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 object of backend CUDA but got backend CPU for argument #2 'other' #3

Closed
linchunmian opened this issue May 21, 2021 · 10 comments

Comments

@linchunmian
Copy link

Hi, I followed the installation and get_start files to complete necessary running environment, and this bug happened. How should I solve this, and please help me !
Thanks!

@tianweiy
Copy link
Owner

Seems that some value need to be converted to cuda. You can just add a cuda() at that line ?

@linchunmian
Copy link
Author

linchunmian commented May 25, 2021 via email

@tianweiy
Copy link
Owner

tianweiy commented May 25, 2021

I mean adding a cuda() to this line you referenced #2 (comment)

Does this work? If not please paste the full log, this is easier than sentences for debugging

@linchunmian
Copy link
Author

I mean adding a cuda() to this line you referenced #2 (comment)

Does this work? If not please paste the full log, this is easier than sentences for debugging

Thanks. The error information is as follows:
Screenshot from 2021-05-26 09-06-01
Where should cuda() be added?

@tianweiy
Copy link
Owner

either center_int or feature_map_size

@tianweiy
Copy link
Owner

like

center_int[0].cuda() < feature_map_size[0].cuda() ...

@linchunmian
Copy link
Author

like

center_int[0].cuda() < feature_map_size[0].cuda() ...

Many thanks. As you said, I have added cuda() behind the variance of 'feature_map_size', and new type problem happens:
Screenshot from 2021-05-26 09-17-04
How to solve it? By the way, adding cuda() after center_int, e.g center_int().cuda() does not make effect.

@tianweiy
Copy link
Owner

try this

if not (0 <= center_int[0] < feature_map_size[0].cuda().int()
      and 0 <= center_int[1] < feature_map_size[1].cuda().int()):

@linchunmian
Copy link
Author

I convert the type of feature_map_size to int32 by adding .to(torch.int32).
It seems this bug has passed, and the code run normally.
Many thanks for your helps.

@tianweiy tianweiy closed this as completed Jun 6, 2021
@bi-qiuqiu
Copy link

I convert the type of feature_map_size to int32 by adding .to(torch.int32). It seems this bug has passed, and the code run normally. Many thanks for your helps.
Did you change all feature_map_size in this file to feature_map_size.to(torch.int32)?I changed line 269 to if not (0 <= center_int[0] < feature_map_size[0].cuda().int(),but this problem arises.
and 0 <= center_int[1] < feature_map_size[1].cuda().int()):
image

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