Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Install the cublas wheel NVIDIA actually publishes for the bundle's CUDA major (#10324)

Daniel Han7197da2191a8
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 7af952b7e61..f35527ae350 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -524,15 +524,28 @@ RUN /opt/unsloth-venv/bin/python /tmp/fetch_llama_prebuilt.py \
# can never ship again. libcuda.so.1 is exempt: that is the driver stub, injected
# by nvidia-container-toolkit at `docker run --gpus`, never present in the image.
# ldd needs no GPU, so this keeps the build host-independent.
+#
+# The name is not `nvidia-cublas-cu${major}` at every major: NVIDIA dropped the
+# suffix at CUDA 13, where `nvidia-cublas-cu13` is only a 0.0.1 sdist whose build
+# backend exits 1 with "use nvidia-cublas instead", failing the BUILD, not the
+# install. Neither project spans both majors: the unsuffixed one publishes 13.x
+# only, and nvidia-cublas-cu12 has no unsuffixed twin. Pin the major so a future
+# CUDA 14 cannot install over a 13 bundle; the unresolved-library check below is
+# what proves the right wheel landed.
RUN set -eux \
&& CUDA_SO=/opt/unsloth/llama.cpp/libggml-cuda.so \
&& if [ -f "$CUDA_SO" ]; then \
want="$(ldd "$CUDA_SO" | sed -n 's/^[[:space:]]*\(libcublas\.so\.[0-9]*\)[[:space:]]*=> not found$/\1/p' | head -n1)"; \
if [ -n "$want" ]; then \
major="${want##*.}"; \
- echo ">> $want missing, installing nvidia-cublas-cu${major}"; \
+ if [ "$major" -ge 13 ]; then \
+ pkg="nvidia-cublas==${major}.*"; \
+ else \
+ pkg="nvidia-cublas-cu${major}"; \
+ fi; \
+ echo ">> $want missing, installing ${pkg}"; \
/opt/unsloth-venv/bin/uv pip install --python /opt/unsloth-venv/bin/python \
- "nvidia-cublas-cu${major}"; \
+ "${pkg}"; \
ldconfig; \
fi; \
missing="$(ldd "$CUDA_SO" | grep 'not found' | grep -v 'libcuda\.so\.1 ' || true)"; \
diff --git a/tests/python/test_docker_llama_cuda_backend.py b/tests/python/test_docker_llama_cuda_backend.py
index 045f9b8ea79..58e4a9cf6e7 100644
--- a/tests/python/test_docker_llama_cuda_backend.py
+++ b/tests/python/test_docker_llama_cuda_backend.py
@@ -12,6 +12,8 @@ on the CPU. These pin the two Dockerfile halves that prevent it.
from __future__ import annotations
import re
+import shlex
+import subprocess
from pathlib import Path
import pytest
@@ -38,6 +40,12 @@ def test_cublas_dir_is_registered_with_the_loader(dockerfile: str):
"wheel copy; without this entry the CUDA backend fails to dlopen and GGUF "
"silently runs on the CPU"
)
+ # Both layouts, because the wheel moved with the name: nvidia-cublas-cu12
+ # unpacks to nvidia/cublas/lib, nvidia-cublas (13+) to nvidia/cu13/lib
+ assert "$SP/nvidia/cu13/lib" in block, (
+ "the CUDA 13 cublas wheel unpacks to nvidia/cu13/lib, so dropping this entry "
+ "puts libcublas.so.13 off the loader path even after the guard installs it"
+ )
def test_loader_config_is_not_ld_library_path(dockerfile: str):
@@ -61,13 +69,52 @@ def test_build_fails_on_an_unresolved_cuda_backend(dockerfile: str):
), "libcuda.so.1 must be exempt from the guard or every build fails"
-def test_guard_installs_the_matching_cublas_major(dockerfile: str):
- # the two arch bundles differ in CUDA major, so it must come from ldd
+def _cublas_pkg_for(dockerfile: str, soname: str) -> str:
+ """The wheel the guard installs for a bundle asking for ``soname``.
+
+ Runs the Dockerfile's own selection lines instead of matching them. A name
+ is only correct if it resolves on PyPI, which no string comparison can tell
+ you, so pinning one spelling is how this went wrong the first time.
+ """
guard = dockerfile[dockerfile.index("CUDA_SO=") :]
- assert (
- "nvidia-cublas-cu${major}" in guard
- ), "the guard must install the cublas major the bundle actually asks for"
- assert "libcublas" in guard
+ start = guard.index('major="${want##*.}"')
+ snippet = guard[start : guard.index('echo ">> $want missing', start)]
+ lines = snippet.replace("\\\n", "\n")
+ script = "\n".join([f"want={shlex.quote(soname)}", lines, 'printf %s "$pkg"'])
+ return subprocess.run(
+ ["sh", "-eu", "-c", script], capture_output = True, text = True, check = True
+ ).stdout
+
+
+ "soname, expected",
+ [
+ ("libcublas.so.12", "nvidia-cublas-cu12"),
+ ("libcublas.so.13", "nvidia-cublas==13.*"),
+ ("libcublas.so.14", "nvidia-cublas==14.*"),
+ ],
+)
+def test_guard_installs_the_matching_cublas_major(dockerfile: str, soname: str, expected: str):
+ # NVIDIA dropped the -cuXX suffix at CUDA 13; neither project spans both majors:
+ # nvidia-cublas publishes 13.x only, nvidia-cublas-cu12 has no unsuffixed twin
+ assert _cublas_pkg_for(dockerfile, soname) == expected
+
+
+def test_the_cublas_major_comes_from_the_bundle(dockerfile: str):
+ # The two arch bundles differ in CUDA major, so the name must follow ldd; a
+ # hardcoded major would satisfy any single case above on its own
+ assert _cublas_pkg_for(dockerfile, "libcublas.so.12") != _cublas_pkg_for(
+ dockerfile, "libcublas.so.13"
+ )
+
+
+def test_the_guard_never_asks_for_a_retired_suffixed_wheel(dockerfile: str):
+ # The regression: the arm64 bundle links libcublas.so.13, the guard derived
+ # nvidia-cublas-cu13, a 0.0.1 sdist whose build backend exits 1 saying to use
+ # nvidia-cublas. That fails the build, not the install, so the fail-soft paths
+ # elsewhere in this file could not catch it.
+ for major in range(13, 20):
+ assert f"-cu{major}" not in _cublas_pkg_for(dockerfile, f"libcublas.so.{major}")
def test_guard_runs_after_the_prebuilt_is_fetched(dockerfile: str):