Skip to content

one line for detection rpn work normally with cuda#1312

Open
Cosin777 wants to merge 2 commits intopytorch:mainfrom
Cosin777:fix-models-detection-cuda
Open

one line for detection rpn work normally with cuda#1312
Cosin777 wants to merge 2 commits intopytorch:mainfrom
Cosin777:fix-models-detection-cuda

Conversation

@Cosin777
Copy link

@Cosin777 Cosin777 commented Sep 9, 2019

The origin code, for example for detection: model.cuda()(torch.tensor([1,3,128,128], dtype = torch.float).cuda()), will raise error because the anchor tensor is still on the "cpu". This fix make the
code work more pytorch way.

@fmassa fmassa closed this Sep 9, 2019
@fmassa fmassa reopened this Sep 9, 2019
Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you write a full example which shows the error and add a test for it?

I believe the error happens only if you have done a first forward with the model in the CPU, and then you move the model to the GPU and try doing forward again.

But this should indeed be fixed, thanks for the catch!


def set_cell_anchors(self, device):
if self.cell_anchors is not None:
if self.cell_anchors is not None and device == self.cell_anchors[0].devcie:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a typo here, and the code is not going to work as is (devcie is not an attribute of Tensor).

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 this pull request may close these issues.

2 participants