| Property | Value |
|---|---|
| Severity | Warning |
| Category | Correctness |
| Default | Enabled |
| Auto-fix | Yes (suggestion) |
Description
DetectsRUN instructions where pip, uv, or conda installs reference a CUDA version
that does not match the base image’s CUDA toolkit version. A mismatch can cause:
- Silent fallback to CPU execution
- Runtime CUDA errors or build failures
- Subtle performance degradation
- pip/pip3 package suffixes —
torch==2.0.0+cu118 - pip/pip3/uv index URLs —
--index-url https://download.pytorch.org/whl/cu118 - uv
--torch-backend—--torch-backend cu118 - conda/mamba/micromamba —
pytorch-cuda=11.8orcudatoolkit=11.8
Why this matters
- Silent CPU fallback — PyTorch may load but silently use CPU instead of GPU when the CUDA wheel version doesn’t match the available CUDA runtime
- Runtime crashes — mismatched CUDA versions can produce cryptic
CUDA errormessages at runtime - Copy-paste bugs — the most common real-world pattern is upgrading the base
image CUDA version but forgetting to update the pip
--index-urlsuffix
Examples
Violation
No violation
Version compatibility
The rule uses NVIDIA’s forward compatibility guarantee:- Same major, wheel minor at or below base minor — OK (forward-compatible)
- Same major, wheel minor above base minor — Mismatch (wheel needs newer CUDA)
- Different major — Always a mismatch
CUDA suffix mapping
| Suffix | CUDA version |
|---|---|
cu118 | 11.8 |
cu121 | 12.1 |
cu124 | 12.4 |
cu126 | 12.6 |
cu128 | 12.8 |
Fix suggestions
The rule offers two fix alternatives:- Update the wheel/index to match the base image — preferred when the base image has a higher CUDA version (the common case: base was upgraded but pip URL was not)
- Update the base image to match the wheel — preferred when the wheel targets a newer CUDA version than the base
FixSuggestion safety — verify the target wheel or image tag exists
before applying.
Applicability
This rule fires when:- The base image is
nvidia/cuda:*(ordocker.io/nvidia/cuda:*) - The CUDA version can be parsed from the image tag
- A CUDA version reference is found in a
RUNinstruction - In multi-stage builds, stages that inherit from a CUDA-based parent stage
(
FROM builderwherebuilderusesnvidia/cuda:*) also trigger the rule. In this case, only the “update wheel/index” fix is offered — the “update base image” fix is skipped since theFROMline references a stage name, not an image tag.
- Non-NVIDIA base images
- Digest-only or ARG-based image tags (version cannot be determined)
- pip installs without CUDA suffixes or index URLs