M3D-RPN icon indicating copy to clipboard operation
M3D-RPN copied to clipboard

TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

Open fglks opened this issue 4 years ago • 6 comments

python scripts/train_rpn_3d.py --config=kitti_3d_multi_warmup:

Traceback (most recent call last): File "scripts/train_rpn_3d.py", line 196, in main(sys.argv[1:]) File "scripts/train_rpn_3d.py", line 125, in main det_loss, det_stats = criterion_det(cls, prob, bbox_2d, bbox_3d, imobjs, feat_size) File "/home/user/anaconda3/envs/M3DRPN/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, **kwargs) File "/home/user/yty/M3D-RPN-master/lib/loss/rpn_3d.py", line 126, in forward src_anchors = self.anchors[rois[:, 4].type(torch.cuda.LongTensor), :] File "/home/user/anaconda3/envs/M3DRPN/lib/python3.6/site-packages/torch/tensor.py", line 486, in array return self.numpy() TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

fglks avatar Sep 23 '20 08:09 fglks

what should i do to solve it?

fglks avatar Sep 23 '20 08:09 fglks

do a bit of debugging and check which tensor is causing this error. just take that variable and apply variable_name.numpy() or variable_name.cpu().data.numpy().

imprashr avatar Sep 23 '20 14:09 imprashr

I meet the same problem.Do you have some solution to solve it?

gizem-buss avatar Dec 16 '20 14:12 gizem-buss

@gizem-buss hey, go through the way I wrote, it 'll help

pkraison avatar Dec 17 '20 05:12 pkraison

@pkraison I could not find your way. where is the way you mentioned?

gizem-buss avatar Dec 17 '20 13:12 gizem-buss

I have the same problem, after a bit of debugging I still can't figure it out. Is there a solution to this?

rburridge92 avatar Mar 03 '21 11:03 rburridge92