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

i am facing this error when i try to run test.py file. would you please give me any suggestions #9

Open
AliMedVisionTech opened this issue Jan 6, 2021 · 2 comments

Comments

@AliMedVisionTech
Copy link

Traceback (most recent call last):
File "test.py", line 58, in
denoiser = torch.nn.DataParallel(denoiser, device_ids=gpus_list)
File "/home/ali/anaconda3/envs/torch/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 136, in init
_check_balance(self.device_ids)
File "/home/ali/anaconda3/envs/torch/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 19, in _check_balance
dev_props = [torch.cuda.get_device_properties(i) for i in device_ids]
File "/home/ali/anaconda3/envs/torch/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 19, in
dev_props = [torch.cuda.get_device_properties(i) for i in device_ids]
File "/home/ali/anaconda3/envs/torch/lib/python3.7/site-packages/torch/cuda/init.py", line 317, in get_device_properties
raise AssertionError("Invalid device id")
AssertionError: Invalid device id

@Holmes-Alan
Copy link
Owner

You need to modify the model file since we tried the network on two GPU using torch.nn.DataParallel(). If you only use one GPU, you need to change the load function as something like,
pretrained_dict = torch.load(model_G, map_location=lambda storage, loc: storage)
model_dict = G.state_dict()
pretrained_dict = {k: v for k, v in pretrained_dict.items() if k in model_dict}
model_dict.update(pretrained_dict)
G.load_state_dict(model_dict)

@ajaykumar6666
Copy link

You need to modify the model file since we tried the network on two GPU using torch.nn.DataParallel(). If you only use one GPU, you need to change the load function as something like, pretrained_dict = torch.load(model_G, map_location=lambda storage, loc: storage) model_dict = G.state_dict() pretrained_dict = {k: v for k, v in pretrained_dict.items() if k in model_dict} model_dict.update(pretrained_dict) G.load_state_dict(model_dict)

Even though I changed, the error remained the same!

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

3 participants