Pytorch 载入模型 torch.load(file) 指定 device 为CPU 或者为GPU
发布于 2 个月前 作者 pangguoming 77 次浏览 来自 PyTorch

torch.load(file) 默认是使用cuda GPU,要改为使用CPU需要添加参数map_location=torch.device(‘cpu’) 如下:

torch.load(file, map_location=torch.device('cpu'))

这样就是用CPU了

回到顶部