How to load a pickle.dump pkl file from GPU server

Store a list on GPU server into a pkl file using pickle.dump(…)
Now I want to pickle.load the pkl file on a CPU-only machine, but got the following error message:

RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=‘cpu’ to map your storages to the CPU.

I tried to load the pkl using torch.load with mapping to CPU, but it doesn’t work.

Hi,

You can use torch.load() and ask for your tensors to be on the cpu by setting map_location="cpu".