-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
CrossEntropyLoss fails to run with GPU #2400
Comments
No, you have to move |
Ok, thanks @rohitgr7. |
You can also use:
the PL module knows what device it is on. |
@williamFalcon is there a reason why this is not managed by lightning? |
@taylorchu If you pass that from the DataLoader(or Dataset) itself it will be handled automatically, but if a tensor is created in between the procedure by the user itself, one has to move it to the device manually the PyTorch way. |
yup... no way around it as mentioned above |
🐛 Bug
Using the following
training_step
method which usesnn.CrossEntropyLoss()
loss function:fails to run with GPU throwing the following error:
The function
self.loss_fn
is shown below:Is
target = torch.arange(x1.size()[0])
not being created in the GPU?Expected behavior
That target tensor (
target = torch.arange(x1.size()[0])
) is created on the GPU.Environment
The text was updated successfully, but these errors were encountered: