模型预测时遇到报错AssertionError: Torch not compiled with CUDA enabled
代码本身可以确定是没有问题的,最后发现问题出现在Pytorch和CUDA版本不兼容的问题上。问题的发现可以在终端中输入'python'命令,运行python后,输入
import torch
print(torch.__version__)
print(torch.cuda.is_available())
如果输出的结果是False,那么说明当前的Pytorch版本无法使用显卡
终端输入
cat /usr/local/cuda/version.txt
查看当前cuda版本
并安装对应版本pytorch