Open haideralimughal opened 3 years ago
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)
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!
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