当前位置:网站首页>Correspondence between rtx3090 and pytorch versions

Correspondence between rtx3090 and pytorch versions

2022-06-21 22:22:00 mingqian_ chu

stay RTX 3090 Judge , The current version of torch Whether the version can be used , Generally, the following methods are required :

  1. conda activate torch1.8.1 ( Activate the relevant virtual environment )
  2. python Get into python Environmental Science , import torch Import torch Installation package ;
  3. test  torch.cuda.is_available(),
  4. test torch.zero(1).cuda()

until , Step 4 complete , To describe the current version of cuda  You can call the current version of pytorch;

Key points of the problem :

  1. install pytorch In the process ,  There are two points to note ,  One is currently installed pytorch edition ,  The pytroch The official version website specifies which versions are included cuda edition ;
  2. Use pip install torch==1.8.1 Mode of installation , The default is torch edition +  On the current host cuda edition
  3. Possible problems ,  Current host cuda edition   Incompatible with this torch Several official releases in the version cuda  edition ;

1. Problem phenomenon

>>> torch.zeros(1).cuda()
/home/respecting/anaconda3/envs/torch1.8.1/lib/python3.7/site-packages/torch/cuda/__init__.py:104: UserWarning: 
NVIDIA GeForce RTX 3090 with CUDA capability sm_86 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70.
If you want to use the NVIDIA GeForce RTX 3090 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/

1.1 Problem analysis

Indicates the currently installed pytorch The version does not match the appropriate cuda,   At present pytorch Version of cuda The version does not correspond to its own host , Installed cuda  edition ,

pytorch Installed in cuda edition ,  There are two conditions that need to be met :

  1. At present pytorch Version of computing power support   The computing power of the graphics card on the current machine ;
  2. pytorch   Medium cuda edition   It cannot be higher than the one already installed on the current machine cuda  edition ;

Specifically ,  The same pytorch edition , such as pytorch 1.8.1 Will correspond to different versions of cuda

# ROCM 4.0.1 (Linux only)
pip install torch==1.8.1+rocm4.0.1 torchvision==0.9.1+rocm4.0.1 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

# ROCM 3.10 (Linux only)
pip install torch==1.8.1+rocm3.10 torchvision==0.9.1+rocm3.10 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

# CUDA 11.1
pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

# CUDA 10.2
pip install torch==1.8.1+cu102 torchvision==0.9.1+cu102 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

# CUDA 10.1
pip install torch==1.8.1+cu101 torchvision==0.9.1+cu101 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

# CPU only
pip install torch==1.8.1+cpu torchvision==0.9.1+cpu torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

1.2  solve the problem

pytorch Installed in cuda edition ,  There are two conditions that need to be met :

  1. At present pytorch Version of computing power support   The computing power of the graphics card on the current machine ;
  2. pytorch Medium cuda The version cannot be higher than the one already installed on the current machine cuda  edition ;

Knowing the cause of the problem ,  We can solve the problem :

  1. RTX3090 Need at least cuda 11.1 edition , To drive the device , So we can install cuda11.1 Above version
  2. So when you want to install pytorch In the version , Find greater than   cuda11.1 <= pytorch-cuda --version <=   Installed on the current machine cuda --version

Because the author installed on the machine is cuda11.2 ,  and 3090 Corresponding cuda Version must be greater than or equal to cuda11.1,
Therefore, installation pytorch 1.8.1 Medium  cuda11.1 edition ,   Uninstall and reinstall the corresponding version ;

 pip install -i https://pypi.douban.com/simple torch-1.8.1+cu111-cp37-cp37m-linux_x86_64.whl 
Looking in indexes: https://pypi.douban.com/simple
Processing ./torch-1.8.1+cu111-cp37-cp37m-linux_x86_64.whl
Requirement already satisfied: numpy in /home/respecting/anaconda3/envs/torch1.8.1/lib/python3.7/site-packages (from torch==1.8.1+cu111) (1.21.6)
Requirement already satisfied: typing-extensions in /home/respecting/anaconda3/envs/torch1.8.1/lib/python3.7/site-packages (from torch==1.8.1+cu111) (4.2.0)
Installing collected packages: torch
  Attempting uninstall: torch
    Found existing installation: torch 1.8.1
    Uninstalling torch-1.8.1:
      Successfully uninstalled torch-1.8.1
Successfully installed torch-1.8.1+cu111

torchvision install

(torch1.8.1) [email protected]:/media/respecting/Ubuntu 18.0/June18$  pip install -i https://pypi.douban.com/simple torch-1.8.1+cu111-cp37-cp37m-linux_x86_64.whl 
Looking in indexes: https://pypi.douban.com/simple
Processing ./torch-1.8.1+cu111-cp37-cp37m-linux_x86_64.whl
Requirement already satisfied: numpy in /home/respecting/anaconda3/envs/torch1.8.1/lib/python3.7/site-packages (from torch==1.8.1+cu111) (1.21.6)
Requirement already satisfied: typing-extensions in /home/respecting/anaconda3/envs/torch1.8.1/lib/python3.7/site-packages (from torch==1.8.1+cu111) (4.2.0)
Installing collected packages: torch
  Attempting uninstall: torch
    Found existing installation: torch 1.8.1
    Uninstalling torch-1.8.1:
      Successfully uninstalled torch-1.8.1
Successfully installed torch-1.8.1+cu111

2. To test

(torch1.8.1) [email protected]:~$ python
Python 3.7.13 (default, Mar 29 2022, 02:18:16) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.zeros(1).cuda()
tensor([0.], device='cuda:0')
>>> 

原网站

版权声明
本文为[mingqian_ chu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206212023059632.html