Repository navigation
Studio: install the Vulkan audio.cpp build on AMD GPUs - #13298
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a7ab58d95
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if shutil.which("nvidia-smi"): | ||
| return True | ||
| try: | ||
| return sys.platform.startswith("linux") and bool(os.listdir("/proc/driver/nvidia/gpus")) |
There was a problem hiding this comment.
Detect NVIDIA adapters through DRM sysfs
On Linux systems with both AMD and NVIDIA adapters where NVIDIA uses Nouveau/NVK—or otherwise lacks both nvidia-smi and the proprietary driver's /proc/driver/nvidia/gpus entry—this returns false even though the NVIDIA card is present under DRM as vendor 0x10de. detect_accelerator() consequently selects Vulkan, and the staged check accepts a Vulkan device on either card, so Vulkan can enumerate the NVIDIA adapter first despite the new mixed-host guard. Check DRM vendor IDs for NVIDIA here as well.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: an NVIDIA card driven by Nouveau/NVK with no proprietary driver next to an AMD GPU is a rare mixed host, and even there the Vulkan build runs on a real GPU, so nothing crashes or returns wrong output. The guard is for the common case, the proprietary driver, which nvidia-smi and /proc/driver/nvidia/gpus cover.
|
|
||
|
|
||
| # `--list-devices` prints one `Vulkan:<n> "<name>" [GPU]` row per device ggml-vulkan accepts. | ||
| _VULKAN_DEVICE_ROW = re.compile(r"^Vulkan:\d+\s", re.MULTILINE) |
There was a problem hiding this comment.
Require an AMD device before accepting Vulkan
On an AMD-plus-Intel host, or a Windows Intel-only host with a stale AMD display-adapter registry entry, this accepts an Intel Vulkan:<n> row as proof that the AMD route works. The installed record stores only the Vulkan backend, and normal launches do not select a device, so if Intel is Vulkan device 0 audio.cpp runs on the Intel iGPU instead of the detected AMD GPU. Validate that an enumerated row belongs to AMD and preserve/select that device index rather than accepting any Vulkan device.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing here: on an Intel iGPU plus AMD dGPU host the Vulkan build still runs every model on a GPU, so this is device preference, not a failure or wrong output. Picking a specific Vulkan device would need a recorded device index and a --device at launch in audio_cpp_server.py; that is a separate change if hybrid laptops turn out to need it.
| server, | ||
| backend = backend, | ||
| extra_dirs = _cuda_runtime_dirs(backend), | ||
| require_vulkan_device = requested == "auto" and backend == "vulkan", |
There was a problem hiding this comment.
Revalidate cached auto Vulkan installs
When a previous auto-selected Vulkan install still matches its pins, _pinned_install_matches() returns it before this staged-only device check runs. If the Vulkan device later becomes unavailable while the AMD adapter remains visible in sysfs or the registry—for example after a driver removal, device-permission change, or moving a persisted install into a container—a setup rerun keeps the Vulkan record and every model load still fails instead of installing the CPU fallback. Re-run the device probe before accepting an existing auto Vulkan install.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: losing the Vulkan driver after a working Vulkan install while the AMD adapter stays is rare, and re-probing devices on every setup run costs every AMD host a server start. That host recovers with --force or UNSLOTH_AUDIO_CPP_ACCELERATOR=cpu, the same as any other install whose driver was removed.
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a7ab58d95
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
|
|
||
| # `--list-devices` prints one `Vulkan:<n> "<name>" [GPU]` row per device ggml-vulkan accepts. | ||
| _VULKAN_DEVICE_ROW = re.compile(r"^Vulkan:\d+\s", re.MULTILINE) |
There was a problem hiding this comment.
Reject CPU-class Vulkan devices
When an AMD adapter lacks a working hardware ICD but a software implementation such as lavapipe or SwiftShader is installed, --list-devices can emit a Vulkan:<n> ... [CPU] row. This prefix-only regex accepts that row as a GPU, so the installer records the Vulkan backend and audio_cpp_server.select_backend() subsequently forces --backend vulkan, running workloads through software Vulkan instead of installing the optimized CPU build. Inspect the device classification suffix and reject CPU-class Vulkan rows.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not reachable: the vendored ggml-vulkan only registers eDiscreteGpu / eIntegratedGpu physical devices (ggml_vk_instance_init) and reports every Vulkan device as GPU or IGPU (ggml_backend_vk_device_get_type), so a Vulkan row is never CPU-class. Checked with the pinned Linux Vulkan bundle and only the lavapipe ICD: it prints 'ggml_vulkan: No devices found.' and lists only CPU:0, so the installer falls back to the CPU build. Matching a [GPU] suffix would also reject AMD APUs, which list as [IGPU].
Fixes #13042
On AMD GPUs Studio installs the CPU build of audio.cpp, so audio models run on the CPU even when the GPU runs llama.cpp fine (a 15 s MOSS-Transcribe-Diarize clip took 4:50 on an RX 9070 XT, a 50 s one timed out). The Vulkan bundles are already pinned;
detect_accelerator()just never picked them.Changes
studio/install_audio_cpp_prebuilt.py:detect_accelerator()returnsvulkanwhen an AMD display adapter is present and no NVIDIA card is. AMD is read the wayinstall_llama_prebuilt.pyalready routes llama.cpp to Vulkan: PCI vendor0x1002in Linux DRM sysfs, the Windows display-adapter registry (windows_amd_gpu_in_registry). Anynvidia-smi(or/proc/driver/nvidia/gpuson Linux) keeps the old answer, so NVIDIA hosts, mixed hosts and Macs are unchanged.audiocpp_server --list-devices, aVulkan:<n>row) before it is swapped in. If it lists none (no Vulkan driver,libvulkan.so.1missing, a software-only ICD), the installer installs the CPU build instead and records the host as detectedvulkan, so later setup runs are no-ops rather than re-downloading the Vulkan bundle. This matters because the Vulkan server does not fall back to CPU on its own; it exits withVulkan backend requested but registry 'Vulkan' has no device 0.--accelerator vulkan/UNSLOTH_AUDIO_CPP_ACCELERATOR=vulkanis never device-checked or downgraded (a Docker build sees no GPU).Existing AMD installs were recorded as auto with detected
cpu, so the nextunsloth studio update/ Desktop update sees the new detection and installs the Vulkan bundle. Intel GPUs stay on the CPU build: the Vulkan bundle is only confirmed on AMD so far. The HIP bundle half of the issue is release packaging in unslothai/audio.cpp and is not part of this PR.Tests
tests/studio/install/test_install_audio_cpp_prebuilt_logic.py: detection on Linux (AMD, AMD + Intel, Intel only, NVIDIA with and without a CUDA version) and Windows (registry yes / no / raising), the--list-devicescheck (GPU row, CPU only, loader failure, OSError, timeout), and the install flow (AMD auto installs Vulkan; no Vulkan GPU installs CPU once and the rerun makes no lookup; an existing CPU install moves to Vulkan; explicit vulkan is not checked). 10 of the new tests fail on main, 116/116 pass on this branch.Real bundles on Linux x86_64 (
v0.9.0-unsloth.1, detection pinned to "AMD GPU, no NVIDIA"):bin-ubuntu-x64-cpu-portable, backend cpubin-ubuntu-x64-vulkan, backend vulkanfinds no Vulkan GPU on this host; installing the CPU build, backend cpu; rerunalready matchesbin-ubuntu-x64-vulkan; rerunalready matches--accelerator vulkan, no GPUbin-ubuntu-x64-vulkanas beforeMOSS-Transcribe-Diarize q4_k on a 15.9 s clip gives the identical transcript on the CPU and Vulkan bundles.
On real AMD hardware
gfx1151 (Radeon 8060S), same job and box for main (fc5cf50) and this PR (5a7ab58), the real installer with no detection patched (Linux read
card1/device/vendor = 0x1002, Windows the display-adapter registry). MOSS-Transcribe-Diarize q4_k on a 15.9 s clip, two repeats:--list-deviceson this PRwindows-x64-cpu-portable.zipwindows-x64-vulkan.zipVulkan:0 "AMD Radeon(TM) 8060S Graphics" [IGPU]ubuntu-x64-cpu-portable.tar.gzubuntu-x64-vulkan.tar.gzVulkan:0 "AMD Radeon Graphics (RADV GFX1151)" [IGPU]The Windows CPU time matches the report (4:50 for a 15 s clip). A second install on every side prints
already matches. The Windows runs used a 16 kHz copy of the clip: the MOSS model on the Windows bundles (CPU and Vulkan alike, main included) refuses non-16 kHz input withrequires SOXR for non-16-kHz audio, which is separate from this change.