VIsualization script problem when dealing with cpu only machine
osmarcedron opened this issue · 3 comments
osmarcedron commented
Salut Lucas!
I found this error while trying the visualization script using only cpu.
Traceback (most recent call last):
File "/envs/pytorch/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/envs/pytorch/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "rl-starter-files/scripts/visualize.py", line 55, in <module>
device=device, argmax=args.argmax, use_memory=args.memory, use_text=args.text)
File "rl-starter-files/utils/agent.py", line 25, in __init__
self.acmodel.load_state_dict(utils.get_model_state(model_dir))
File "rl-starter-files/utils/storage.py", line 46, in get_model_state
return get_status(model_dir)["model_state"]
File "rl-starter-files/utils/storage.py", line 32, in get_status
return torch.load(path)
File "/envs/pytorch/lib/python3.6/site-packages/torch/serialization.py", line 592, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/envs/pytorch/lib/python3.6/site-packages/torch/serialization.py", line 851, in _load
result = unpickler.load()
File "/envs/pytorch/lib/python3.6/site-packages/torch/serialization.py", line 843, in persistent_load
load_tensor(data_type, size, key, _maybe_decode_ascii(location))
File "/envs/pytorch/lib/python3.6/site-packages/torch/serialization.py", line 832, in load_tensor
loaded_storages[key] = restore_location(storage, location)
File "/envs/pytorch/lib/python3.6/site-packages/torch/serialization.py", line 175, in default_restore_location
result = fn(storage, location)
File "/envs/pytorch/lib/python3.6/site-packages/torch/serialization.py", line 151, in _cuda_deserialize
device = validate_cuda_device(location)
File "/envs/pytorch/lib/python3.6/site-packages/torch/serialization.py", line 135, in validate_cuda_device
raise RuntimeError('Attempting to deserialize object on a CUDA '
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=torch.device('cpu') to map your storages to the CPU.
lcswillems commented
Hi!
This is a weird issue. Did you train and save the model on a computer that have a CUDA and then loaded it on a computer that doesn't have a CUDA?
osmarcedron commented
Yes indeed. I do not have access to a X11 in the HPC where I train so for visualization purposes I gotta use only CPU. Is there any problem with my approach?
lcswillems commented
Thank you for having raised this issue! It had just been fixed in this commit: e604b36