AttributeError:'MyModel' object has no attribute ‘module’问题的解决

由于是用自己笔记本编写程序,只有一块显卡,不存在多个GPU!但编写程序时会想到使用多个GPU的事情,但会出现错误,我的解决方式是:

if args.mGPU else net.refinement.parameters()
改为:
if args.mGPU and (torch.cuda.device_count() > 1) else net.parameters()

看了其他的程序,还有些是将本次运行后产生的.pyc文件全部删除,重新运行就好了

你可能感兴趣的:(pytorch)