InternImage icon indicating copy to clipboard operation
InternImage copied to clipboard

RuntimeError: The detected CUDA version (12.1) mismatches the version that was used to compile PyTorch (11.7). Please make sure to use the same CUDA versions.

Open JunKaiLiao opened this issue 2 years ago • 2 comments

Did anyone meet this problem? Please help ! !

JunKaiLiao avatar Jun 17 '23 08:06 JunKaiLiao

Hi, I've met this problem before, so I'm here to help. But before we get started, there are some pre-checklists to finish:

  1. Run "nvcc -V" in a terminal to see the CUDA version installed on your computer or server;
  2. Run python3 -c "import torch; print(torch.version)" in a terminal or VScode to check the PyTorch version and its compatible CUDA version. For example, in my server, it will return with "2.0.1+cu118" meaning PyTorch 2.0.1 and CUDATOOLKIT 11.8 are installed.

After running the pre-checklists above, a normal outcome should be match; while in your case, a mismatch is expected. However, you might refer to https://stackoverflow.com/questions/76285777/cuda-and-pytorch-versions-mismatch-in-conda to see if it works; if it doesn't work, consider uninstalling the CUDA version you are using and installing a lower version (11.7) to match your PyTorch requirement manually.

KevinXu-01 avatar Jun 20 '23 07:06 KevinXu-01

Uninstall the previous version of the Pytorch pip uninstall torch torchvision torchaudio -y and reinstall to match the 12.1 version pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 make sure your env is accepting the code python -c "import torch; print(torch.version)" as PyTorch version: 2.5.1+cu121

9Mercury avatar May 26 '25 16:05 9Mercury