问题描述:
在跑分类任务时间遇到以下错误:
UserWarning:NVIDIA Geforce RIX 3060 Laptop GPU with CUDA capability sm_86 is not compatible with the current PyTorch installation. The current PyTorch Instell supports CUDA capabilities sa_37 sm_50 sa_60 sm_61 se,70 sn_75 compute._37. If you want to use the NVIDIA Geforce RTX 3060 Laptop GU GPU with PyTorch, please check the instructions at http://pytorch.org/get-started/locally/
问题原因:
造成这一错误的原因是我的RTX3060的显卡和pytorch的版本不适配,pytorch的版本过低或者过高。
问题解决:
打开pycharm终端Termina激活pytorch虚拟环境,前面由base变成pytorch则激活成功。
键入conda list查看当前torch的版本如下:
可知当前python解释器的版本为3.8,torch的版本为1.10.0,cuda的版本为10.2,版本过低。
在重新安装前需要卸载低版本,在终端Termina键入:
pip uninstall torch
pip uninstall torchaudio
pip uninstall torchvision
卸载完成之后需要重新安装适配显卡的torch版本。
按win+r打开命令窗口键入:nvidia-smi
查看显卡最高支持的cuda版本,如下:
显卡所支持cuda的最高版本为11.7。
需要注意的是版本之间的对应,其官网的对应关系如下链接。
进入官网:Previous PyTorch Versions | PyTorch
找到对应的CUDA版本,我对应下载CUDA11.6版本。
其中torch的版本为1.13.0,适配于python3.8的版本。
pytorch版本1.13.0,cuda版本为11.6,键入一下命令重新安装适配版本:
pip install torch==1.13.0+cu116 torchvision==0.14.0+cu116 torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/cu116
安装成功,问题解决。