适用问题
本文解决了“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/”
上段提示的意思是当前cuda的算力或pytorch和显卡算力不匹配
我的环境配置
显卡:RTX 3090
通过nvidia-smi
指令查看:
绿色部分即为显卡系列,通过报错信息可知其算力是sm_86,如果你的模型没有要求pytorch的版本,可以去查一下跟sm_86对应的pytorch版本。我的模型对pytorch的版本有要求。
pytorch:torch-1.11.0 && torchvision-0.12.0
python:3.8.10
通过python
指令查看
我有两个版本的python,上图为默认版本。python版本的选择可以在pycharm里面进行配置,需要根据pytorch的版本进行选择。
CUDA:RTX 3090要求的cuda的版本要在11以上,并且cuda的版本不能超过上图中红色圈圈内的版本。同时,还要考虑pytorch的版本(根据自己的要求去选择cuda),因此我选择的是cuda11.3。
CUDNN:查看与cuda配套的cudnn版本,这个也一定要下!!我选择的是cudnn–8.2.1
上面配置具体下载的方法我就不赘述了。
查找解决办法
解决本文问题,借鉴了以下文章:
https://blog.csdn.net/A407567738/article/details/127457398
自测问题
自测代码:
import torch
print(torch.cuda.is_available())
print(torch.zeros(1).cuda())
若报错:
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/
则点击右侧,查看与当前cuda匹配的pytorch:pytorch下载官网
解决问题
综合考虑,我选择了:
pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113
这里我下载了一个半小时,时间比较久应该是正常的。
验证结果
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.zeros(1).cuda()
tensor([0.], device='cuda:0')
>>>
当出现tensor([0.], device='cuda:0')
则说明问题已经解决。
特别说明
本人在解决这个问题前,重新配置了一下cudnn,我觉得我报错的原因还有可能是没有下载正确的cudnn。
详细方法看见这两篇文章:教你如何下载cudnn和教你如何移动cudnn/cuda中的文件。
一定要记得把解压后的cudnn中cuda的两个文件夹移动到你需要的cuda文件里(上面链接里有教!!!)