Skip to content

fix(docker): make the CUDA image build and run on any recent NVIDIA GPU - #1052

Open
Creylay wants to merge 5 commits into
developfrom
fix/1028-cuda-dockerfile
Open

Creylay wants to merge 5 commits into
developfrom
fix/1028-cuda-dockerfile

Conversation

@Creylay

@Creylay Creylay commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Dockerfile.cuda has produced an unusable image since the migration to uv (effdacc6d). The four defects are chained, each one masking the next, and no CI workflow builds the Dockerfiles, so none of them surfaced. One commit per issue:

Also found while testing the image: on a fresh database the Huey consumer pre-warmed its worker and cleared the loaded_model table before the app's migrations had created it, logging no such table: loaded_model on every first start. The cleanup now runs only when replacing a dead worker; the app already clears the table right after migrating. Reproduced on develop with a fresh --local-path and gone with the fix.

Verification

Built and run on an RTX 3070 (sm_86), driver 620.73.04:

Check Result
Build OK, 31 min
#1028 interpreter /opt/venv/bin/python3, Python 3.12.13
#1042 libgomp all 6 llama_cpp/lib libraries resolve libgomp.so.1
#1043 imports import llama_cpp; import torch OK, cuda.is_available() True
#1044 architectures libggml-cuda.so ELF sm_75/80/86/89, PTX sm_89
GGUF on GPU SmolLM2-360M-Instruct Q8_0, 33/33 layers offloaded, 387.6 tok/s
App on :8000 /app/ and /api/v1/dataset/ return 200

The ncclCommShrink error from #1043 did not reproduce on this GPU/driver even without the fix, so this run shows the fix is harmless here, not that it is required. The issue reporter verified it on an L4.

Locally: tests/back/models passes, except the two BART tests, which fail the same way on develop (pytensor/clang compile error on macOS).

Closes #1028
Closes #1042
Closes #1043
Closes #1044

The runtime stage copied only /opt/venv, whose python symlinks point at the
interpreter uv downloaded under /root/.local/share/uv/python. They were left
dangling, so python3 fell back to the system 3.10 without the venv packages.

Pin Python 3.12 (the CI default), install it under /opt/python and copy it
next to the venv. The apt python3 package is no longer needed.

Closes #1028
Every llama-cpp-python shared library links against the OpenMP runtime. The
builder gets it through build-essential, the runtime base image does not, so
import llama_cpp failed with 'libgomp.so.1: cannot open shared object file'.

Closes #1042
Without CMAKE_CUDA_ARCHITECTURES llama.cpp compiles only for the build
host's GPU, so the image did not run on any other card. Target T4, A100,
A10/RTX 30xx and L4/RTX 40xx, plus PTX for sm_89 so newer cards can JIT.

Closes #1044
When llama_cpp is imported first, torch skips its NCCL preload and import
torch fails with 'undefined symbol: ncclCommShrink'. llama_utils imported
llama_cpp at module level, so the GGUF models always hit the bad order.

Import llama_cpp lazily in llama_utils, add a test that checks the order in
a fresh interpreter, and preload libnccl in the CUDA image so it stays
correct regardless of future import changes.

Closes #1043
The Huey consumer starts alongside the app and pre-warms its worker,
which cleared the loaded_model table. On a fresh database this ran
before the app's migrations created it, logging
"no such table: loaded_model". The app already clears the table right
after migrating, so only clear it when replacing a dead worker.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant