nvidia-smi shows CUDA 12.2, but nvcc --version doesn't work, and PyTorch doesn't support 12.2
Problem
nvidia-smi shows CUDA 12.2, but PyTorch or nvcc shows a different version or doesn't run.
Cause
The CUDA version shown by nvidia-smi is the maximum CUDA version supported by the GPU driver.
That is different from the actual CUDA Toolkit (nvcc) version and the CUDA version your framework uses.
Solution
- Check the actual CUDA Toolkit version with:
nvcc --version
- If the command isn't recognized, set your PATH:
export PATH=/usr/local/cuda/bin:$PATH
nvcc --version
- Install a PyTorch / TensorFlow build that matches the CUDA Toolkit version you confirmed.
Additional Notes
-
PyTorch checks compatibility based on the CUDA Toolkit, not
nvidia-smi. -
Example:
nvidia-smi→ 12.2,nvcc→ 11.8 → use PyTorch cu118.