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

Not accepting input type from CUDA #19

Open
ranka47 opened this issue Apr 7, 2019 · 2 comments
Open

Not accepting input type from CUDA #19

ranka47 opened this issue Apr 7, 2019 · 2 comments

Comments

@ranka47
Copy link

ranka47 commented Apr 7, 2019

Traceback (most recent call last):
  File "run_model.py", line 143, in <module>
    loss_ssim = -ssim_loss(noriginalimage, outputimage)
  File "/usr/local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pytorch_ssim/__init__.py", line 57, in forward
    return _ssim(img1, img2, window, self.window_size, channel, self.size_average)
  File "/usr/local/lib/python3.6/site-packages/pytorch_ssim/__init__.py", line 18, in _ssim
    mu1 = F.conv2d(img1, window, padding = window_size//2, groups = channel)
RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same

It is throwing this error. I have to convert both the variables to CPU to run which kills the speed of the computation. Can someone help out in resolving this?

@t2ac32
Copy link

t2ac32 commented Oct 10, 2019

Can you post the code section where you sent your too inputs to cuda?
Because youa re sending two thing to ssim both as tensors but only one of them is in GPU the other not.

@crvogt
Copy link

crvogt commented Jul 9, 2020

For future reference, the weights need to be sent to cuda device, or input needs to be on 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

3 participants