fix(docker): install cuDNN 8 compat libraries in the CUDA Docker image - #2072
Conversation
The CUDA base image is pytorch/pytorch:2.8.0-cuda12.8-cudnn9-runtime, so it ships cuDNN 9. CTranslate2 — WhisperX and faster-whisper — links cuDNN 8, and its absence aborts the backend process outright rather than raising (debpalash#1371). scripts/setup.py side-loads the cuDNN 8 libraries for source installs, but the Dockerfile never did, so every CTranslate2 ASR engine was unavailable in Docker and the demo synthesis timed out with libcudnn_ops_infer.so.8 missing. Install the same nvidia-cudnn-cu12==8.9.7.29 shim during the image build, deriving the target from sys.prefix so it matches where backend/core/cudnn8.py searches rather than hardcoding the conda path — sys.prefix differs between the conda-based CUDA image and the ROCm venv. Guarded to GPU_FLAVOR=cuda, since ROCm does not use cuDNN, and --no-deps keeps the base image's torch stack untouched. A post-install assert fails the build if no .so.8 libraries landed, rather than letting it resurface as the same runtime warning. Fixes debpalash#2050
|
No actionable merge-blocking issue was identified. SummaryInstalls isolated cuDNN 8 compatibility libraries in CUDA containers, with a build-time presence check.
Reviews (2) · Last reviewed commit: "fix: integrate current main and finish r..." |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe Docker runtime stage installs pinned cuDNN 8 compatibility libraries for CUDA images. It derives the target site-packages path and verifies the installed ChangesCUDA cuDNN compatibility
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to CUDA images gain the required cuDNN 8 compatibility libraries while ROCm images remain unaffected. No actionable merge risk is identified from the supplied evidence. 🚥 Pre-merge checks | ✅ 7 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (7 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (2 skipped: 2 unsupported.) Full details: Local-First GuaranteeExplanation The CUDA image build adds a required outbound PyPI dependency fetch at
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks — title updated to On the local-first warning, I think it is being applied to the wrong layer, but I would rather lay out the reasoning than quietly dismiss it. The gate in CONTRIBUTING reads:
That sits among runtime properties — logging, persisted secrets, home paths — so I read it as constraining what the running application does on a user's machine, not what the image build fetches. This change adds nothing at runtime; it only puts files into the image. At build time the Dockerfile already reaches the network in four places:
My line 119 is the same mechanism as 64 and 90, pinned to the exact version Vendoring the wheel as the bot suggests would mean carrying ~700 MB of platform-specific CUDA binaries in-tree, which seems a worse trade than one pinned install alongside the four that already run. Happy to be overruled — if you would prefer it vendored, sourced from a prebuilt artifact, or made opt-in behind a build arg, say which and I will rework it. |
Fixes #2050
The CUDA base image is
pytorch/pytorch:2.8.0-cuda12.8-cudnn9-runtime, so it ships cuDNN 9. CTranslate2 — WhisperX and faster-whisper — links cuDNN 8, and per the note inbackend/core/cudnn8.pyits absence aborts the backend process outright rather than raising (#1371).scripts/setup.pyside-loads the cuDNN 8 libraries for source installs, but the Dockerfile never did. Docker users therefore lose every CTranslate2 ASR engine, which surfaces as the demo synthesis timing out and:Change
Install the same
nvidia-cudnn-cu12==8.9.7.29shim during the image build.Two details worth flagging:
The target is derived from
sys.prefix, not hardcoded.backend/core/cudnn8.py::compat_dirs()searches<sys.prefix>/lib/pythonX.Y/site-packages/cudnn8_compat/nvidia/cudnn/lib, andsys.prefixdiffers between the conda-based CUDA image and the ROCm venv. Deriving it keeps the install and the lookup in agreement if the base image's Python version or layout moves. I verified the computed target is exactly the parent of the directorycompat_dirs()looks in.A post-install assert fails the build if no
.so.8libraries landed. Without it, a silently empty install would reappear as this same runtime warning, which is what made the original report hard to place.Guarded to
GPU_FLAVOR=cuda— ROCm does not use cuDNN — and--no-depskeeps the install to the cuDNN wheels alone, leaving the base image's torch stack untouched, consistent with the existing torch-clobber guard directly above.Quality gates
uv pip installsteps in this Dockerfile. No new runtime outbound calls.Testing
docker build --check -f deploy/Dockerfile .passes — the only warning isInvalidBaseImagePlatform, because I am on arm64 and the base image is amd64.What I could not run: I could not build the image or run
uv run pytest backend/ -x -qon this machine — it is an arm64 Raspberry Pi, and the CUDA base image is amd64-only. So the install step itself is unexercised here and I would rely on CI for it. What I did verify directly is the path logic, since that is the part most likely to be wrong:The pinned version matches the one
scripts/setup.pyalready installs, so it is not a new dependency choice.The reporter in #2050 confirmed a hardcoded variant of this fix works in a derived image; this PR generalises it and adds the verification step.
The CUDA Docker image now installs and verifies
nvidia-cudnn-cu12==8.9.7.29in thecudnn8_compatpath required by CTranslate2-based WhisperX and faster-whisper engines, with documentation and regression coverage added. The install runs only forGPU_FLAVOR=cudaand uses--no-deps. Full image builds and backend tests were not run because the available machine is arm64 while the CUDA image is amd64.