遇到的问题
最近在带4卡GeForce RTX 3080 的服务器上安装了一个高版本的pytorch,发现在运行如下命令时报如下错误:
运行命令如下:
import torch
print(torch.__version__)
print(torch.cuda.is_available())
torch.zeros(1).cuda()
print(torch.cuda.get_arch_list())
报错如下:
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.
If you want to use the NVIDIA GeForce RTX 3080 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
warnings.warn(incompatible_device_warn.format(device_name, capability, " ".join(arch_list), device_name))
即当前显卡的算力sm_86与当前安装的pytorch版本所能支持的算力[sm_37 sm_50 sm_60 sm_70]并不兼容。
解决办法
-
查看了系统当前的版本
(1)ubuntu 22.04
(2)cuda 11.4
(3)Python 3.7
(4)显卡 GeForce RTX 3080,算力为8.6,可在如下官方链接中查看:显卡算力查看 -
根据网上网友提供的相关资料,找到了当下不同Pytorch版本所支持的算力如下表所示
从上图中可以看到pytorch的1.8.0,且是cuda11.1的版本是支持显卡算例为sm_86的。因此,在本服务器安装的时候,安装上述对应的版本(值的注意的是:虽然该版本所对应的cuda与本服务器所已经安装的cuda11.4版本不对应,但最后安装完毕后,pytorch可正常调用显卡资源。可能cuda版本是向下兼容的)
安装命令如下:
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
- 输入如下代码,对安装的pytorch进行测试验证:
import torch
print(torch.__version__)
print(torch.cuda.is_available())
torch.zeros(1).cuda()
print(torch.cuda.get_arch_list())
输出结果如下:
之前所报的错误已经消失了。