【软件环境安装与使用】GeForce RTX 3080 with CUDA capability sm_86 is not compatible with the current PyTorch installation.
前言
博主在运行edgeai_yolov5的时候,出现了一些意料之外的错误,记之。
问题:
NVIDIA GeForce RTX 3080 Ti 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. 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. For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
原因:
NVIDIA GeForce RTX 3080 Ti with CUDA capability sm_86意思是RTX 3080 Ti的算力是8.6,而当前安装好的pytorch最高只支持到7.5算力的显卡,也就是说显卡算力和pytorch版本不匹配。
从log可以看出与pytorch、CUDA版本之间是否匹配有关;
通过以下代码不能确定cuda是否可用,只是检测CUDA是否正确安装并能否被pytorch检测到;
import torch # 在python的命令环境测试该命令 返回是True的,但是在run torch程序的时候报错 torch.cuda.is_available()
要测试显卡算力与当前pytorch是否匹配,可以进入python命令行,依次输入如下两行代码:
如果想要测是你的cuda版本torch是否可以使用,使用以下命令测试可能会更好。
import torch torch.zeros(1).cuda()
pip install -r requirements.txt
pip之后默认安装的环境是torch1.9.0+cuda10.2,而3080ti的算力是8.6,支持的cuda版本应该不小于11.0,所以出错。
解决办法是修改requirements.txt中的torch相关内容的版本,comment取消torch相关的pip安装,直接使用conda安装指定的torch和cuda版本即可;
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch # 最新版本的pytorch,也可以指定pytorch版本 pip install -r requirements.txt
其中-c pytorch表示指定使用pytorch channel,这个服务器位于国外,下载速度很慢,使用清华镜像源可以得到一个较快的下载速度。
update 20230113
问题
使用conda安装pytorch,每次都是默认安装了cpuonly组件,卸载cpuonly也是不行;添加清华源,还是不行;重启,重装conda,尝试了多种方法还是没解决这个问题;
conda update -n base conda conda -V conda update -n base conda conda update --all # 修改频道 conda config --add channels conda-forge conda config --set channel_priority flexible conda install pytorch==1.9 cudatoolkit=11.3 conda uninstall cpuonly
conda install pytorch==1.9 torchvision cudatoolkit=11.3 ./setup.sh
安装之后发现还是无法使用cuda版本的pytorch,错误如下:
AssertionError:Torch not compiled with CUDA enabled
原因分析:
重新安装之后还是不行,问题到底出在哪里呢???
conda install pytorch==1.10.0 torchvision torchaudio cudatoolkit=11.3
解决问题;
参考
1. GeForce RTX 3080 with CUDA capability sm_86 is not compatible with the current PyTorch installation.;
完
心正意诚,做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
版权声明,转载请注明出处:https://www.cnblogs.com/happyamyhope/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】