Faster-rcnn.pytorch: RuntimeError: reciprocal is not implemented for type torch.cuda.ByteTensor

Created on 24 Apr 2018  路  5Comments  路  Source: jwyang/faster-rcnn.pytorch

Traceback (most recent call last):
File "trainval_net.py", line 323, in
rois_label = fasterRCNN(im_data, im_info, gt_boxes, num_boxes)
File "/home/liuweizhou/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 371, in __call__
result = self.forward(input, *kwargs)
File "/home/liuweizhou/object-detection/faster-rcnn.pytorch/lib/model/faster_rcnn/faster_rcnn.py", line 50, in forward
rois, rpn_loss_cls, rpn_loss_bbox = self.RCNN_rpn(base_feat, im_info, gt_boxes, num_boxes)
File "/home/liuweizhou/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 371, in __call__
result = self.forward(input, *kwargs)
File "/home/liuweizhou/object-detection/faster-rcnn.pytorch/lib/model/rpn/rpn.py", line 87, in forward
rpn_data = self.RPN_anchor_target((rpn_cls_score.data, gt_boxes, im_info, num_boxes))
File "/home/liuweizhou/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 371, in __call__
result = self.forward(input, *kwargs)
File "/home/liuweizhou/object-detection/faster-rcnn.pytorch/lib/model/rpn/anchor_target_layer.py", line 157, in forward
positive_weights = 1.0 / num_examples
File "/home/liuweizhou/anaconda3/lib/python3.6/site-packages/torch/autograd/variable.py", line 328, in __rdiv__
return self.reciprocal() * other
RuntimeError: reciprocal is not implemented for type torch.cuda.ByteTensor

Most helpful comment

@kebijuelun Use Pytorch 0.3.0 version. It will solve the problem.

All 5 comments

Same problem with me as well. Does anybody find the solution for this?

Traceback (most recent call last): File "trainval_net.py", line 322, in <module> rois_label = fasterRCNN(im_data, im_info, gt_boxes, num_boxes) File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 491, in __call__ result = self.forward(*input, **kwargs) File "/home/faster-rcnn.pytorch/lib/model/faster_rcnn/faster_rcnn.py", line 50, in forward rois, rpn_loss_cls, rpn_loss_bbox = self.RCNN_rpn(base_feat, im_info, gt_boxes, num_boxes) File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 491, in __call__ result = self.forward(*input, **kwargs) File "/home/faster-rcnn.pytorch/lib/model/rpn/rpn.py", line 87, in forward rpn_data = self.RPN_anchor_target((rpn_cls_score.data, gt_boxes, im_info, num_boxes)) File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 491, in __call__ result = self.forward(*input, **kwargs) File "/home/faster-rcnn.pytorch/lib/model/rpn/anchor_target_layer.py", line 157, in forward positive_weights = 1.0 / num_examples File "/usr/local/lib/python2.7/dist-packages/torch/tensor.py", line 320, in __rdiv__ return self.reciprocal() * other RuntimeError: reciprocal is not implemented for type torch.cuda.LongTensor Exception NameError: "global name 'FileNotFoundError' is not defined" in <bound method _DataLoaderIter.__del__ of <torch.utils.data.dataloader._DataLoaderIter object at 0x7fb842e6e3d0>> ignored

@kebijuelun Use Pytorch 0.3.0 version. It will solve the problem.

@R1234A Thank you. This solution works for me.

@kebijuelun @R1234A how you guys switch back to Pytorch V0.3 when you already installed version 0.4

I also encounter this error used pytorch0.4, I fixed this error as follow:
num_examples=num_examples.type(torch.cuda.FloatTensor)
positive_weights =torch.div( torch.tensor(1.0).type(torch.cuda.FloatTensor),num_examples)
negative_weights =torch.div(torch.tensor(1.0).type(torch.cuda.FloatTensor),num_examples)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gullalc picture gullalc  路  4Comments

gayathrimahalingam picture gayathrimahalingam  路  3Comments

Feiyu-Zhang picture Feiyu-Zhang  路  5Comments

Gr1tee picture Gr1tee  路  4Comments

MathewXiren picture MathewXiren  路  5Comments