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

Saving Multi-GPU #34

Open
EoinKenny opened this issue Jun 5, 2023 · 1 comment
Open

Saving Multi-GPU #34

EoinKenny opened this issue Jun 5, 2023 · 1 comment

Comments

@EoinKenny
Copy link

Thanks for this repo!

It seems like the code doesn't save the models correctly when using multiple GPUs right? Like if I train on multiple GPUs but load on a single CPU, it won't work I think.

You have this

    def save(self, path):
        states = {
            'G': self.G.state_dict(),
            'D': self.D.state_dict(),
            'optim_G': self.optim_G.state_dict(),
            'optim_D': self.optim_D.state_dict()
        }
        torch.save(states, path)

But I think you need self.G.module.state_dict() ?

@elvisyjlin
Copy link
Owner

Hello @EoinKenny , it could be the case when the model is trained on multiple GPUs. I trained the model on single GPU, so I didn't encounter any error. Please refine the code if you see it. Also, feel free to create a pull request!

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

2 participants