I am trying to run the following code with multiple GPUs but I am not getting where to add the following?
net = torch.nn.DataParallel(model, device_ids=[0, 1, 2])
with torch.cuda.device(CUDA_VISIBLE_DEVICES):
if args.dataset == "fashionmnist":
resnet18 = resnet.ResNet18fm(num_classes=NO_CLASSES).cuda()
else:
#resnet18 = vgg11().cuda()
resnet18 = resnet.ResNet18(num_classes=NO_CLASSES).cuda()
if method == 'lloss':
#loss_module = LossNet(feature_sizes=[16,8,4,2], num_channels=[128,128,256,512]).cuda()
loss_module = LossNet().cuda()
models = {'backbone': resnet18}
if method =='lloss':
models = {'backbone': resnet18, 'module': loss_module}
torch.backends.cudnn.benchmark = True
models = torch.nn.DataParallel(models, device_ids=[0])