在此之前,我能够通过CUDA运行时版本10.2连接到GPU。但是,当我设置一个项目时,我遇到了一个错误。
Using torch 1.10.1+cu102 (NVIDIA GeForce RTX 3080)
UserWarning:
NVIDIA GeForce RTX 3080 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.经过一些阅读,sm_86似乎只适用于11.0及以上版本。这就是为什么我升级到最新的CUDA版本,并无法连接到GPU之后。我尝试过很多方法,重新安装库达工具包、PyTorch、torchvision等等,但都没有用。
我使用过的CUDA工具包:
$ wget https://developer.download.nvidia.com/compute/cuda/11.6.0/local_installers/cuda_11.6.0_510.39.01_linux.run
$ sudo sh cuda_11.6.0_510.39.01_linux.run我已经安装了PyTorch (尝试了conda和pip):
$ conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
$ pip3 install torch==1.10.1+cu113 torchvision==0.11.2+cu113 torchaudio==0.10.1+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html以下是一些基本信息:
(base) ubuntu@DESKTOP:~$ python
Python 3.9.5 (default, Jun 4 2021, 12:28:51)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.__version__
'1.10.1+cu113'
>>> x = torch.rand(6,6)
>>> print(x)
tensor([[0.0228, 0.3868, 0.9742, 0.2234, 0.5682, 0.7747],
[0.2643, 0.3911, 0.3464, 0.5072, 0.4041, 0.4268],
[0.2247, 0.0936, 0.4250, 0.1128, 0.0261, 0.5199],
[0.0224, 0.7463, 0.1391, 0.8092, 0.3742, 0.2054],
[0.3951, 0.4205, 0.6270, 0.4561, 0.4784, 0.5958],
[0.8430, 0.5078, 0.7759, 0.5266, 0.4925, 0.7557]])
>>> torch.cuda.get_arch_list()
[]
>>> torch.cuda.is_available()
False
>>> torch.version.cuda
'11.3'
>>> torch.cuda.device_count()
0下面是我的配置。
(base) ubuntu@DESKTOP:~$ ls -l /usr/local/ | grep cuda
lrwxrwxrwx 1 root root 21 Jan 24 13:47 cuda -> /usr/local/cuda-11.3/
lrwxrwxrwx 1 root root 25 Jan 17 10:52 cuda-11 -> /etc/alternatives/cuda-11
drwxr-xr-x 17 root root 4096 Jan 24 13:48 cuda-11.3
drwxr-xr-x 18 root root 4096 Jan 24 10:17 cuda-11.6ubuntu版本:
(base) ubuntu@DESKTOP:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focalnvidia-smi
(base) ubuntu@DESKTOP:~$ nvidia-smi
Mon Jan 24 17:22:42 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.39.01 Driver Version: 511.23 CUDA Version: 11.6 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... On | 00000000:02:00.0 Off | N/A |
| 0% 26C P8 5W / 320W | 106MiB / 10240MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 4009 G /Xorg N/A |
| 0 N/A N/A 4025 G /xfce4-session N/A |
| 0 N/A N/A 4092 G /xfwm4 N/A |
| 0 N/A N/A 25903 G /msedge N/A |
+-----------------------------------------------------------------------------+nvcc --version
(base) ubuntu@DESKTOP:~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Sun_Mar_21_19:15:46_PDT_2021
Cuda compilation tools, release 11.3, V11.3.58
Build cuda_11.3.r11.3/compiler.29745058_0发布于 2022-02-07 05:11:17
我在回答我自己的问题。
PyTorch pip车轮和Conda二进制文件随CUDA运行时一起发布。但CUDA通常不附带NVCC,需要与conda-forge/cudatoolkit-dev分开安装,这在安装过程中非常麻烦。
所以,我所做的就是从Nvidia CUDA工具包安装NVCC。
$ wget https://developer.download.nvidia.com/compute/cuda/11.6.0/local_installers/cuda_11.6.0_510.39.01_linux.run和Conda Py手电筒-GPU版本
$ conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch事实证明,这两种安装是不兼容的。
因此,我为解决这一问题所采取的步骤:
website.
cuda_11.3。$ pip3 install torch==1.10.1+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.htmlhttps://stackoverflow.com/questions/70831932
复制相似问题