RuntimeError: CUDA error: no kernel image is available for execution on the device
安装适用于GeForce RTX 3090显卡的pytorch
卸载当前版本的pytorch, 重新按照以下安装
pip uninstall torch
# torch 1.7.0+cu110
pip install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
# 更新:现在可使用torch 1.8.2 啦!!
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch-lts -c nvidia
如果安装失败可以尝试离线安装,具体参考我的另一篇博客
Pytorch安装太慢/安装不了怎么办?那就离线安装Pytorch_wisteri的博客-CSDN博客
另一个小问题
Pytorch错误:Torch not compiled with CUDA enabled
在用Pytorch炼丹的过程中,很意外地碰到了一个错误提示AssertionError: Torch not compiled with CUDA enabled。
代码本身可以确定是没有问题的,因为只是在往日已经跑过的代码上加入了小改动。最后发现问题出现在Pytorch和CUDA版本不兼容的问题上。问题的发现可以在终端中输入'python3'命令,运行python3后,输入
import torch
print(torch.__version__)
print(torch.cuda.is_available())
如果输出的结果是False,那么说明当前的Pytorch版本无法使用显卡。
解决办法:
应该是你装的是cpu版本的Pytorch,卸载重装cuda版本的Pytorch。