【Pytorch多GPU训练错误】AttributeError: ‘DataParallel’ object has no attribute ‘xxxx’
在 pytorch 多GPU训练下,存储 整个模型 ( 而不是model.state_dict() )后再调用模型可能会遇到下面的情况:AttributeError: ‘DataParallel’ object has no attribute ‘xxxx’解决的方法是:model = torch.load('path/to/model')#添加语句部分if isinstance(mo...
·
在 pytorch 多GPU训练下,存储 整个模型 ( 而不是model.state_dict() )后再调用模型可能会遇到下面的情况:
AttributeError: ‘DataParallel’ object has no attribute ‘xxxx’
解决的方法是:
model = torch.load('path/to/model')
#添加语句部分
if isinstance(model,torch.nn.DataParallel):
model = model.module
#下面就可以正常使用了
model.eval()
...
...
...
更多推荐

所有评论(0)