Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Pix2PixHDModel' object has no attribute 'module' #20

Open
yejg2017 opened this issue Feb 9, 2018 · 8 comments
Open

'Pix2PixHDModel' object has no attribute 'module' #20

yejg2017 opened this issue Feb 9, 2018 · 8 comments

Comments

@yejg2017
Copy link

yejg2017 commented Feb 9, 2018

When I run my own image data,I met this bug,and how can I solved this problem?
type(self).name, name))
AttributeError: 'Pix2PixHDModel' object has no attribute 'module'

@tcwang0509
Copy link
Contributor

Which line in which file does this occur?

@alwynmathew
Copy link

I couldn’t find a module in model. Could you point me to the code section where its defined.
AttributeError: 'model' object has no attribute 'module'

@oatmeal3000
Copy link

When I use cpu only without GPU

create web directory ./checkpoints/melody/web...
Traceback (most recent call last):
File "train.py", line 48, in
optimizer_G, optimizer_D = model.module.optimizer_G, model.module.optimizer_D
File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 772, in getattr
type(self).name, name))
torch.nn.modules.module.ModuleAttributeError: 'Pix2PixHDModel' object has no attribute 'module'

@joel1895
Copy link

joel1895 commented Oct 8, 2020

I am also facing the error, any solution for this?

@kondela
Copy link

kondela commented Oct 8, 2020

Any chance you are trying to run it using PyTorch >= 1.0 and on cpu? Try PyTorch 1.5/1.6 and a GPU

@AyeshaShafique
Copy link

i also need solution @joel1895

@alwynmathew
Copy link

Set gpu_ids as -1 to run in cpu.

if opt.isTrain and len(opt.gpu_ids) and not opt.fp16:

if gpu_ids is not set to -1, model will be wrapped in DataParallel

model = torch.nn.DataParallel(model, device_ids=opt.gpu_ids)

when its wrapped in DataParallel, everything in model can be only access like model.module.something

Hope this helped.

@kex243
Copy link

kex243 commented Jun 14, 2021

You can remove all instances of ".module" in train.py if commenting in models.py if opt.isTrain and len(opt.gpu_ids) and not opt.fp16: model = torch.nn.DataParallel(model, device_ids=opt.gpu_ids)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants