The documentation for nn.DataParallel is not clear at all to me. How exactly am I supposed to pass input and targets to the GPU, if I specify concrete GPU’s?
My code looks something like this:
device = torch.device('cuda:' + str(arg.gpu) if torch.cuda.is_available() else 'cpu')
model = Model(arg).to(device)
for epoch in range(epochs+1):
    model.train()
    for step, (original, keypoints) in enumerate(train_loader):
        original, keypoints = original.to(device), keypoints.to(device)

I want to be able to pass pass GPU’s to the arg_parser through --gpu 5 7, which produces a list [5, 7]. Simply adding the line model = nn.DataParallel(Model(arg), device_ids=[5, 7]) is not enough, since I have to specify the device variable. However, device = torch.device('cuda:5,7' if torch.cuda.is_available() else 'cpu') results in an error. What am I supposed to do instead?