The error is raised by PyTorch in its serialization module and the map_location argument can be specified in torch.load. I don’t know how pickle can be directly used to avoid this error, but would recommend to stick to torch.save/load and specify the pickle_module, if necessary.