- 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/
- RuntimeError: CUDA error: no kernel image is available for execution on the device
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
今天运行项目的时候出现了这个报错,记录一下解决方式
需求:项目需要使用特定版本的pytorch,我不知道应该下载什么版本的cuda与之对应
问题原因:当前GPU(以我的为例,为RTX 3090)与当前的CUDA版本(11.4)支持的sm类型是sm_86,与现在的PyTorch版本不匹配
解决方式:安装符合GPU和项目要求的torch版本的cuda和torch
网上也有一些查询支持的sm类型的方法,在此不再说明,可参考帖子NVIDIA GeForce RTX 3090 with CUDA capability sm_86 is not compatible with the current PyTorch_power_kaikaige的博客-优快云博客
现在仅说明出现这个报错该如何解决:
1.
nvidia-smi
使用此命令看当前GPU支持的最新Cuda版本是多少
nvcc -V
再使用此命令看当前Cuda版本是多少,如果当前Cuda版本比所支持最新Cuda还要新,则需要先降低对应的cuda版本
2.
因为很多帖子展示的Cuda和Pytorch对应版本都较老,如果不知道较新的cuda版本对应的pytorch是多少,可按照下方的网站,
Previous PyTorch Versions | PyTorch
定位到所需要的torch版本,以我为例为v1.12.1,可看到如下代码:
# CUDA 10.2
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=10.2 -c pytorch
# CUDA 11.3
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch
# CUDA 11.6
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge
# CPU Only
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cpuonly -c pytorch
可根据自己GPU算力选择对应的命令安装torch,并按照安装cuda的方式,安装对应版本的cuda
注意cuda是向下兼容的,所以可以选择>=项目要求版本的cuda,如某项目需要11.4的cuda,则可以选择第三条命令,并安装cuda11.6