Repository navigation
Windows x64 and Linux CUDA bundles: ship cudart/cublas so installs without PyTorch run on the GPU - #362
Windows x64 and Linux CUDA bundles: ship cudart/cublas so installs without PyTorch run on the GPU#362LeoBorcherding wants to merge 2 commits into
Conversation
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
I ran your copy step and packager on the published b12246 binaries on two The size cost is larger than the ARM64 comparison in the description suggests:
The other four bundles grow by the same amount per CUDA line. One path I did not exercise: the CUDA 12.8 redist DLLs are unsigned (the 13.x ones are NVIDIA-signed), so the cuda12 legs will sign them with our certificate, including the 660 MiB Linux has the same gap, which this PR does not cover: its CUDA bundles ship no runtime either, so a |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Thanks for running it, converging Codex, and adding the Linux side. The size cost is the bigger problem, though (+373 to +552 MiB per bundle, now on Linux too), so I'd rather not ship the runtime in the bundles at all. Proposal: let the installer supply the runtime, and only for installs that lack it. When there's no torch and an NVIDIA GPU, Unsloth Studio would
What that gets us:
That change lives in unslothai/unsloth ( |
…ause the CUDA bundles ship no cudart/cublas (#17463) 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-devices` printed `(none)`, and the log showed `n_threads = 2` on the CPU. ## Why The `app-*` CUDA bundles Unsloth Studio installs since #5963 ship `ggml-cuda.dll` but no `cudart`/`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.dll` fails to load, and llama.cpp quietly falls back to the CPU. ``` .unsloth/ ├ llama.cpp/…/Release/ same in every case: ggml-cuda.dll, no cudart └ studio/unsloth_studio/…/site-packages/ ├ torch/lib/ full install: cudart64_12.dll, cublas64_12.dll → GPU ├ (nothing) chat-only today → CPU └ nvidia/cu13/bin/ chat-only with this PR: cudart64_13.dll, … → GPU ``` On Windows torch ships these DLLs inside its own wheel (`torch\lib`). On Linux torch pulls NVIDIA's `nvidia-cuda-runtime` / `nvidia-cublas` wheels into `site-packages/nvidia/`, which are the same wheels this PR installs. ## Change - **Linux, before bundle selection.** Selection only takes a CUDA bundle whose runtime line is already on disk, so a driver-only host would skip CUDA and fall back to a source build. On an x64 NVIDIA host with an `auto`/`cuda` request 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. - **After install, both OSes.** The install kind and CUDA major come from the asset name, since the install marker records no install kind. If the runtime is missing (Linux: `detected_linux_runtime_lines()`, the same scan selection uses; Windows: `cudart`, `cublas` and `cublasLt` of that major, each found in the bundle, `torch/lib`, the env's `nvidia/` wheels, `CUDA_PATH` or the loader's own DLL dirs from `windows_runtime_dirs()`, checked flat), it installs NVIDIA's wheels: `nvidia-cuda-runtime` + `nvidia-cublas`, or the `-cu12` names with cublas pinned to 12.9.2.10 on Windows, the last one with a `win_amd64` wheel. - **Repair.** `--check-installed` reports such an install as not ready, so setup and update reinstall it and fill the gap on machines that are already broken. - `llama_cpp.py` already puts the env's `nvidia/*` wheel dirs on `PATH` / `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 at `907e50f558` (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. --------- Co-authored-by: oobabooga <[email protected]>
Unsloth Studio installs without PyTorch (chat-only) on a machine with an NVIDIA GPU run llama-server on the CPU. The CUDA app bundles ship the CUDA backend (
ggml-cuda.dll,libggml-cuda.so) but not the CUDA runtime it links against (cudart, cublas, cublasLt). Studio has relied on PyTorch to supply it, and the NVIDIA driver does not include it.This PR ships the runtime in the Windows x64 and Linux CUDA bundles, and records that in the release manifest.
1. Windows x64
ggml-cuda.dllcannot load withoutcudart64_*/cublas64_*/cublasLt64_*, and llama.cpp falls back to the CPU with no error. The install still reports "installed and validated". This has been the case since Source llama.cpp prebuilts from unslothai/llama.cpp (CUDA, ROCm, macOS) unsloth#5963 moved Windows installs from upstream'sllama-*bundles plus the pairedcudart-llama-bin-win-cuda-*.zipto theseapp-*bundles: its selection code says the app bundles come "with bundled runtime libs", but only the ARM64 bundle has them (since Fix ROCm CPU performance, update the ROCm toolchain, and bundle Windows ARM64 CUDA libraries #233).unsloth-prebuilt-cuda-windows.ymlcopies the three DLLs from the job's toolkit intosrc/build/binbefore signing and setsBUNDLE_CUDA_RUNTIME=1on the packaging step, as the ARM64 leg does. The step fails if a pattern does not match exactly one DLL.*.dllfrom the bundle, and Windows loads DLLs from the executable's own directory first, so installs that have PyTorch use the bundled runtime too.windows-2022runners, with the published b12246 binaries, the real toolkit install step, and this copy step and packager unchanged: run. The published bundle failsLoadLibrary(ggml-cuda.dll)with WinError 126 and--list-devicesprints(none). The bundle from this PR loads it and reachesggml_cuda_init. The runners have no NVIDIA GPU or driver, so the cuda12 legs use a stand-in fornvcuda.dll.2. Linux x64 and arm64
libggml-cuda.soneedslibcudart.so.Nandlibcublas.so.N. Studio only installs a Linux CUDA bundle after finding those on disk. On a chat-only install with only the NVIDIA driver it logs "no published CUDA bundle covers this host" and falls back to a source build, which uses CUDA only whennvccis present. The result is the CPU.unsloth-prebuilt-cuda.ymlcopieslibcudart,libcublasandlibcublasLtfrom the job's toolkit intosrc/build/binunder their sonames. The packager's NEEDED walk picks them up from there. NVIDIA'slibcublascarriesRUNPATH $ORIGIN, solibcublasLtresolves from the bundle directory with noLD_LIBRARY_PATH.bundles_cuda_runtime: true(section 3). Until then this section changes the download size and nothing else.ubuntu:22.04container that has the NVIDIA driver and no CUDA libraries. Packaged as on master,llama-server --list-devicesprints(none). Packaged with this PR it printsCUDA0: NVIDIA GeForce RTX 3090. Same result for cuda12 and cuda13.ubuntu-22.04andubuntu-24.04-armrunners, with the real toolkit install step: run. The step finds all three libraries on both CUDA lines and on arm64, and the bundle'slibggml-cuda.sothen has no unresolved library besides the driver'slibcuda.so.1.3. The manifest says which bundles carry the runtime
package_bundle.pywritesbundles_cuda_runtimeintoUNSLOTH_PREBUILT_INFO.json(true when the bundle contains cuBLAS) andassemble_metadata.pycopies it into each CUDA entry ofllama-prebuilt-manifest.json. A bundle packaged before the field existed reads as false..get, so the extra key does not affect current installs.Size
Every CUDA bundle grows, for installs with PyTorch as well. Measured:
The other bundles grow by the same amount per platform and CUDA line. Over the 15 CUDA bundles a release grows by about 7 GiB.
Report
Reported in the Discord help thread: RTX 5070 Ti, Windows, chat-only Unsloth Desktop install, LFM2.5-24B-A2B UD-Q3_K_XL. 10 tok/s in Unsloth Studio against about 140 in LM Studio on the same model, with the GPU at 0% and the CPU at 75%.
Install log:
llama-server log at 50k context:
llama-server.exe --list-devices:build\bin\Releasehasggml-cuda.dll(257 MB), anddir cu*.dllfinds nothing.nvidia-smishows driver 591.86 / CUDA 13.1, which is new enough for both the cuda12 and cuda13 bundles. Reinstalling reproduces it, and so does pointing Studio at LM Studio's llama.cpp folder (LM Studio keeps its CUDA runtime elsewhere).Companion changes in unslothai/unsloth
bundles_cuda_runtime: true.windows-cudainstall whose manifest entry hasbundles_cuda_runtime: true. Keying on the field keeps installs of older releases healthy.Not tested
cublasLt64_12.dll. The ARM64 leg never did that.