Repository navigation
Studio: fix WSL Strix Halo GPU on reinstall (ROCDXG drop-in + system HIP before bundle) - #6227
Conversation
_maybe_bootstrap_rocm_wsl calls _ensure_rocm_probe_env (which exports a transient HSA_ENABLE_DXG_DETECTION + adds /opt/rocm/bin to PATH on the installer process) right before the "rocminfo enumerates gfx1151 -> already set up, return early" gate. On any reinstall over an existing /opt/rocm -- the common case, since the uninstaller keeps shared ROCm userspace but removes /etc/profile.d/unsloth-rocm-wsl.sh -- that probe env makes rocminfo succeed, so the gate returns 0 WITHOUT ever persisting the drop-in. The transient env dies with the installer, so the next login shell (Studio, llama-server) sees no GPU: torch cuda_avail=False, rocminfo finds nothing, the llama.cpp ROCm prebuilt segfaults on a GPU it can't reach. Factor the drop-in writer into _persist_rocm_wsl_dropin() and call it before the early return so the persistent env is restored whenever librocdxg is present. Idempotent (only writes when the drop-in is missing), gated on librocdxg so it never fires on non-WSL/non-ROCDXG hosts, root-writes or sudo-tees like before. The fast-path branch now reuses the same helper. Reproduced on gfx1151 (Radeon 8060S) under dash (the curl|sh shell): before the fix a reinstall left the drop-in absent and torch cuda_avail False; after, the drop-in is persisted and a fresh login shell reports cuda_avail True. Verified under both dash and bash, and idempotent on re-run.
…151)
The lemonade / published llama.cpp ROCm prebuilts bundle their own HIP
runtime (libamdhip64) built for bare-metal Linux. In WSL the GPU is reached
through the system ROCm's librocdxg bridge over /dev/dxg, which the bundled
runtime cannot drive -- it segfaults on the first GPU call. So:
- install_llama_prebuilt.py: the prebuilt's llama-quantize/llama-server
validation runs with the bundle dir first on LD_LIBRARY_PATH, segfaults
(empty stderr), and the install silently falls back to a CPU source build
(which on this host can't even build for GPU -- hipcc absent). The Strix
Halo WSL user ends up on CPU despite a working GPU.
- llama_cpp.py: even if a GPU prebuilt were kept, the serve-time launcher
put the bundle dir first too, so it would crash at load.
Fix: on a ROCDXG WSL host (gated on /dev/dxg + "microsoft" /proc/version +
a librocdxg-providing /opt/rocm), prepend the system ROCm lib dir to
LD_LIBRARY_PATH so the WSL-capable libamdhip64 + librocdxg load first, while
the bundle still supplies libggml-hip / librocblas with the gfx1151 kernels.
Set HSA_ENABLE_DXG_DETECTION=1 alongside. Added _wsl_system_rocm_lib_dirs()
to both modules (kept identical so a prebuilt that passed install validation
runs the same way at serve time). Strict no-op on bare-metal Linux, NVIDIA,
macOS, and Windows.
Verified on gfx1151 (Radeon 8060S) in WSL (ROCm 7.2.1 + librocdxg, Adrenalin
ROCDXG): before, the lemonade gfx1151 prebuilt segfaulted and the install
fell back to a broken CPU build; after, install_llama_prebuilt validates and
keeps the GPU prebuilt (source=published, prebuilt_fallback_used=False), and
Studio serves Qwen3-1.7B-GGUF at 53 tok/s with the model resident in GPU
memory (llama-server device_info: ROCm0 = AMD Radeon 8060S).
- _wsl_system_rocm_lib_dirs: no-op without /dev/dxg, on bare-metal Linux, and on WSL without librocdxg; returns the system lib dir on a ROCDXG WSL host. - binary_env: prepends the system ROCm lib dir ahead of the bundle and sets HSA_ENABLE_DXG_DETECTION on WSL; unchanged on bare-metal Linux. - install.sh: _persist_rocm_wsl_dropin exists, is gated on librocdxg, and the rocminfo-already-works early return calls it before returning. - llama_cpp.py: the serve-time launcher prepends the WSL rocm dirs before the bundle dir (mirrors binary_env).
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 479976b429
ℹ️ 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".
| printf 'export HSA_ENABLE_DXG_DETECTION=1\n' | ||
| printf 'export TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1\n' | ||
| printf 'export PATH="%s/bin:${PATH}"\n' "${_rw_rocm}" | ||
| printf 'export LD_LIBRARY_PATH="%s/lib:${LD_LIBRARY_PATH:-}"\n' "${_rw_rocm}" |
There was a problem hiding this comment.
Include lib64 when persisting the ROCm bridge path
When the guard above is satisfied by /opt/rocm/lib64/librocdxg.so, the drop-in still persists only /opt/rocm/lib in LD_LIBRARY_PATH. In that lib64-only layout, future shells launched after the reinstall will not have the directory containing librocdxg on the loader path, so this new persistence path can still leave rocminfo/Studio unable to see the WSL GPU after the installer exits.
Useful? React with 👍 / 👎.
| # bundle still provides libggml-hip / librocblas. No-op on bare metal. | ||
| _wsl_rocm = _wsl_system_rocm_lib_dirs() | ||
| if _wsl_rocm: | ||
| ld_dirs = [*_wsl_rocm, *ld_dirs] |
There was a problem hiding this comment.
Avoid letting system ROCm shadow bundled rocBLAS
On ROCDXG WSL hosts with a normal ROCm install, /opt/rocm/lib contains more than the WSL HIP bridge (for example librocblas/hipblaslt), so prepending the entire system ROCm directory ahead of the prebuilt directory makes the dynamic loader choose the system copies of every overlapping ROCm library. That contradicts the bundled-runtime path that copies lib*.so* plus the ROCm kernel trees for the selected prebuilt, and it can make validation/runtime use a different rocBLAS/hipBLASLt than the archive that was selected for gfx1151; the same ordering is mirrored at serve time, so the fix needs to preserve the bundled BLAS libraries while only forcing the WSL-capable HIP bridge/runtime.
Useful? React with 👍 / 👎.
Condense the drop-in / system-HIP-ordering comments and docstrings added in this PR. Verified comment-only via AST parse + py_compile + sh/bash -n, the 308-test rocm_support suite, and a dash functional re-run of the bootstrap (drop-in still persisted, env still set).
Summary
Three fixes that restore gfx1151 GPU on WSL for Unsloth Studio after PR #5940 landed. All are strictly WSL-gated (no-op on bare-metal Linux, NVIDIA, macOS, Windows). Found while re-running the full teardown→reinstall→verify cycle on a real Strix Halo (Radeon 8060S) under WSL2.
1.
install.sh: persist the ROCm-on-WSL drop-in even when rocminfo already works_maybe_bootstrap_rocm_wslcalls_ensure_rocm_probe_env(transientHSA_ENABLE_DXG_DETECTION+/opt/rocm/binon PATH) right before the "rocminfo enumerates gfx1151 → return early" gate. On any reinstall over an existing/opt/rocm— the common case, since the uninstaller keeps shared ROCm but removes/etc/profile.d/unsloth-rocm-wsl.sh— that probe env makes rocminfo succeed, so the gate returns without persisting the drop-in. The transient env dies with the installer, so the next login shell (Studio, llama-server) sees no GPU: torchcuda_avail=False, rocminfo finds nothing. Factored_persist_rocm_wsl_dropin()and call it before the early return.2 + 3. WSL: load the system HIP runtime before a prebuilt's bundled one (
install_llama_prebuilt.py+llama_cpp.py)The llama.cpp ROCm prebuilts bundle their own HIP runtime built for bare-metal Linux. In WSL the GPU is reached through the system ROCm's
librocdxgbridge over/dev/dxg, which the bundled runtime can't drive — it segfaults on the first GPU call. So the prebuilt fails validation (empty stderr) and the install silently falls back to a CPU source build. Fix: on a ROCDXG WSL host, prepend the system ROCm lib dir toLD_LIBRARY_PATH(in both the install-time validator and the serve-time launcher, kept identical) so the WSL-capablelibamdhip64+librocdxgload first while the bundle still supplieslibggml-hip/librocblaswith the gfx1151 kernels.Verification (real gfx1151, Radeon 8060S, WSL2 + ROCm 7.2.1 + librocdxg)
cuda_avail=False; the lemonade gfx1151 prebuilt segfaulted → install fell back to a broken CPU build.cuda_avail=True;install_llama_prebuiltvalidates and keeps the GPU prebuilt (prebuilt_fallback_used=False); Studio serves Qwen3-1.7B-GGUF at 53 tok/s with the model resident in GPU memory (llama-serverdevice_info: ROCm0 = AMD Radeon 8060S); the 3-engine cross-origin HTML client test passes.dash(thecurl|shshell) andbash, idempotent.test_rocm_support.py308 passed, backend prebuilt/llama tests 59 passed. The 2 pre-existing flash-attn test failures on this host are unrelated (fail identically on basemain).🤖 Generated with Claude Code