PyTorch: CUDA error: no kernel image is available for execution on the device
RuntimeError: CUDA error: no kernel image is available for execution on the device
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Immediate Remediation
bash
pip install torch --index-url https://download.pytorch.org/whl/cu121
Root Cause Analysis
The installed PyTorch binary was compiled for a CUDA architecture that does not include the GPU's compute capability. This often happens when using an older PyTorch version with a newer GPU (e.g., RTX 40 series) or vice versa.
Verification & Guardrails
- Check your GPU compute capability with `nvidia-smi` or `torch.cuda.get_device_capability()`.
- If using a pre-built wheel, ensure the CUDA version matches your driver (e.g., cu118, cu121).
- For a temporary workaround, set `CUDA_VISIBLE_DEVICES=''` to force CPU usage, but this is not recommended for production.
Have a custom or uncategorized crash?
Run your trace through our in-memory client privacy sandbox for instant SRE remediation.