AssertionError: Torch not compiled with CUDA enabled
此错误是由于下载的torch没有cuda,在运行时就会出错,经过查阅,在程序最开始的地方加上:
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
一定不要用中文引号
代码其余地方出现.cuda()的地方改成.to(device)就可以在无gpu的环境中运行了。
NameError: name 'torch' is not defined
直接
import torch
NameError: name 'jit' is not defined
from torch import from_numpy, jit
参考:https://blog.csdn.net/m0_37663482/article/details/88893603