我正在使用 PyTorch。我将在带有 CPU 的多个 GPU 上使用已经训练好的模型。这个任务怎么做?
我在 Anaconda 3 和 pytorch 上试过只有 cpu 我没有 gpu
model = models.get_pose_net(config, is_train=False)
gpus = [int(i) for i in config.GPUS.split(',')]
model = torch.nn.DataParallel(model, device_ids=gpus).cuda()
print('Created model...')
print(model)
checkpoint = torch.load(config.MODEL.RESUME)
model.load_state_dict(checkpoint)
model.eval()
print('Loaded pretrained weights...')
Run Code Online (Sandbox Code Playgroud)
我得到的错误是
AssertionError Traceback (most recent call last)
<ipython-input-15-bbfcd201d332> in <module>()
2 model = models.get_pose_net(config, is_train=False)
3 gpus = [int(i) for i in config.GPUS.split(',')]
----> 4 model = torch.nn.DataParallel(model, device_ids=gpus).cuda()
5 print('Created model...')
6 print(model)
C:\Users\psl\Anaconda3\lib\site-packages\torch\nn\modules\module.py in cuda(self, device)
258 …Run Code Online (Sandbox Code Playgroud)