No kernel image is available for execution on the device问题

Error

  • 训练时报以下错误:
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.
  • 运行以下脚本
import torch
torch.zeros(1).cuda()

报错:

GeForce RTX 3060 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 GeForce RTX 3060 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/

大概的意思是,当前的pytorch-cuda版本仅支持3.7、5.0、6.0、7.0的算力,但是本显卡的算力为8.6,因此需要升级pytorch-cuda的版本。
Note:目前朋友torch官网上给出的pytorch、cuda都是捆绑的,因此两者是一同install的。

Solution

  • 去这个网站寻找适配的版本:

直接复制命令,然后运行即可,但是不知道会不会根据python环境自动选择对应版本,博主没试过,重点介绍.whl安装。

https://pytorch.org/get-started/previous-versions/
  • 手动离线(.whl)文件 pip install .whl安装

由于实习的服务器只能从本地源上下载,因此博主采取的是离线安装方式。
进入下面这个网站

https://download.pytorch.org/whl/

注意 torch、torchvision需要下载同一个版本的cuda,同时需要和本地的python环境、系统架构对应,否则会报错。

torch-1.10.0: torch版本
cu111: cuda11.1
cp37_cp37m: python3.7
linux_x86: x_86架构的系统, 日常的大部分
AArch: Arm架构的系统

在这里插入图片描述
同时兼顾torch+cuda的版本,下载torchvision+cuda的版本,并上传服务器即可通过pip install命令安装。

参考文献:
知乎
CSDN

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值