LoginSignup
0
1

More than 3 years have passed since last update.

Pytorchではtorch.deviceとDataParallel両方で使用するGPUを指定可能ですが

Posted at

Pytorchにはtorch.deviceとDataParallel両方で使用するGPUを指定可能ですが、それらの設定が矛盾している場合はどうなるのでしょうか?

例:

gpus = (0,2,4) #使用するgpu番号のtuple(複数選択可)

GPU id を0,2,4に設定された!

device = torch.device(f"cuda:{min(gpus)}" if len(gpus) > 0 else 'cpu')

GPU を1,3,5に指定された!

model = DataParallel(model, device_ids=[1,3,5])

model.to(device)

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1