AssertionError: Torch not compiled with CUDA enabled
看了很多文章,问题并没有解决,于是淘宝找人解决,来记录解决过程,仅供大家参考。
错误显示如下:
看conda的安装环境!
(base) C:\Users\Administor>conda info --envs
显示结果如下:
激活openmmlab:
(base)C:\Users\Adminisitor>conda activate openmmlab
再导入安装openmmlab的文件夹,看安装列表
pip list
如果list里有torch和torchversion,则全卸载。按理说,是都有的。
pip uninstall torch
pip uninstall torchvision
卸载完,看英伟达显卡所允许安装的CUDA的最高版本。
nvidia-smi
11.6以下都可以安装
这里我安装的是CUDA11.3版本,用的是豆瓣源
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 -i https://pypi.douban.com/simple
成功安装匹配的torch torchvision cuda, torch 1.12.1 ,cuda 11.3 , torchvision 0.13.1
再输入python
import torch
torch.cuda.is_available()
结果为true
错误解决 成功运行
end