Repository navigation
feat(docker): add CUDA container image for mlxcel and mlxcel-server - #3543
Conversation
Add docker/Dockerfile.cuda with a chiseled Ubuntu runtime target and a cudnn-devel debug target, both carrying /opt/mlxcel, user 65532, HOME=/cache, MLXCEL_CACHE_DIR=/cache/mlxcel under MLXCEL_CACHE_TRUSTED_ROOT=/cache, and the mlxcel-server entrypoint. Binaries come from the release zips (sha256-checked) or, with MLXCEL_SOURCE=local, from a build context. Every RUN runs on the build platform, so a linux/amd64 image builds on an arm64 host without emulation; docker/collect-runtime-libs.sh resolves libraries with readelf plus the measured dlopen set and fails the build on an unresolved soname or a binary that needs a newer glibc than the rootfs. The runtime target must not be published yet: NVRTC opens cuda_runtime.h, cooperative_groups.h and math_constants.h, which Attachment A of the CUDA EULA does not list. The GB10 smoke record, the x86_64 GLIBC_2.43 finding and the measured file lists are in docs/benchmark_results/docker-cuda-smoke-gb10-2026-11-29.md. Refs #3484
The /health 503 never appeared because mlxcel-server binds only after load and warmup, which the server log shows; say so instead of blaming the poll interval. Rename the timing column to what was measured (a full non-streaming chat response), note that the header trace ran in a cudnn-devel probe container, and mark the release runners' CUDA minor, the distroless cc-debian13 glibc and the Ubuntu 26.04 amd64 path as unverified. Refs #3484
Since #3540 the NVRTC JIT reads only the CUDA headers in scripts/ci/nvrtc_header_allowlist.txt, so the runtime target can carry them. The image now copies exactly that list into /usr/local/cuda/include (docker/copy-cuda-headers.sh, no second list) and the build fails if any other file is there; docker/copy-cuda-headers_test.sh covers the guard in CI. The CUDA and cuDNN libraries and headers now come from NVIDIA's CUDA apt repository, signature-checked against pinned key fingerprints and unpacked without installing, instead of being copied out of an nvidia/cuda image, whose container license allows a derived image only when it includes the whole container. Package versions are recorded in /opt/mlxcel/share/cuda-packages.txt. The debug target stays the whole cudnn-devel image. amd64 now defaults to Ubuntu 26.04 with CUDA 13.5, matching the x86_64 release runner (its binaries need GLIBC_2.43); arm64 stays on Ubuntu 24.04 with CUDA 13.0. NOTICE records the CUDA and cuDNN distribution basis and the bundled CCCL and CUTLASS headers; README and docs/installation.md describe the image and its readiness behavior. Refs #3484
Rewrite the GB10 record for a build of main at 15e6395 (includes #3508, #3509 and #3540). A cold-cache Qwen3-4B-4bit generation inside the runtime image under strace opened 11 CUDA toolkit headers, all in the allow-list, and succeeded; the server smoke (uid 65532, chat completion, CLI generate, docker stop drain, PTX cache reuse on a named volume, a root:root 0777 bind mount and a private-group 2775 bind mount) passed again. The record also states the license basis, the amd64 cross builds on Ubuntu 26.04 with CUDA 13.5, and what was not run. Refs #3484
Implementation Review SummaryIntent
Static review only; no image was built for this review. No CRITICAL or HIGH findings, so nothing was changed on the branch. Findings AddressedNone needed. Remaining Items
Verification
Checked and fine: keyring fingerprint pin (primary keys only, both repos), cross-arch apt setup in both |
Review follow-ups for the CUDA image. OpenBLAS, libgfortran5 and libquadmath0 are unpacked from Ubuntu debs, which dropped their Debian copyright files; the image now carries them under /opt/mlxcel/share/copyright (from the gcc base package where the library's doc directory is a symlink), the build fails if one is missing, and NOTICE names them. NOTICE no longer calls the debug target unmodified. Build steps now fail instead of continuing on a failed deb extraction, an empty CUDA include directory, or a --check of a missing directory, and DLOPEN_LIBS globs are no longer expanded against the current directory. .dockerignore also excludes .work/ and node_modules/. The docs state that the CUDA patch level pins only the debug base, list the remaining build arguments, and note that an in-container model download was not measured. Rebuilt on GB10: amd64 runtime from v0.9.0-beta.3 and arm64 runtime from v0.8.1 (both cache-only). Refs #3484
The image sets HOME=/cache, and the model resolver probes the HuggingFace cache at $HOME/.cache/huggingface/hub without owner or mode checks and before the /models store. On a world-writable /cache bind, which the guide gave as its example, another host uid can plant a snapshot that -m owner/name loads instead of the model in /models. MLXCEL_CACHE_TRUSTED_ROOT keeps the PTX cache safe on such a mount, but its threat model does not cover the HF cache. The guide now recommends a bind owned by 65532 (0700) or a private group with 2775, and says why a 0777 bind should be avoided on shared hosts. Named volumes are unaffected. Docs only; the resolver itself is unchanged. Refs #3484
Security and performance reviewStatic review only (no docker build). One HIGH finding, fixed in docs by 3e2b7e8; no CRITICAL findings. Addressed
Remaining (not fixed, below the fix threshold)
Checked and fineThe NVIDIA keyring check compares every primary key against fingerprints pinned in the Dockerfile, and apt trusts only the CUDA repo in that stage. The Ubuntu archive is reached through the signed |
The container example in docs/installation.md published the port on every interface while the server has no API key by default. It now uses -p 127.0.0.1:8080:8080 and says to set LLAMA_API_KEY or pass --api-key-file before exposing it elsewhere.
The image layout line listed only /opt/mlxcel/{bin,include}, and the smoke record listed /opt/mlxcel/share without the copyright directory that the Dockerfile fills with the OpenBLAS Debian copyright files. Both now match docker/Dockerfile.cuda.
Validation: shellcheck is clean on the three docker scripts, check_cross_repo_refs.py lists only lablup/mlxcel issue numbers, insert_apache_header.py --check, check_env_var_docs.py, check_nvrtc_headers.py and the benchmark and report layout checks pass, and every relative link in the changed docs resolves.
Refs #3484
The literal two-platform build from the issue (v0.8.1, linux/amd64 and linux/arm64) now builds for both the runtime and debug targets on GB10, cache-only, which also pulls the new amd64 debug base (13.5.0 on Ubuntu 26.04) for the first time. The record now says the GPU runs used the image from before the review follow-ups, so the copyright directory and hardened steps were only built, not run. NOTICE limits the NVIDIA-GPU-only clause to the CUDA EULA, the one agreement where it was read. Refs #3484
## Summary Adds `charts/mlxcel`, a Helm chart for `mlxcel-server` on a GPU node, plus a `helm-chart` CI job. One replica, `Recreate`, Service, optional Ingress, PDB and ServiceMonitor, PVCs for `/models` and (optionally) `/cache`. Three model modes: `hf` (a `download` initContainer, the default), `pvc` (snapshot already under `/models`) and router (`--models-dir`, `--models-max`); other combinations fail rendering with a message naming the value. ## Decisions beyond the issue text - Default `model.source: hf`, so a default install works on an empty volume. The server always runs with `--offline` in model mode: only the initContainer fetches, `HF_TOKEN` never reaches the server, and `--revision` goes to the download only (a revision-qualified `-m` skips the `/models` store in the resolver). - `HF_HOME`/`HF_HUB_CACHE` point into `/models/.huggingface`, closing the #3543 finding that `HOME=/cache` makes the resolver read `/cache/.cache/huggingface/hub` before `/models` without an owner check. - `MLXCEL_CACHE_DIR=/cache/mlxcel` under the trusted root `/cache`, `fsGroup: 65532`, `fsGroupChangePolicy: OnRootMismatch`. No root container and no values switch for one; the container security context is fixed. - The download initContainer inherits the server's `resources` (GPU limit) because the binary links the NVIDIA driver library; kubelet reuses init-container devices for the server. - `enableServiceLinks: false` (a release named `mlxcel` would inject `MLXCEL_*` variables), `automountServiceAccountToken: false`, and `extraEnv` may not repeat a chart-set name (server-side apply rejects duplicates). - Router mode with `model.hfToken` requires `apiKey.existingSecret` (the router's `POST /models` and `DELETE /models` are open without a key); `podSecurityContext` rejects uid, gid or `fsGroup` 0 even with schema validation skipped. - Files outside `charts/**`: a one-line pointer in `docs/installation.md`, `scripts/ci/check_helm_chart.py` (template matrix, kubeconform, invariants, rejection cases), `scripts/ci/check_helm_chart_kind.sh` (restricted Pod Security admission with a negative control), and the record `docs/benchmark_results/helm-chart-kind-2026-11-29.md`. ## kind findings (kind v0.33.0, Kubernetes v1.37.0) - emptyDir root `2777 0:65532`; kind `local-path` PVC root `777 0:0` (a hostPath PV, kubelet applies no `fsGroup`); hand-made `local` PV root `2775 0:65532`. - On the `local` PV, `Always` relabeled the server-style entries on remount to `2770` dirs and `660` files; `OnRootMismatch` kept `2700`/`600`. The cache rules refuse group-writable directories and entries below the trusted root, so `Always` would disable the cache from the second pod on (from the source, not observed with the server). ## Changes during review - The `helm-chart` job installs PyYAML with `uv pip`: the chart-testing action puts a pip-less venv first on PATH, which failed the first CI run. - The router API-key requirement and the root-group rejection above came from the security review. The cache guidance in `values.yaml` and the README now warns against same-uid workloads on the cache volume (they pass the owner checks), not other uids (which can only turn the cache off). ## Test plan - [x] `helm lint --strict` (default and every `ci/*-values.yaml`) and `ct lint` (chart-testing v3.15.0) pass - [x] `scripts/ci/check_helm_chart.py` passes under Helm 4.3.2 and Helm 3.16.4, kubeconform v0.8.0 strict with the ServiceMonitor CRD schema - [x] `scripts/ci/check_helm_chart_kind.sh` on kind: default (hf), hf, pvc and router releases admitted under `enforce=restricted`, control pod rejected - [x] actionlint 1.7.12 with CI's shellcheck floor - [x] `helm chart` CI job passes (lint, ct lint, kubeconform, kind install under restricted Pod Security) - [ ] Not validated: any GPU pod (Ready on Qwen3-4B, no cache refusal line, PTX reuse after restart and pod replacement, cold/warm time to Ready), device reuse from initContainer to server, an in-cluster download. No Kubernetes cluster with a GPU was available. Closes #3486
Bilingual reports for the eight PRs of epic #3488: #3508 (graceful drain), #3509 (CUDA PTX cache trust), #3530 (ROCm hsaco cache trust), #3540 (NVRTC redistributable headers), #3543 (CUDA container image), #3549 (Helm chart), #3550 (GHCR image publishing) and #3554 (chart OCI publishing and docs). Each report names what the PR record leaves unvalidated: a real GHCR push, a GPU pod on a cluster, the amd64 and debug images. The HuggingFace cache follow-up is #3570.
Summary
Adds
docker/Dockerfile.cuda: a shell-less chiseled Ubunturuntimeimage and adebugimage (the wholenvidia/cudacudnn-develimage plus mlxcel) forlinux/amd64andlinux/arm64, running as uid 65532 with/modelsand/cachevolumes. The previous attempt stopped at the CUDA header license gate; #3540 removed the non-redistributable includes, so the runtime image now ships.What changed
scripts/ci/nvrtc_header_allowlist.txtinto/usr/local/cuda/include(docker/copy-cuda-headers.sh, no second list). The build fails if a listed header is missing or any other file is there.docker/copy-cuda-headers_test.shcovers the guard and runs in CI.nvidia/cudaimage, because the NGC container license allows a derived image only when it includes the whole container (1.c, 4.c). Package versions go to/opt/mlxcel/share/cuda-packages.txt.readelfclosure plus a measured dlopen set, with a glibc/libstdc++ version guard.GLIBC_2.43. arm64 stays on Ubuntu 24.04 with CUDA 13.0.NOTICErecords the CUDA EULA and cuDNN distribution basis and adds the bundled CCCL (Apache-2.0 with LLVM exceptions) and CUTLASS/CuTe (BSD-3-Clause) headers.README.mdanddocs/installation.mddescribe the image./healthwording is corrected, not the server: with-mthe listener binds only after load and warmup, so probes are refused until the server returns 200. The image has noHEALTHCHECK.HOME=/cachemeans-m owner/namereads/cache/.cache/huggingface/hubbefore/modelswithout an owner check, so a/cacheother host uids can write lets them substitute a model. The docs now recommend a 65532-owned or private-group bind; a resolver fix is left for a follow-up.Test plan
GB10, local build of
mainat15e63955(#3508, #3509, #3540), arm64 runtime image, all GPU runs undergpu-lock.mlxcel generateunder strace inside the runtime image: exit 0, 0 to 12 PTX files. It opened 11 toolkit headers, all allow-listed, and no header outside the toolkit and bundled include roots.root:root 0777bind with the trusted root, and65532:65532 2775bind with the trusted root unset. In every case the chat completion returned text,docker stoptook under 1 s with exit 0, and the second start compiled nothing and left the cache identical. CLIgenerateworked and--entrypoint shfailed.--platform linux/amd64,linux/arm64build from v0.8.1, cache-only, forruntimeanddebug; amd64 runtime also from v0.9.0-beta.3 (glibc 2.43 rootfs).3ab35c1f(copyright files, build-step hardening); that version was only rebuilt, not run.docker/copy-cuda-headers_test.sh(5 cases, including a plantedmath_constants.hand a symlink).docs/benchmark_results/docker-cuda-smoke-gb10-2026-11-29.md.Owner review requested: the license basis in
NOTICE(CUDA EULA Attachment A and 1.1.2, cuDNN supplement, NGC container license 1.c/4.c/7) is my reading of those documents, not legal advice.Closes #3484