deep-high-resolution-net.pytorch icon indicating copy to clipboard operation
deep-high-resolution-net.pytorch copied to clipboard

AssertionError: Invalid device id

Open chappie1998 opened this issue 6 years ago • 8 comments

chappie1998 avatar Mar 24 '19 15:03 chappie1998

1.change the code in test.py: model = torch.nn.DataParallel(model,device_ids=cfg.GPUS).cuda() to model = torch.nn.DataParallel(model, device_ids=(0,)).cuda()

tianjiahao avatar Mar 25 '19 09:03 tianjiahao

I use model = torch.nn.DataParallel(model, device_ids=[0]).cuda()

YinRui1991 avatar Mar 28 '19 08:03 YinRui1991

Instead of directly changing test.py code at model = torch.nn.DataParallel(model,device_ids=cfg.GPUS).cuda(), You can execute test.py by giving the list of gpus as a parameter. Example: python tools/test.py --cfg experiments/coco/hrnet/w32_256x192_adam_lr1e-3.yaml TEST.MODEL_FILE models/pytorch/pose_coco/pose_hrnet_w32_256x192.pth GPUS (0,)

rrbarioni avatar May 29 '19 20:05 rrbarioni

warnings.warn(incompatible_device_warn.format(device_name, capability, " ".join(arch_list), device_name)) Traceback (most recent call last): File "gtad_train.py", line 109, in model = torch.nn.DataParallel(model, device_ids=list(range(opt['n_gpu']))).cuda() File "/usr/local/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 136, in init _check_balance(self.device_ids) File "/usr/local/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 "/usr/local/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 "/usr/local/lib/python3.7/site-packages/torch/cuda/init.py", line 317, in get_device_properties raise AssertionError("Invalid device id") AssertionError: Invalid device id

I face the same problem, I work at google colab. cuda 10.1

Malithi-gif avatar Dec 30 '20 05:12 Malithi-gif

1.change the code in test.py: model = torch.nn.DataParallel(model,device_ids=cfg.GPUS).cuda() to model = torch.nn.DataParallel(model, device_ids=(0,)).cuda()

where the test.py located?

Malithi-gif avatar Dec 30 '20 05:12 Malithi-gif

Instead of directly changing test.py code at model = torch.nn.DataParallel(model,device_ids=cfg.GPUS).cuda(), You can execute test.py by giving the list of gpus as a parameter. Example: python tools/test.py --cfg experiments/coco/hrnet/w32_256x192_adam_lr1e-3.yaml TEST.MODEL_FILE models/pytorch/pose_coco/pose_hrnet_w32_256x192.pth GPUS (0,)

But using GPUS(0,) throws syntax error near unexpected token `('....please help

Shadowwalker10 avatar May 21 '21 02:05 Shadowwalker10

@Shadowwalker10
Please use GPUS [0]. I hope it would resolve issue for you.

gulraizk94 avatar Aug 17 '21 15:08 gulraizk94

instead of !python tools/train.py --cfg experiments/mpii/hrnet/w32_256x256_adam_lr1e-3.yaml, which gives and error like above mentioned from others, I've used !python tools/train.py --cfg experiments/coco/hrnet/w32_256x192_adam_lr1e-3.yaml TEST.MODEL_FILE models/pytorch/pose_coco/pose_hrnet_w32_256x192.pth GPUS [0] and it seems like it's working so far, but what does TEST.MODEL_FILE models/pytorch/pose_coco/pose_hrnet_w32_256x192.pth GPUS [0] do exactly?

ChloeS31 avatar Jan 27 '22 06:01 ChloeS31