unsloth/docker
Daniel Han 9e3f3671d0 docker: give llama.cpp its libcublas so GGUF stops running on the CPU
The portable llama.cpp bundle loads libggml-cuda.so with dlopen, links it
against libcublas, and does not ship libcublas. The CUDA runtime base
image only carries libcudart, and the only libcublas in the image is
torch's wheel copy under site-packages/nvidia/cublas/lib, which was not
on the loader path. So the CUDA backend failed to load, and llama.cpp
said nothing about it: `--list-devices` printed an empty list and every
GGUF request ran on the CPU.

Measured in the built image on a B200 with gemma-4-E2B-it UD-Q4_K_XL:
1.6 tok/s from llama-cli and 4.2 tok/s from llama-server. With the fix,
the same image and model report `CUDA0: NVIDIA B200` and run at 229 tok/s
and 193 tok/s. Studio's GGUF chat and the GGUF export path go through the
same bundle, so both were affected.

The venv loader config already existed for torchcodec, so cublas/lib
joins it there rather than on LD_LIBRARY_PATH: ld.so.conf.d is consulted
after DT_RUNPATH, which keeps llama.cpp resolving its own $ORIGIN libs
first. cu13/lib comes along for the arm64 bundle's layout.

A silent 140x slowdown deserves a build-time gate, so the layer after the
fetch runs ldd over libggml-cuda.so, installs the cublas major the bundle
actually asks for when it is missing, and fails the build on anything
still unresolved. The amd64 bundle wants libcublas.so.12 and torch
already provides it; the arm64 bundle is CUDA 13, and deriving the major
from ldd keeps that leg honest without hardcoding either. libcuda.so.1 is
exempt: nvidia-container-toolkit injects the driver stub at
`docker run --gpus`, so it is never resolvable at build time. ldd needs
no GPU, so the build stays host-independent.

tests/python/test_docker_llama_cuda_backend.py pins the loader entry, the
guard, the driver-stub exemption and the ordering.
2026-07-26 14:59:27 +00:00
..
jupyter docker: tighten comments 2026-07-19 15:32:20 +00:00
.dockerignore docker: Colab-grade JupyterLab and Studio UX for the Unsloth image (#6681) 2026-07-06 08:27:00 -07:00
build.sh docker: tighten comments 2026-07-19 15:32:20 +00:00
Dockerfile docker: give llama.cpp its libcublas so GGUF stops running on the CPU 2026-07-26 14:59:27 +00:00
Dockerfile.studio docker: tighten comments 2026-07-19 15:32:20 +00:00
entrypoint.sh docker: tighten comments 2026-07-19 15:32:20 +00:00
fetch_llama_prebuilt.py docker: tighten comments 2026-07-19 15:32:20 +00:00
NOTICE docker: Colab-grade JupyterLab and Studio UX for the Unsloth image (#6681) 2026-07-06 08:27:00 -07:00
run.sh docker: tighten comments 2026-07-19 15:32:20 +00:00
smoke_test.py docker: tighten comments 2026-07-19 15:32:20 +00:00
studio_launch.sh docker: tighten comments 2026-07-19 15:32:20 +00:00
supervisord.conf docker: tighten comments 2026-07-19 15:32:20 +00:00
unsloth_colab_compat.py docker: tighten comments 2026-07-19 15:32:20 +00:00
unsloth_ipython_startup.py docker: tighten comments 2026-07-19 15:32:20 +00:00
unsloth_jupyter_tunnel.sh docker: optional Cloudflare tunnel for JupyterLab (UNSLOTH_JUPYTER_CLOUDFLARE) 2026-06-24 09:55:11 +00:00
unsloth_llama_update.sh docker: tighten comments 2026-07-19 15:32:20 +00:00
unsloth_nb_compat.py docker: tighten comments 2026-07-19 15:32:20 +00:00
unsloth_nb_content_sig.py docker: tighten comments 2026-07-19 15:32:20 +00:00
unsloth_nb_pip_magic.py docker: tighten comments 2026-07-19 15:32:20 +00:00
unsloth_nb_strip_colab.py docker: tighten comments 2026-07-19 15:32:20 +00:00
unsloth_nb_view.py docker: tighten comments 2026-07-19 15:32:20 +00:00
unsloth_pip_shim.py docker: tighten comments 2026-07-19 15:32:20 +00:00
unsloth_run.py docker: tighten comments 2026-07-19 15:32:20 +00:00
unsloth_studio_update.sh docker: tighten comments 2026-07-19 15:32:20 +00:00
unsloth_sync_notebooks.sh docker: detach the notebook network refresh from container startup 2026-07-20 06:04:49 +00:00