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

Maybe a bug about multi_scale_deform_attn #2159

Closed
pixeli99 opened this issue Jul 29, 2022 · 5 comments · Fixed by #2158
Closed

Maybe a bug about multi_scale_deform_attn #2159

pixeli99 opened this issue Jul 29, 2022 · 5 comments · Fixed by #2158
Assignees

Comments

@pixeli99
Copy link

Hi,
I got an error when executing this line of code.

sampling_offsets = self.sampling_offsets(query).view(

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

I personally feel that there is a problem with initializing weights. You can see here, the bias of sampling_offsets may be put on cpu?

self.sampling_offsets.bias.data = grid_init.view(-1)

The device of grid_init is cpu on my machine.

thetas = torch.arange(
            self.num_heads,
            dtype=torch.float32) * (2.0 * math.pi / self.num_heads)
grid_init = torch.stack([thetas.cos(), thetas.sin()], -1)
@zhouzaida
Copy link
Collaborator

Calling model.init_weight() after model.to('cuda:0') will cause this error you mentioned above. Are you willing to create a PR to resolve it?

@pixeli99
Copy link
Author

OK, but where was the model.to('cuda:0') called?

I'm not sure where to fix it

@zhouzaida
Copy link
Collaborator

Oh, and there's already a PR (#2158) to fix this bug.

@zhouzaida zhouzaida linked a pull request Jul 30, 2022 that will close this issue
7 tasks
@pixeli99
Copy link
Author

OK, thank you for your reply.😊

@zhouzaida
Copy link
Collaborator

Oh, and there's already a PR (#2158) to fix this bug.

Done

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

Successfully merging a pull request may close this issue.

3 participants