-
Notifications
You must be signed in to change notification settings - Fork 32
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
Making train_parallel.py work on a single machine (non-distributed) #29
base: main
Are you sure you want to change the base?
Conversation
@@ -274,12 +288,15 @@ def main(args): | |||
"args": args, | |||
} # save full config. | |||
ema_model.save(vision_model_file, other_items=other_items) | |||
diffusion_model.model.module.vision_model.save( | |||
getattr(diffusion_model.model, "module", diffusion_model.model).vision_model.save( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need getattr
here, does the diffusion_model.model
sometimes not have a module
? Or is this connected to the torch change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that diffusion_model.model
only has module
when it's in the nn.parallel.DistributedDataParallel
container, so this getattr accounts for when model = diffusion_model.model
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's a better way to account for this (e.g. just adding the module
attribute to the model instance if it's missing), please let me know and I can make the change!
Small tweaks to train_parallel.py (and related changes to distributed.py and generate_batch.py) so that it works on a single machine. Mainly, it now only uses the nn.parallel.DistributedDataParallel model container if in a distributed environment.