pytorch允许把在GPU上训练的模型加载到CPU上,也允许把在CPU上训练的模型加载到GPU上。


CPU->CPU,GPU->GPU

torch.load('gen_500000.pkl')


GPU->CPU

torch.load('gen_500000.pkl', map_location=lambda storage, loc: storage)


CPU->GPU1

torch.load('gen_500000.pkl', map_location=lambda storage, loc: storage.cuda(1))



posted on 2018-03-10 09:00  未雨愁眸  阅读(1477)  评论(0编辑  收藏  举报