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

gan.py template fails to run with GPU #523

Closed
MarkoOrescanin opened this issue Nov 18, 2019 · 1 comment
Closed

gan.py template fails to run with GPU #523

MarkoOrescanin opened this issue Nov 18, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@MarkoOrescanin
Copy link

Common bugs:

  1. Tensorboard not showing in Jupyter-notebook see issue 79.
  2. PyTorch 1.1.0 vs 1.2.0 support see FAQ

Describe the bug
When running the gan.py script with the only change in script

trainer = pl.Trainer(max_nb_epochs=10, gpus=1, distributed_backend='dp')
or with gpus=[0]

script fails with error on the loss function not being on GPU
File "/home/marko/anaconda2/envs/py36_torch13/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/home/marko/anaconda2/envs/py36_torch13/lib/python3.6/site-packages/pytorch_lightning/pt_overrides/override_data_parallel.py", line 58, in forward
return self.module.training_step(*inputs[0], **kwargs[0])
File "gan.py", line 116, in training_step
g_loss = self.adversarial_loss(self.discriminator(self.generated_imgs), valid)
File "gan.py", line 89, in adversarial_loss
return F.binary_cross_entropy(y_hat, y)
File "/home/marko/anaconda2/envs/py36_torch13/lib/python3.6/site-packages/torch/nn/functional.py", line 2065, in binary_cross_entropy
input, target, weight, reduction_enum)
RuntimeError: Expected object of device type cuda but got device type cpu for argument #2 'target' in call to _thnn_binary_cross_entropy_forward
Epoch 1: 0%| | 0/938 [00:00<?, ?batch/s]

To Reproduce
Steps to reproduce the behavior:

  1. Go to gan.py
  2. Change the trainer= pl.Trainer() to above on a GPU system

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • OS: Ubuntu 16.04
@MarkoOrescanin MarkoOrescanin added the bug Something isn't working label Nov 18, 2019
@williamFalcon
Copy link
Contributor

Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants