torch.load('tensors.pt') # 把所有的张量加载到CPU中 torch.load('tensors.pt', map_location=lambda storage, loc: storage) # 把所有的张量加载到GPU 1中 torch.load('tensors.pt', map_location=lambda storage, loc: storage.cuda(1)) # 把张量从GPU 1 移动到 GPU 0 torch.load('tensors.pt', map_location={'cuda:1':'cuda:0'})