Skip to content

Commit

Permalink
Bug fix: RuntimeError: Expected all tensors to be on the same device,…
Browse files Browse the repository at this point in the history
… but found at least two devices, cuda:0 and cuda:2! (#7521)

修复Free anchor Retinanet网络训练时,可能会遇到计算得到的anchor与pre_bboxes不在同一个cuda device的bug。
  • Loading branch information
Youth-Got authored Mar 24, 2022
1 parent 91bfd75 commit 9459ae1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mmdet/models/dense_heads/free_anchor_retina_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def loss(self,
"""
featmap_sizes = [featmap.size()[-2:] for featmap in cls_scores]
assert len(featmap_sizes) == self.prior_generator.num_levels

anchor_list, _ = self.get_anchors(featmap_sizes, img_metas)
device = cls_scores[0].device
anchor_list, _ = self.get_anchors(featmap_sizes, img_metas, device=device)
anchors = [torch.cat(anchor) for anchor in anchor_list]

# concatenate each level
Expand Down

0 comments on commit 9459ae1

Please sign in to comment.