Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. #1

Open
kirqwer6666 opened this issue Apr 12, 2021 · 1 comment

Comments

@kirqwer6666
Copy link

Hi, when running your test program, i met this question? I cannot handle it. Can you help me? Thank you!

Traceback (most recent call last):
File "test.py", line 28, in
net = Dehaze()
File "C:\Users\zyq\Desktop\ktdn\model.py", line 255, in init
res2net101.load_state_dict(model_zoo.load_url(model_urls['res2net101_v1b_26w_4s']))
File "D:\anaconda\envs\dehaze\lib\site-packages\torch\hub.py", line 559, in load_state_dict_from_url
return torch.load(cached_file, map_location=map_location)
File "D:\anaconda\envs\dehaze\lib\site-packages\torch\serialization.py", line 595, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "D:\anaconda\envs\dehaze\lib\site-packages\torch\serialization.py", line 774, in _legacy_load
result = unpickler.load()
File "D:\anaconda\envs\dehaze\lib\site-packages\torch\serialization.py", line 730, in persistent_load
deserialized_objects[root_key] = restore_location(obj, location)
File "D:\anaconda\envs\dehaze\lib\site-packages\torch\serialization.py", line 175, in default_restore_location
result = fn(storage, location)
File "D:\anaconda\envs\dehaze\lib\site-packages\torch\serialization.py", line 151, in _cuda_deserialize
device = validate_cuda_device(location)
File "D:\anaconda\envs\dehaze\lib\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 C
PU.

@ghost
Copy link

ghost commented Mar 10, 2022

open the resnet.py, and recify the cuda path to 0 or just annotation it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant