RuntimeError: CUDA error: unknown error
ID: cuda/cuda-unknown-error
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 12 | active | — | — | — |
Root Cause
A catch-all CUDA error that occurs when the CUDA runtime encounters an unrecoverable state. Most commonly caused by a stale GPU context after a previous CUDA error, driver bugs, or a corrupted GPU state from suspend/resume cycles. Often requires driver-level remediation.
genericWorkarounds
-
82% success Reset the GPU state by killing all CUDA processes and reinitializing
# Kill all GPU processes sudo fuser -v /dev/nvidia* 2>/dev/null | xargs -r sudo kill -9 # Or reset the GPU directly sudo nvidia-smi --gpu-reset # Then restart your training script in a fresh process
Sources: https://docs.nvidia.com/deploy/driver-persistence/index.html
-
90% success Reboot the machine to fully reset GPU driver and hardware state
sudo reboot # After reboot, verify GPU state: nvidia-smi # Then re-run your workload
Sources: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/#post-installation-actions
-
80% success Update or reinstall the NVIDIA driver to a known-stable version
# Check current driver version nvidia-smi # Install latest stable driver sudo apt update && sudo apt install nvidia-driver-545 # Or use the NVIDIA official installer sudo ./NVIDIA-Linux-x86_64-545.29.06.run sudo reboot
Sources: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/#driver-installation
Dead Ends
Common approaches that don't work:
-
Retry the same operation in a loop assuming it is a transient error
95% fail
Once the CUDA context enters an error state, all subsequent CUDA operations in the same process will fail; retrying without resetting the context is futile
-
Set CUDA_LAUNCH_BLOCKING=1 hoping to get a more specific error
70% fail
Unlike device-side assert errors, 'unknown error' typically originates from driver or hardware level, not from a specific kernel launch; synchronous mode does not reveal additional information
-
Uninstall and reinstall PyTorch to fix the CUDA error
88% fail
The error is at the driver/hardware layer, not the framework layer; reinstalling PyTorch does not affect the NVIDIA driver or GPU state