Pytorch使用CPU运行“Torch not compiled with CUDA enabled”

错误提示:

Torch not compiled with CUDA enabled

修改:
1.将

torch.cuda.set_device(0)

换成

device = ('cuda' if torch.cuda.is_available() else 'cpu')

2.将

checkpoint = torch.load("/home/model/model_J18.pth.tar")

换成:

checkpoint = torch.load("C:/Users/user/Desktop/CoRRN/CoRRN/model/model_J18.pth.tar",map_location = 'cpu') 

3.将

model = model.cuda()  		

换成

model = model.to(device)

即将.cuda() 的地方都换成.to(device)

猜你喜欢

转载自blog.csdn.net/demo_jie/article/details/107358836