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

Tensors not on the same device #35

Open
drjoeCV opened this issue Jan 14, 2022 · 4 comments
Open

Tensors not on the same device #35

drjoeCV opened this issue Jan 14, 2022 · 4 comments

Comments

@drjoeCV
Copy link

drjoeCV commented Jan 14, 2022

I'm getting the RuntimeError: Expected all tensors to be on the same device error in several locations:

iou_mask.py line 340 boxes1[:,0] = *w
rapid.py line 221 norm_anch_wh = anchors[:,0:2] / imp_hw

and more

@duanzhiihao
Copy link
Owner

Hi, your information is not sufficient for me to locate the problem. Which python file are you executing? Can you provide your command line args?

@drjoeCV
Copy link
Author

drjoeCV commented Jan 14, 2022

following the README, I'm running $ python train.py --model rapid_pL1 --dataset COCO --batch_size 4
I successfully ran the example.py on both the CPU and GPU

I'm on torch version 1.10.1

BTW, that remind me of another problem. the readme says to use --model rapid_L1 but its supposed to be --model rapid_pL1 I added an assert into train.py to catch if the model string is not on of the supported pL1 or pL2

duanzhiihao added a commit that referenced this issue Jan 14, 2022
@duanzhiihao
Copy link
Owner

I see.

  1. The code works on PyTorch 1.6 or something. But at some version update, PyTorch makes tensor.shape return torch.Size, where previously it returns tuple. This update breaks my code. I will make an update sometime tomorrow to make it compatible with PyTorch 1.10.
  2. I updated readme.

@drjoeCV
Copy link
Author

drjoeCV commented Jan 14, 2022

Thanks. That is the problem, its returning a torch.Size instead of a tuple or even a tensor. You have a isinstance(size, Tuple) that you need to change in iou_mask.py and in rapid.py you need to change imp_hw from being a torch.Size to a torch.Tensor that is ALSO on the same device as the anchors.

duanzhiihao added a commit that referenced this issue Jan 14, 2022
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