Skip to content

[Bug] Silent CPU fallback on native Linux AMD (RDNA3/gfx1100): studio-prepended /opt/rocm/lib hides the GPU from the bundled llama-server #14906

Closed

Description

@carottemendoza

Possible regression from the fix for #7208 (system-ROCm prepend on native Linux).

Environment:

  • Unsloth Desktop (AppImage, Linux), fresh install — reproduces identically after full uninstall/reinstall
  • OS: CachyOS (Arch-based), native Linux (/dev/kfd present, no /dev/dxg)
  • GPU: AMD Radeon RX 7900 XTX (RDNA 3, gfx1100), 24 GB
  • CPU: AMD Ryzen 7 9800X3D
  • System ROCm 7.2 properly installed; rocminfo sees gfx1100
  • Studio venv PyTorch: ROCm build (HIP 7.2.26015), torch.cuda.is_available() = True
  • llama.cpp prebuilt: build 11798 (ec0da70e9), "Compiled by the Unsloth team"

What happens:

Loading a GGUF model (reproduced with unsloth/LFM2.5-24B-A2B-GGUF, UD-Q4_K_XL) and prompting it shows CPU-bound inference: the model is resident in system RAM (~20 GB RSS on llama-server), the GPU stays idle. There is no error or warning anywhere, even at --verbosity 4.

The studio's planner correctly detects the GPU via PyTorch and builds a full offload plan, so the launch flags (-ngl -1, etc.) are all correct. The failure is purely in library resolution at llama-server startup: the GPU never gets registered as a device.

Log excerpt from the studio-launched llama-server (~/.unsloth/studio/logs/llama-server/):

device_info:
  - CPU     : AMD Ryzen 7 9800X3D 8-Core Processor (...)
load_tensors:          CPU model buffer size =  6133.85 MiB
load_tensors:   CPU_REPACK model buffer size =  8046.00 MiB
llama_kv_cache:        CPU KV buffer size =  2560.00 MiB
sched_reserve:        CPU compute buffer size =   217.02 MiB

No ROCm0 entry in device_info; no WARN/ERR lines.

Root cause:

The spawn environment the studio gives llama-server sets:

LD_LIBRARY_PATH=/opt/rocm/lib:/opt/rocm/lib/llvm/lib:~/.unsloth/llama.cpp/build/bin:~/.unsloth/studio/unsloth_studio/lib/python3.13/site-packages/torch/lib

With /opt/rocm/lib first, the dynamic loader shadows the ROCm libraries bundled with the llama.cpp build with the system ROCm installation's copies. On this machine that combination makes the HIP backend fail to initialize silently — the GPU is never registered, and -ngl -1 becomes a no-op.

Verified by bisection of the spawned process environment (captured from /proc/<pid>/environ, 117 variables): LD_LIBRARY_PATH is the only variable whose presence hides the GPU, and within it, only the /opt/rocm/lib entry is sufficient.

Minimal reproduction, no model load needed:

# Bare invocation (clean environment) — GPU IS detected:
~/.unsloth/llama.cpp/llama-server --list-devices
# → ROCm0: AMD Radeon RX 7900 XTX (24560 MiB, ...)

# Same binary with /opt/rocm/lib injected — GPU VANISHES:
LD_LIBRARY_PATH=/opt/rocm/lib ~/.unsloth/llama.cpp/llama-server --list-devices
# → Available devices:
#   (none)

The remaining studio paths (/opt/rocm/lib/llvm/lib, build/bin, torch's lib) individually do not hide the GPU.

Relation to prior issues:

This looks like the mirror image of #7208, and part of a broader pattern in which different AMD setups need opposite LD_LIBRARY_PATH orderings:

Put together: two gfx1100 users on native Linux with system ROCm 7.2 need opposite orderings (bundled-first here, system-first in #7208), RDNA4 needs system-first, and gfx1151 needed system-only. Presumably the shipped bundles carry different ROCR builds over time, each compatible with different subsets of host drivers and system-ROCm versions — so any fixed ordering will keep breaking one subset of AMD hosts.

Workaround (verified working):

Replace the ~/.unsloth/llama.cpp/llama-server symlink with a wrapper that strips /opt/rocm/lib from LD_LIBRARY_PATH before exec-ing the real binary:

#!/bin/bash
if [ -n "$LD_LIBRARY_PATH" ]; then
    export LD_LIBRARY_PATH=$(echo "$LD_LIBRARY_PATH" | tr ':' '\n' | grep -v '^/opt/rocm/lib$' | paste -sd:)
fi
exec ~/.unsloth/llama.cpp/build/bin/llama-server "$@"

After applying, all buffers land on the GPU and inference runs at GPU speed:

load_tensors:        ROCm0 model buffer size = 14179.85 MiB
llama_kv_cache:      ROCm0 KV buffer size =  2560.00 MiB
sched_reserve:      ROCm0 compute buffer size =   213.01 MiB

Suggestions:

  1. Detection over ordering: probe GPU visibility (e.g. run --list-devices or check hsa_init) with and without the system ROCm prepend at spawn time, and keep whichever ordering actually detects the GPU. Any fixed ordering will keep breaking one subset of AMD hosts — the four issues above each needed a different one.
  2. Fail loudly: when the user requested GPU offload (-ngl > 0) and no GPU backend initializes, emit a prominent warning instead of silently serving on CPU. [Bug] [ROCm] llama-server silently falls back to CPU on native Linux AMD: bundled ROCR runtime crashes in hsa_init(), system-ROCm override only applied on WSL #7208's author asked for the same thing — the silent fallback is what makes this costly to diagnose. The only observable symptom is slow tokens.

Activity

  1. added
    feature request
    on Oct 23, 2026
  2. danielhanchen commented on Oct 23, 2026

    @danielhanchen
    Member

    Fixed! Studio put the system ROCm libraries ahead of the ROCm runtime bundled with llama.cpp on native Linux, and on hosts like yours where the system copy does not match, the GPU silently vanished and the model ran on the CPU. Studio now checks once whether llama-server can see the GPU with that ordering, and if it only sees it with the bundled runtime, it uses the bundled runtime and logs a warning. Hosts where the system ROCm ordering is the one that works keep it. Fixed in #14933, which will be in the next Studio / Desktop release. Thanks for the detailed bisection, it made this easy to pin down. Reopen if it still happens.

  3. carottemendoza commented on Oct 23, 2026

    @carottemendoza
    Author

    Awesome! Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugfeature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions