How to Load a model_dict saved in GPU on cpu

# original saved file with DataParallel
state_dict = torch.load('myfile.pth.tar')
# create new OrderedDict that does not contain `module.`
from collections import OrderedDict
new_state_dict = OrderedDict()
for k, v in state_dict.items():
    name = k[7:] # remove `module.`
    new_state_dict[name] = v
# load params

I've found this code on the forum but the object is saved on .tar, 
how does this code modify in order to be applied to a .pt file?
Thanks in advance

Try to pass map_location='cpu' to torch.load as it should then directly load the data to the CPU.