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

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! #91

Closed
Lansv-Noer opened this issue Dec 26, 2021 · 2 comments

Comments

@Lansv-Noer
Copy link

Lansv-Noer commented Dec 26, 2021

Hi,
Thank you for your work, but I have a problem when I run lpips loss on my computer with one GPU. All inputs of lpips are on device "cuda:0", but I am given an error (RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!). Details of error are shown as below. And version of lpips is 0.1.4.
File "losses/Lpips_Loss.py", line 47, in forward loss = self.loss(input[:, (2, 1, 0), ...], target[:, (2, 1, 0), ...], normalize=True) File "/**/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "/**/lib/python3.8/site-packages/lpips/lpips.py", line 118, in forward in0_input, in1_input = (self.scaling_layer(in0), self.scaling_layer(in1)) if self.version=='0.1' else (in0, in1) File "/**/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "/**/lib/python3.8/site-packages/lpips/lpips.py", line 154, in forward return (inp - self.shift) / self.scale RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
Thanks.

@Lansv-Noer
Copy link
Author

I don't transmit Lpips model to gpu, so I got this error.

@szh404
Copy link

szh404 commented Jun 15, 2024

self.shift and self.scale are on the CPU

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