unsloth/studio/backend
Ayushman c1947ed946
fix(rocm): prepend system ROCm libs on native Linux to avoid bundled HIP crash (#7233)
* fix(rocm): prepend system ROCm libs on native Linux to avoid bundled HIP crash

Prebuilt llama.cpp bundles ship their own ROCR/HIP runtime which can be
incompatible with the host's amdkfd kernel driver, causing hsa_init()
to crash or report zero devices. The llama-server then silently falls
back to CPU while the UI reports GPU.

The existing workaround (_wsl_system_rocm_lib_dirs) that prepends
/opt/rocm/lib to LD_LIBRARY_PATH was gated on WSL (/dev/dxg) only,
leaving native Linux AMD hosts unprotected.

This commit adds _native_linux_system_rocm_lib_dirs(), a parallel
helper gated on:
- Linux platform (not WSL)
- /dev/kfd present (bare-metal AMD compute)
- Bundle contains bundled HIP libs (libggml-hip.so)
- System has libhsa-runtime64.so(.1)

It is called from both _llama_server_env_for_binary (serve-time)
and binary_env (install-time validation), directly after the WSL
block in both paths.

Fixes #7208

Fixes #7208

* Add UNSLOTH_LLAMA_NO_SYSTEM_ROCM opt-out to native-Linux system ROCm preference for PR #7233

Lets a host where the bundled runtime works but system ROCm is mismatched keep
the bundle. Mirrored in llama_cpp.py and install_llama_prebuilt.py.

* Prefer env-configured ROCm root over /opt/rocm fallback for PR #7233

Put HIP_PATH/HIP_PATH_57/ROCM_PATH-derived roots before /opt/rocm so a stale
/opt/rocm can't shadow the driver-matching install the env vars point at.
Mirrored in llama_cpp.py and install_llama_prebuilt.py.

* Match versioned libggml-hip.so via glob so the native-Linux ROCm fix fires for PR #7233

* Clarify native-Linux ROCm prepend uses the consistent system stack for PR #7233

* llama_cpp: tighten native-Linux ROCm prepend comments (no code change)

---------

Co-authored-by: Daniel Han <danielhanchen@gmail.com>
2026-07-21 18:00:22 -07:00
..
assets Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
auth Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
core fix(rocm): prepend system ROCm libs on native Linux to avoid bundled HIP crash (#7233) 2026-07-21 18:00:22 -07:00
hub Feat/model picker per model config v2 (#7207) 2026-07-20 22:53:22 -07:00
loggers Studio: quiet noisy logs, log real progress, and speed up Windows/macOS dataset prep (#7087) 2026-07-15 06:49:52 -07:00
models Fix resume training crash recovery and MLX checkpoints (#6796) 2026-07-21 02:34:58 -07:00
picker Feat/model picker per model config v2 (#7207) 2026-07-20 22:53:22 -07:00
plugins Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
requirements Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
routes Fix resume training crash recovery and MLX checkpoints (#6796) 2026-07-21 02:34:58 -07:00
state Studio: shareable per-checkpoint preview links (#6486) 2026-06-24 06:31:53 -07:00
storage Fix resume training crash recovery and MLX checkpoints (#6796) 2026-07-21 02:34:58 -07:00
tests Studio: fix loading split GGUFs from the local HF cache (#7273) 2026-07-21 02:48:19 -07:00
utils Studio: fix loading split GGUFs from the local HF cache (#7273) 2026-07-21 02:48:19 -07:00
__init__.py Final cleanup 2026-03-12 18:28:04 +00:00
_platform_compat.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
cloudflare_tunnel.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
colab.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
main.py Feat/model picker per model config v2 (#7207) 2026-07-20 22:53:22 -07:00
mcp_server.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
run.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00
startup_banner.py Replace standalone Studio wording with Unsloth (#7221) 2026-07-19 00:47:04 -07:00