You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
#140
Number of images: 8
...load U2NET---173.6 MB
Traceback (most recent call last):
File "/Users/Kevin.SuTJ/Desktop/U^2 Net/u2net_portrait_test.py", line 117, in <module>
main()
File "/Users/Kevin.SuTJ/Desktop/U^2 Net/u2net_portrait_test.py", line 87, in main
net.load_state_dict(torch.load(model_dir))
File "/usr/local/lib/python3.9/site-packages/torch/serialization.py", line 595, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/usr/local/lib/python3.9/site-packages/torch/serialization.py", line 774, in _legacy_load
result = unpickler.load()
File "/usr/local/lib/python3.9/site-packages/torch/serialization.py", line 730, in persistent_load
deserialized_objects[root_key] = restore_location(obj, location)
File "/usr/local/lib/python3.9/site-packages/torch/serialization.py", line 175, in default_restore_location
result = fn(storage, location)
File "/usr/local/lib/python3.9/site-packages/torch/serialization.py", line 151, in _cuda_deserialize
device = validate_cuda_device(location)
File "/usr/local/lib/python3.9/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.
In the u2net_portrait_test.py i added , map_location=torch.device("cpu")
In the u2net_portrait_test.py i added
, map_location=torch.device("cpu")
net.load_state_dict(torch.load(model_dir))
to
net.load_state_dict(torch.load(model_dir, map_location=torch.device("cpu")))
And then I'm doing fine.
The text was updated successfully, but these errors were encountered: