Repository navigation
[Bug] Unsloth Studio: chat-only installs run llama.cpp on the CPU because the CUDA bundles ship no cudart/cublas - #17463
Merged
LeoBorcherding merged 6 commits intoNov 12, 2026
Conversation
…DA llama.cpp installs
…dle selection on Linux
… DLL dirs, before installing the runtime wheels
…iding to supply CUDA 12
oobabooga
approved these changes
Nov 11, 2026
github-actions Bot
pushed a commit
to Flipped-168/unsloth
that referenced
this pull request
Nov 14, 2026
…pair in the GPU backend warning (unslothai#17675) Fixes unslothai#17663 After an in-app llama.cpp update on Windows (RTX 5090 Laptop), llama-server ran entirely on the CPU, and only Repair installation brought the GPU back. ## Why The `app-*` Windows CUDA bundles ship `ggml-cuda.dll` but no CUDA runtime. In b12319 (and b12284), the cuda13 `ggml-cuda.dll` imports `cublas64_13.dll`, `cublasLt64_13.dll` and `nvcudart_hybrid64.dll`. llama.cpp loads its backends dynamically (`GGML_BACKEND_DL`), so when those cannot be found it falls back to the CPU without an error. unslothai#17463 (merged after v0.1.917-beta, not released yet) installs NVIDIA's runtime wheels when an install has no runtime. Two gaps remain on the path this report took: 1. The wheel step finds uv only through `shutil.which("uv")`. A Desktop-started backend can run with a PATH that lacks uv's directory (`s3_runtime._find_uv` and `mlx_repair._uv_executable` already guard this). The fallback `python -m pip` cannot work either, because the venv is made by `uv venv` with no pip. In that case an in-app update logs "CUDA runtime wheel install failed; llama.cpp will run on the CPU" and still reports success. The step now also looks in `~/.local/bin` and `~/.cargo/bin`, where install.ps1 / install.sh put uv by default, the same lookup `mlx_repair` uses. 2. When the GPU is found but llama.cpp cannot use it, the chat warning pointed only at the logs. It now also says that Repair installation in the desktop app, or re-running the installer, reinstalls the engine, which is what fixed this report. The wording matches the existing PyTorch mismatch notice. Nothing changes when uv is on PATH, and the warning shows under the same conditions as before. ## Tests - `tests/studio/install/test_no_torch_cuda_runtime_wheels.py::test_uv_off_path_is_still_used`: with no uv on PATH and uv in `~/.local/bin`, the wheels are installed with that uv. Fails without the change. - `studio/frontend/tests/partial-offload.test.ts`: the GPU backend warning names Repair installation. Fails without the change. - `tests/studio/install`: 21 failures on both base and head (pre-existing, for example in `test_dependency_pass_skips.py`); head passes one more test, the new one. Not covered: a real Windows Desktop run. The reporter's exact cause is unconfirmed without their install log, so this hardens the path unslothai#17463 added rather than proving their root cause. ## Screenshots The toast after loading a model whose GPU llama.cpp could not use. This was a real CPU load of SmolLM2-135M Q4_K_M in Studio, built from the merge base (left) and this branch (right), with only the load response's GPU backend flag forced on, since this host has no GPU. 
danielhanchen
added a commit
to LeoBorcherding/unsloth
that referenced
this pull request
Nov 18, 2026
…ai#18168) Chat-only (no torch) Linux installs with an NVIDIA GPU run audio.cpp (text to speech, music, dictation) on the CPU, even after unslothai#17463 fixed the same problem for llama.cpp. ## Why The Linux audio.cpp CUDA bundles link `libcudart`, `libcublas` and `libcufft` and ship none of them. A full install borrows them from torch's `nvidia-*` wheels. A chat-only install has no torch, so `_linux_cuda_runtime_available` fails and `resolve_for_request` installs the CPU build. Since unslothai#17463 the llama.cpp step installs `nvidia-cuda-runtime` and `nvidia-cublas`, but nothing installs cuFFT, so audio.cpp still falls back: ``` audio.cpp: no CUDA 13 runtime (cudart, cuBLAS) for audio-v0.9.5-unsloth.1-bin-ubuntu-x64-cuda13.tar.gz; installing the CPU build ``` An existing chat-only install also never recovers: `_record_fits_request` only looks the GPU build up again when torch's runtime appears, and a chat-only install never gets torch, so every update answers "already matches" with the CPU build. ## Change - `resolve_for_request`: when the chosen Linux CUDA bundle has no runtime and the env has no torch (Linux x86_64 only), install NVIDIA's wheels for that CUDA line first (`nvidia-cuda-runtime`, `nvidia-cublas`, `nvidia-cufft`, or the `-cu12` names), then check again. Only if they are still missing does it install the CPU build, as today. Wheels that are already installed are left alone (uv no-ops them), and nothing is installed when the runtime is already present. - `_record_fits_request`: a chat-only CPU fallback recorded before this change is looked up once more on the next update, so existing installs move to the GPU build. The new install record carries `cuda_runtime_wheels_tried`, so a host where the wheels cannot install (offline, a blocked mirror) keeps answering "already matches" without a lookup on later runs, as it does today. - A kept CPU install (the resolver picked the same CPU asset again after the wheels failed) is marked too, and a CPU fallback that already tried the wheels does not try again when a newer audio.cpp release comes out. So a host whose package index is blocked pays for at most one attempt. - `--print-asset` only resolves and never installs wheels. Hosts with torch, Windows (which downloads its own cudart archive), macOS, AMD and arm64 take exactly the same path as before. The download is the cuFFT wheel (about 157 MB plus nvjitlink) on top of what the llama.cpp step already installed, and only on chat-only Linux NVIDIA hosts. ## Tests Real run on a Colab T4 (driver 580, CUDA 13.0) with every `libcudart`, `libcublas`, `libcublasLt` and `libcufft` moved off the VM so only the driver is left (`cuInit` = 0, 1 device). Each arm is a torch-free venv that ran the llama.cpp installer first, as a chat-only install does, then the arm's audio.cpp installer: | Case | audio.cpp bundle | `audiocpp_server --version` | `libcufft.so.12` | |---|---|---|---| | main | `ubuntu-x64-cpu-portable` | `backends: cpu` | not linked (CPU build) | | this PR | `ubuntu-x64-cuda13` | `backends: cpu,cuda` | venv `nvidia/cu13/lib` | | existing CPU install, then this PR's installer (update) | `ubuntu-x64-cuda13` | `backends: cpu,cuda` | venv `nvidia/cu13/lib` | | same, run again | `already matches`, nothing downloaded | `backends: cpu,cuda` | venv `nvidia/cu13/lib` | `tests/studio/install/test_install_audio_cpp_prebuilt_logic.py`: 244 passed (20 new). With only the functional lines reverted (helpers kept), the behaviour tests fail: wheels installed and CUDA kept, CPU fallback when the wheels fail, an old CPU record looked up once, the record marked so reruns stay offline, a kept CPU install marked after a failed attempt, and no retry for a newer release. Not covered: an offline rerun pinned to the installed release (`UNSLOTH_AUDIO_CPP_TAG` or `--published-release-tag`) on an old chat-only CPU install now looks the release up once instead of reusing it, and fails if the lookup is unavailable. That needs an explicit pin and no network at the same time, so it is left as is.
shimmyshimmer
pushed a commit
that referenced
this pull request
Nov 18, 2026
…nly installs (#18275) Chat-only (no torch) Windows x64 installs with an NVIDIA GPU download cuBLAS twice: once for llama.cpp, once for audio.cpp. ## Why Since #17463 the llama.cpp step installs NVIDIA's `nvidia-cuda-runtime` and `nvidia-cublas` wheels into the Studio env on chat-only installs (about 410 MB for CUDA 13). The audio.cpp Windows CUDA bundle then downloads its own `cudart-windows-x64-cuda13.zip` (589 MB; 724 MB for CUDA 12), because `torch_provides_cuda_runtime` only looks in `torch\lib`. That archive holds `cudart64_13.dll`, `cublas64_13.dll`, `cublasLt64_13.dll` (458 MiB) and `cufft64_12.dll` (271 MiB), so everything but cuFFT is already on disk. ## Change `studio/install_audio_cpp_prebuilt.py`, Windows x64 only, when there is no torch and the bundle would download its cudart archive: - If the env's `nvidia\*` wheel dirs (the ones `audio_cpp_server` already puts on `PATH`) hold `cudart64_N`, `cublas64_N` and `cublasLt64_N` for the bundle's CUDA line, install only `nvidia-cufft` (`nvidia-cufft-cu12` for CUDA 12), check again, and skip the archive. - Otherwise download the archive exactly as today: cuFFT failing to install, wheels for another CUDA line, Windows ARM64, or a torch install. So it never downloads more than it does now. - A kept install without the archive is intact while those DLLs are still in the env (`_cuda_runtime_satisfied`), so a later setup reinstalls if they go away. Installs that already carry the archive are untouched. Saves about 395 MB per chat-only Windows CUDA 13 install and about 500 MB per CUDA 12 install. Linux, macOS, AMD, Windows ARM64 and installs with torch take the same path as before. On Windows `audiocpp_server.exe` imports `cufft64_12.dll` and `ggml-cuda.dll` imports `cublas64_13.dll`, so both have to resolve from the wheel dirs, which the run below checks. ## Tests `windows-latest` (no GPU), each arm a torch-free venv holding llama.cpp's chat-only CUDA 13 wheels, bundle `audio-v0.9.5-unsloth.1-bin-windows-x64-cuda13.zip`: | | main | this PR | |---|---|---| | CUDA runtime | downloads `cudart-windows-x64-cuda13.zip`, 4 DLLs beside the server | installs `nvidia-cufft` 12.5.0.14 (+ `nvidia-nvjitlink`), no DLLs beside the server | | `audiocpp_server.exe --version` with the Studio runtime dirs on `PATH` | exit 0, `backends: cpu,cuda` | exit 0, `backends: cpu,cuda` | | `ggml-cuda.dll` loads | yes | yes, from the wheel dirs | | same server without the wheel dirs | n/a | exit `0xC0000135` (DLL not found) | | installer run again | n/a | `already matches`, nothing installed | `tests/studio/install/test_install_audio_cpp_prebuilt_logic.py`: 255 passed (14 new). With only the two functional hunks reverted (helpers kept), the install-skips-the-archive and intact-install tests fail. Not covered here: a real Windows NVIDIA GPU running audio.cpp on CUDA (no runner has one).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Chat-only (no-torch) installs with an NVIDIA GPU run llama.cpp on the CPU. Reported in the Discord help thread: a 5070 Ti on Windows (driver 591.86) got ~20 tok/s where LM Studio gets ~140,
llama-server --list-devicesprinted(none), and the log showedn_threads = 2on the CPU.Why
The
app-*CUDA bundles Unsloth Studio installs since #5963 shipggml-cuda.dllbut nocudart/cublas. A full install doesn't need them: PyTorch already carries the CUDA runtime, and Unsloth Studio puts it on llama-server's search path, which saves ~400-550 MB per bundle. A chat-only install skips PyTorch, so there is nothing to borrow,ggml-cuda.dllfails to load, and llama.cpp quietly falls back to the CPU.On Windows torch ships these DLLs inside its own wheel (
torch\lib). On Linux torch pulls NVIDIA'snvidia-cuda-runtime/nvidia-cublaswheels intosite-packages/nvidia/, which are the same wheels this PR installs.Change
auto/cudarequest and no runtime the driver can use, the installer now installs the wheels for the newest line the driver runs first, then selects. Pre-Turing GPUs get CUDA 12, and a CUDA 13 runtime already on disk does not count for them.detected_linux_runtime_lines(), the same scan selection uses; Windows:cudart,cublasandcublasLtof that major, each found in the bundle,torch/lib, the env'snvidia/wheels,CUDA_PATHor the loader's own DLL dirs fromwindows_runtime_dirs(), checked flat), it installs NVIDIA's wheels:nvidia-cuda-runtime+nvidia-cublas, or the-cu12names with cublas pinned to 12.9.2.10 on Windows, the last one with awin_amd64wheel.--check-installedreports such an install as not ready, so setup and update reinstall it and fill the gap on machines that are already broken.llama_cpp.pyalready puts the env'snvidia/*wheel dirs onPATH/LD_LIBRARY_PATH, so it needs no change.Full installs and machines with the CUDA toolkit download nothing new. ARM64 bundles already ship the runtime and are untouched. This replaces unslothai/llama.cpp#362, which put the runtime in every bundle (+373 to +552 MiB each).
Tests
tests/studio/install/test_no_torch_cuda_runtime_wheels.py, 30 passed on macOS at907e50f558(code-level, the filesystem, loader and host are faked). Not run yet on a real Windows or Linux NVIDIA machine with a chat-only install.