*** TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
I suspect it is due to the update of numpy, which changes the behavior of np.array function. Now I use numpy 1.20.0, and I have tried using an earlier version of numpy like 1.19.1 but then there will be another error like this https://github.com/open-mmlab/mmdetection3d/issues/301.
Currently I can solve this error by
device = heatmaps[0][0].device
heatmaps = [[y.cpu() for y in x] for x in heatmaps]
heatmaps = np.array(heatmaps).transpose(1, 0).tolist()
heatmaps = [torch.stack(hms_).to(device) for hms_ in heatmaps]
but it may increase the training time since it brings memory copy between CPU and GPU. Could you please share your numpy and mmpycocotools version or other solutions to this problem?
2. You may add addition that may be helpful for locating the problem, such as
- How you installed PyTorch [e.g., pip, conda, source]
- Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)
Describe the bug
When training using CenterPoint, it will raise an error at L404 https://github.com/open-mmlab/mmdetection3d/blob/391a56b6af48f5056a769c4cd18dfac2a67c6c06/mmdet3d/models/dense_heads/centerpoint_head.py#L402-L405 The error message is
I suspect it is due to the update of
numpy
, which changes the behavior ofnp.array
function. Now I use numpy 1.20.0, and I have tried using an earlier version of numpy like1.19.1
but then there will be another error like this https://github.com/open-mmlab/mmdetection3d/issues/301.Currently I can solve this error by
but it may increase the training time since it brings memory copy between CPU and GPU. Could you please share your
numpy
andmmpycocotools
version or other solutions to this problem?Reproduction
Environment
python mmdet3d/utils/collect_env.py
to collect necessary environment infomation and paste it here.TorchVision: 0.7.0 OpenCV: 4.5.1 MMCV: 1.2.5 MMCV Compiler: GCC 7.3 MMCV CUDA Compiler: 10.2 MMDetection: 2.10.0 MMDetection3D: 0.11.0+391a56b