Repository navigation
Description
Prebuilt ROCm binary crashes with "out of memory" on hipStreamCreateWithFlags; source build of the same exact commit works fine
Summary
The prebuilt linux/rocm release asset for tag b11160-mix-a6922cc crashes on load with a ROCm "out of memory" error at the very first hipStreamCreateWithFlags call. Building llama-server from source at the exact same commit (119fa9dc43cd4d63e89a7b5d11f9378b84c52822), with a standard Nix-packaged ROCm 7.2.3 toolchain, works correctly and produces real generation output at ~121 tok/s. This points to something specific to how the prebuilt asset bundles/links its ROCm runtime, not a hardware or driver problem.
Environment
- OS: NixOS 26.05, kernel 7.2.7 (amdgpu driver in-tree, no dmesg/kfd errors at any point)
- GPU: AMD Radeon 680M (Rembrandt iGPU), reports as
gfx1035. Not on AMD's or llama.cpp's officially validated gfx list, soHSA_OVERRIDE_GFX_VERSION=10.3.0is set to present asgfx1030(RDNA2 desktop) — without this the runtime refuses to initialize at all, which is expected/unrelated to this bug. rocminfo(from a Nix-packaged ROCm 7.2.3 SDK) correctly enumerates the device asgfx1030, 12 CUs, reports a 13.6GB GLOBAL/COARSE_GRAINED memory pool.ulimit -l(memlock): tested at both the OS default (8MB, soft+hard) and after raising it to 8GB viasecurity.pam.loginLimits+ full reboot. No difference in behavior — ruled out as the cause.- No
amdgpu/kfd-related messages injournalctl -kat the time of the crash — the failure appears to be purely userspace (inside the bundled HIP/HSA runtime), not a kernel/driver rejection.
Steps to reproduce (prebuilt asset — crashes)
- Install via
unsloth studio update(this pullsunslothai/llama.cpp@b11160-mix-a6922cc, which for this platform resolves to a prebuilt binary bundling its ownlibamdhip64.so.7,libhsa-runtime64.so.1,libhipblas.so.3, etc. directly alongside the binary). - Run:
./llama-server -m <any GGUF, tested with bartowski/Qwen2.5-0.5B-Instruct-GGUF Q4_K_M> \ --port 38999 -ngl 99 - Observe:
Crash is immediate, before any real model-memory allocation.
ggml/src/ggml-cuda/ggml-cuda.cu:134: ROCm error ROCm error: out of memory current device: 0, in function stream at ggml/src/ggml-hip/../ggml-cuda/common.cuh:1561 hipStreamCreateWithFlags(&streams[device][stream], 0x01)-nglvalue doesn't matter; happens the same with-ngl 1.
Steps to reproduce the fix (source build — works)
git clone --branch b11160-mix-a6922cc https://github.com/unslothai/llama.cpp.git src
# ROCm 7.2.3 toolchain from nixpkgs (rocmPackages: clr, hipcc, rocm-cmake, rocminfo,
# rocm-comgr, rocm-device-libs, rocm-runtime, hipblas(+common/lt), rocblas, rocsolver)
cmake -B build -S src -DGGML_HIP=ON -DAMDGPU_TARGETS=gfx1030 -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_HIP_COMPILER=<rocm-toolchain>/bin/clang
cmake --build build -j16 --target llama-server llama-quantize(Note: had to force gcc/g++ for host C/C++ — using the ROCm-vendored clang for host code too hits an unrelated mm_malloc.h/glibc posix_memalign noexcept conflict on this glibc version, orthogonal to the GPU issue.)
Running the resulting binary with the exact same flags Studio uses (--parallel 4 --flash-attn on --no-context-shift -c 32768 -ngl -1 --fit off --metrics --kv-unified --jinja --spec-default --load-mode none) against the same model works correctly:
model loaded
listening on http://127.0.0.1:38997
and a real /v1/chat/completions request returns a valid completion at 121.6 tok/s (predicted_per_second in the response timings).
What this suggests
Since it's the same source commit, the difference must be in how the prebuilt release asset was built/linked (possibly a different exact ROCm runtime version than the 7.2.3 SDK used here, different AMDGPU_TARGETS set baked into the prebuilt multi-arch "mix" bundle, or a build/link flag difference specific to the release pipeline). Given the "mix" naming in the release tag, this may be specific to how the multi-architecture prebuilt bundle is assembled for gfx1030/RDNA2 targets — possibly not exercised in that pipeline's own testing since gfx1035 (and the override-to-gfx1030 path) is an unofficial combination to begin with, but worth checking whether genuine gfx1030 hardware (RX 6600/6700/etc.) hits the same prebuilt-vs-source discrepancy, since that would point to a real packaging bug rather than something override-specific.
What I'm not certain about
- Whether this reproduces on officially-supported gfx1030 hardware (I only have the override case to test).
- The exact ROCm runtime version bundled in the prebuilt asset (I didn't extract/inspect it beyond
lddshowing locallibamdhip64.so.7/libhsa-runtime64.so.1files bundled next to the binary, vs. our source build linking against the Nix-packaged ROCm 7.2.3 versions of the same).
Happy to run any additional diagnostics against the prebuilt asset if useful — I already have both binaries side by side for comparison.
Activity
danielhanchen commentedon Oct 8, 2026
Thanks for the very thorough report, the side by side source build made this much easier to narrow down.
The llama.cpp source is the same, but the ROCm userspace is not. The
gfx103XLinux bundle ships a TheRock runtime (libamdhip64.so.7.16.26332,libhsa-runtime64.so.1.21.0), while your working build uses stock ROCm 7.2.3. One relevant difference between the two:cu_count * 32waves tocu_count * simd_per_cu * max_waves_per_simdread from KFD topology.kfd_queue.c) still usescu_count * 32for gfx10 / gfx11. When the runtime's buffer is smaller than that, or differs at all on the non-SVM path, KFD rejects queue creation withEINVAL, and HIP reports that asout of memoryat the firsthipStreamCreateWithFlags. That would fit your trace: it fails before any model memory is allocated, and-ngland memlock make no difference.common.cuh:1561,hipStreamCreateWithFlags(&streams[device][stream], 0x01)) with this same bundle on a Strix Halo by making the runtime read a differentmax_waves_per_simdthan the kernel uses. A rebuild of the bundled runtime with the old formula fixes it there. What we cannot tell from here is whether your 680M actually reports a value that triggers it, hence the checks below.Could you run these three checks so we can confirm it on your 680M?
KFD topology values (no root needed):
With
simd_per_cu 2, amax_waves_per_simdbelow 16 means the bundled runtime reserves less queue save space than the kernel requires, which the kernel always rejects. A value above 16 (for example 20) is only rejected when the runtime is not using SVM for that buffer (check 2). If it reads exactly 16, this mismatch is not your cause and we need to look elsewhere.Whether the size check is involved at all. Run the prebuilt with SVM turned off for the runtime's queue buffers:
Please tell us whether that run and your normal run each start. With SVM off you can also see the kernel side:
A line like
expected size 0x... not equal to mapping addr ... size 0x...confirms it.Same prebuilt binary, but with your Nix ROCm 7.2.3 runtime loaded first (the bundle uses
RUNPATH=$ORIGIN, soLD_LIBRARY_PATHtakes precedence):If the prebuilt loads and generates this way, the bundled runtime is confirmed as the cause.
Until this is fixed in the bundle, the source build you already have is the right workaround. Studio puts a system ROCm ahead of the bundled one when it finds it under
ROCM_PATH,HIP_PATH, or/opt/rocm. On NixOS, pointingROCM_PATHat a root whoselib/containslibhsa-runtime64.so.1before starting Studio should also work. The bundle side fix is unslothai/llama.cpp#255: it rebuilds the bundledlibhsa-runtime64with the kernel's wave count, which clears the reproduction above. Your results from the checks will tell us whether it also covers your 680M. We are also looking at making Studio find split Nix ROCm packages on its own.danielhanchen commentedon Oct 9, 2026
A correction to my previous comment: the queue sizing mismatch I described is not your cause. Public rocminfo dumps from other Radeon 680M machines show
Compute Unit: 12,SIMDs per CU: 2,Max Waves Per CU: 32, which is exactly what the kernel driver expects, so on a 680M the bundled runtime and the kernel agree. That mismatch only hits gfx10.1 cards (RX 5000 series), which report 40. unslothai/llama.cpp#255 fixes that case, not yours. Sorry for the noise.So check 1 from my previous comment is no longer needed. Checks 2 and 3 are still the most useful next step, since they separate the bundled runtime from everything else:
RUNPATH=$ORIGIN, soLD_LIBRARY_PATHwins):If you can, please also run the failing prebuilt once with
AMD_LOG_LEVEL=4and attach the last 100 or so lines before theROCm error, so we can see which HSA call fails underneathhipStreamCreateWithFlags.Until then, your source build against ROCm 7.2.3 remains the right workaround.
ROCm Linux: rebuild libhsa-runtime64 with the KFD CWSR wave count
danielhanchen commentedon Oct 15, 2026
Closing this for now since we have not been able to reproduce it on our side.
To be clear about the earlier llama.cpp change: unslothai/llama.cpp#255 fixes a queue sizing crash on gfx10.1 (RX 5000 series) cards, which is a different problem from yours. We do not have a fix for the Radeon 680M crash yet.
Your source build against ROCm 7.2.3 remains the right workaround. If you can run the two checks from my last comment (
HSA_USE_SVM=0, and the prebuilt with your Nix ROCm 7.2.3 libraries loaded first), please post the results here and we will reopen and pick it up from there.