CUDA version is always 10.2

After installing a handful of versions of pytorch with CUDA (11.7 nightly, 11.6 nightly, 11.3), I can’t get torch.version.cuda to be anything but 10.2

[me@legion imagen-test]$ sudo pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu113
Collecting torch
  Downloading https://download.pytorch.org/whl/cu113/torch-1.11.0%2Bcu113-cp310-cp310-linux_x86_64.whl (1637.0 MB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1637.0 MB 28 kB/s              
Collecting torchvision
  Downloading https://download.pytorch.org/whl/cu113/torchvision-0.12.0%2Bcu113-cp310-cp310-linux_x86_64.whl (22.3 MB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 22.3 MB 12.2 MB/s            
Collecting torchaudio
  Downloading https://download.pytorch.org/whl/cu113/torchaudio-0.11.0%2Bcu113-cp310-cp310-linux_x86_64.whl (2.9 MB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2.9 MB 455 kB/s            
Requirement already satisfied: typing-extensions in /usr/lib/python3.10/site-packages (from torch) (4.2.0)
Requirement already satisfied: numpy in /usr/lib/python3.10/site-packages (from torchvision) (1.22.4)
Requirement already satisfied: requests in /usr/lib/python3.10/site-packages (from torchvision) (2.27.1)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in /usr/lib/python3.10/site-packages (from torchvision) (9.1.0)
Requirement already satisfied: chardet>=3.0.2 in /usr/lib/python3.10/site-packages (from requests->torchvision) (4.0.0)
Requirement already satisfied: idna>=2.5 in /usr/lib/python3.10/site-packages (from requests->torchvision) (3.3)
Requirement already satisfied: urllib3>=1.21.1 in /usr/lib/python3.10/site-packages (from requests->torchvision) (1.26.9)
Installing collected packages: torch, torchvision, torchaudio
Successfully installed torch-1.11.0+cu113 torchaudio-0.11.0+cu113 torchvision-0.12.0+cu113
[me@legion imagen-test]$ python
Python 3.10.4 (main, Mar 23 2022, 23:05:40) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.version.cuda)
10.2

Most likely you have multiple PyTorch installations in your current environment and import torch selects the β€œdefault” one shipping with the CUDA 10.2 runtime.
Uninstall all PyTorch installations via rerunning pip uninstall torch -y and conda uninstall pytorch -y until no installations can be found. Then install the new wheel.

1 Like

I don’t have any conda installation, but after uninstalling torch with pip, verifying uninstallation, and reinstalling, I still get CUDA 10.2.

[me@legion imagen-test]$ sudo pip uninstall torch -y
Found existing installation: torch 1.11.0
Uninstalling torch-1.11.0:
  Successfully uninstalled torch-1.11.0
[me@legion imagen-test]$ pip uninstall torch -y
WARNING: Skipping torch as it is not installed.
[me@legion imagen-test]$ python
...
>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'
>>> exit()
[me@legion imagen-test]$ pip3 install torch --extra-index-url https://download.pytorch.org/whl/cu117
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu117
Collecting torch
  Downloading torch-1.11.0-cp310-cp310-manylinux1_x86_64.whl (750.6 MB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 750.6 MB 9.2 kB/s             
Requirement already satisfied: typing-extensions in /usr/lib/python3.10/site-packages (from torch) (4.2.0)
Installing collected packages: torch
Successfully installed torch-1.11.0
[me@legion imagen-test]$ python
Python 3.10.4 (main, Mar 23 2022, 23:05:40) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.version.cuda)
10.2

You are installing the default CUDA 10.2 wheel, as --extra-index-url https://download.pytorch.org/whl/cu117 is not a thing yet (check the URL and it will show an error) so pip install pulls the default wheel. Use the provided install commands from the website or verify the existence of internal wheels manually.