Answers for "pytorch use single gpu"

0

pytorch use multiple gpu

#easiest solution is to wrap you model in DataParallel like so:

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = Model(input_size, output_size)
if torch.cuda.device_count() > 1:
  print("Let's use", torch.cuda.device_count(), "GPUs!")
  model = nn.DataParallel(model)

model.to(device)
Posted by: Guest on August-25-2021

Python Answers by Framework

Browse Popular Code Answers by Language