1.服务器编辑时,一定要出现(base)这个环境
这是表示服务器编辑的所在环境(base)后路径
若是使用虚拟环境,对应的是(torch)…
2.cuda的问题
AssertionError: Torch not compiled with CUDA enabled
此错误是由于下载的torch没有cuda,所以在运行时会报错。
在程序最开始的地方加上:
device = torch.device("cuda"if torch.cuda.is_available() else "cpu")
代码其余地方出现.cuda()的地方改成.to(device)就可以在无gpu的环境中运行了。
# model = model.cuda()
model = model.to(device)