garrickbrazil / M3D-RPN

MIT License
261 stars 67 forks source link

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

Open fglks opened 3 years ago

fglks commented 3 years ago

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 commented 3 years ago

what should i do to solve it?

imprashr commented 3 years ago

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().

gizem-buss commented 3 years ago

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

pkraison commented 3 years ago

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

gizem-buss commented 3 years ago

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

rburridge92 commented 3 years ago

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