Closed sylivahf closed 1 year ago
@sylivahf hi A1: you model config and ckpt are not matched A2: the shape of deploy cfg and input_img and test_img should be aligned.
tested ok with this scripts:
python3 ./tools/deploy.py \
configs/mmdet3d/voxel-detection/voxel-detection_tensorrt_dynamic-nus-20x5.py \
../mmdetection3d/configs/centerpoint/centerpoint_pillar02_second_secfpn_head-circlenms_8xb4-cyclic-20e_nus-3d.py \
"../mmdeploy_checkpoints/mmdet3d/centerpoint/centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus_20220811_031844-191a3822.pth" \
"tests/data/n008-2018-08-01-15-16-36-0400__LIDAR_TOP__1533151612397179.pcd.bin" \
--work-dir "../workdir/test_mmdet3d/mmdet3d/centerpoint/tensorrt/static/fp32/centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus_20220811_031844-191a3822" \
--device cuda:0 \
--log-level INFO \
--test-img tests/data/n008-2018-08-01-15-16-36-0400__LIDAR_TOP__1533151612397179.pcd.bin
@RunningLeon Thanks for your answer. my main problem is that the pth model that downloaded did not match onnx.
now, I converted onnx and trt based on the downloaded centerpoint_pillar_nuscenes, but when I inferred trt, the result was empty. Traceability finds the empty result returned directly when TRT inference. (question)
pth and onnx, trt result as follows: (./mmdetection3d/tests/data/nuscenes/sweeps/LIDAR_TOP/n008-2018-09-18-12-07-26-0400__LIDAR_TOP__1537287083900561.pcd.bin) ======== torch模型推理 ============ bboxes: LiDARInstance3DBoxes( tensor([[-1.3145e+01, -5.9344e-01, -2.2842e+00, 3.6708e-01, 2.5209e+00, 8.3522e-01, -1.1192e-01, -1.9604e-09, -4.6045e-10], [-1.3050e+01, 9.7002e-01, -2.3780e+00, 4.3426e-01, 3.1145e+00, 8.7034e-01, -1.1072e-01, -1.9604e-09, -4.6045e-10], [-1.7004e-01, -4.0453e-01, -9.8386e-01, 4.6877e-01, 4.9995e-01, 1.2595e+00, 3.0697e-01, -1.5224e-04, -7.4921e-05]], device='cuda:0')) scores: tensor([0.2247, 0.2155, 0.3161], device='cuda:0') labels: tensor([5, 5, 9], device='cuda:0', dtype=torch.int32) ======== onnx模型推理 ============ bboxes: LiDARInstance3DBoxes( tensor([[-1.3144e+01, -5.9194e-01, -2.2820e+00, 3.6647e-01, 2.5214e+00, 8.2906e-01, -1.1093e-01, -1.9604e-09, -4.6045e-10], [-1.3051e+01, 9.6715e-01, -2.3750e+00, 4.3467e-01, 3.1164e+00, 8.6940e-01, -1.1152e-01, -1.9604e-09, -4.6045e-10], [-1.7019e-01, -4.0463e-01, -9.8242e-01, 4.6757e-01, 4.9867e-01, 1.2611e+00, 3.2327e-01, -1.5310e-04, -7.2168e-05]])) scores: tensor([0.2223, 0.2106, 0.3128]) labels: tensor([5, 5, 9], dtype=torch.int32) ======== trt模型推理 ============ 06/25 16:15:27 - mmengine - INFO - Successfully loaded tensorrt plugins from /home/mmdeploy/mmdeploy/lib/libmmdeploy_tensorrt_ops.so 06/25 16:15:27 - mmengine - INFO - Successfully loaded tensorrt plugins from /home/mmdeploy/mmdeploy/lib/libmmdeploy_tensorrt_ops.so <InstanceData(
META INFORMATION
DATA FIELDS
bboxes_3d: LiDARInstance3DBoxes(
tensor([], device='cuda:0', size=(0, 9)))
labels_3d: tensor([], device='cuda:0', dtype=torch.int32)
scores_3d: tensor([], device='cuda:0')
) at 0x7fd1408fbc90>
and in torch2onnx and onnx2tensorrt,There are no errors。
Something wrong with inference of TensorRT engine. Could you test the trt engine with trtexec
provided by TensorRT? https://github.com/NVIDIA/TensorRT/tree/master/samples/trtexec#using-trtexec
Something wrong with inference of TensorRT engine. Could you test the trt engine with
trtexec
provided by TensorRT?https://github.com/NVIDIA/TensorRT/tree/master/samples/trtexec#using-trtexec
@RunningLeon Thank you for your prompt reply.
I follow the link you gave to test the trt engine and show pass. the main information: [06/27/2023-09:19:58] [I] === Performance summary === [06/27/2023-09:19:58] [I] Throughput: 270.575 qps [06/27/2023-09:19:58] [I] Latency: min = 3.90543 ms, max = 5.56116 ms, mean = 4.17728 ms, median = 4.16284 ms, percentile(99%) = 4.27029 ms [06/27/2023-09:19:58] [I] Enqueue Time: min = 0.33667 ms, max = 0.988037 ms, mean = 0.51903 ms, median = 0.549469 ms, percentile(99%) = 0.697998 ms [06/27/2023-09:19:58] [I] H2D Latency: min = 0.03125 ms, max = 0.143127 ms, mean = 0.0362435 ms, median = 0.0357666 ms, percentile(99%) = 0.0424194 ms [06/27/2023-09:19:58] [I] GPU Compute Time: min = 3.40891 ms, max = 4.17584 ms, mean = 3.68487 ms, median = 3.67407 ms, percentile(99%) = 3.7796 ms [06/27/2023-09:19:58] [I] D2H Latency: min = 0.436798 ms, max = 1.79608 ms, mean = 0.456166 ms, median = 0.452148 ms, percentile(99%) = 0.468994 ms [06/27/2023-09:19:58] [I] Total Host Walltime: 3.0121 s [06/27/2023-09:19:58] [I] Total GPU Compute Time: 3.00317 s [06/27/2023-09:19:58] [I] Explanations of the performance metrics are printed in the verbose logs. [06/27/2023-09:19:58] [I] &&&& PASSED TensorRT.trtexec [TensorRT v8403] # trtexec --loadEngine=/home/mmdeploy/result/end2end.engine --shapes=voxels:1000x20x5,num_points:1000,coors:1000x4
Is there any possible reasons? I'm trying to build tensorrt8.4.3, mmdet3d1.1.0rc1 environment based on ubuntu20.04-cuda11.3-mmdeploy pulled by docker.
hi, if trtexec inference with dummy input is good, then should have non-empty result for trt inference in mmeploy. Could you double check the outputs from trt engine in here? https://github.com/open-mmlab/mmdeploy/blob/a5de11947891d6ef25a308785a55c700f88c8d74/mmdeploy/codebase/mmdet3d/deploy/voxel_detection_model.py#L92
hi, if trtexec inference with dummy input is good, then should have non-empty result for trt inference in mmeploy. Could you double check the outputs from trt engine in here?
@RunningLeon hi,'outputs = self.wrapper(input_dict) ' here some values of outputs are nan . I really check carefully in conda and docker environment, and input_dict is the same onnx‘s inputs.
I'm going to try cuda10.2, hope to fixe the issue.
@sylivahf hi, maybe you could test with different pytorch(1.8-2.0) and tensorrt(8.2-8.6) and see if there's a good combination.
@sylivahf hi, maybe you could test with different pytorch(1.8-2.0) and tensorrt(8.2-8.6) and see if there's a good combination.
@RunningLeon Okay, maybe I'll try it later.
Now,i can deploy and infer pointpillars on cuda10.2+tensorrt8.4.3.1+onnxruntime1.8.1。
But i have a new question:I trained the model with mmdet3d:1.0.0rc4, and now mmdeploy version is v0.9. If I want to convert and infer CenterPoint (pillar&dynamic_pillar) on an existing mmdeploy(v0.9), can i refer mmdeploy: v0.11.0 to modify the local mmdeploy: v0.9?
suggest upgrading to v0.11.0.
suggest upgrading to v0.11.0.
@RunningLeon Thank you for your help.
I refer to post-processing of mmdet3d:1.0.0rc4 for rewriting mmdeploy:v0.9 post-processing and have successfully inferred centerpoint_pillar. Next, i will try centerpoint_dynamic_pillar.
Do you have a successful inference of mmdet3d_engine model on CUDA11.x? If so, what is the specific version environment?
@sylivahf hi, maybe you could test with different pytorch(1.8-2.0) and tensorrt(8.2-8.6) and see if there's a good combination.
@RunningLeon Okay, maybe I'll try it later.
Now,i can deploy and infer pointpillars on cuda10.2+tensorrt8.4.3.1+onnxruntime1.8.1。
But i have a new question:I trained the model with mmdet3d:1.0.0rc4, and now mmdeploy version is v0.9. If I want to convert and infer CenterPoint (pillar&dynamic_pillar) on an existing mmdeploy(v0.9), can i refer mmdeploy: v0.11.0 to modify the local mmdeploy: v0.9?
@RunningLeon Dear , I found that you have infer pointpillar sucessfully, how about the version of mmdeploy you used When you used the below codebase versions: 06/15 20:35:38 - mmengine - INFO - **Codebase information** 06/15 20:35:38 - mmengine - INFO - mmdet: 3.0.0rc1 06/15 20:35:38 - mmengine - INFO - mmseg: 1.0.0rc0 06/15 20:35:38 - mmengine - INFO - mmpretrain: None 06/15 20:35:38 - mmengine - INFO - mmocr: None 06/15 20:35:38 - mmengine - INFO - mmagic: None 06/15 20:35:38 - mmengine - INFO - mmdet3d: 1.1.0rc1 06/15 20:35:38 - mmengine - INFO - mmpose: None 06/15 20:35:38 - mmengine - INFO - mmrotate: None 06/15 20:35:38 - mmengine - INFO - mmaction: None 06/15 20:35:38 - mmengine - INFO - mmrazor: None
Thank you very much
Okay, so after a few workdays here is what I can confirm:
For all tests I used mim install "mmengine>=0.7.1" "mmcv>=2.0.0" "mmdet>=3.0.0"
and mmdet3d==1.2.0
+ mmdeploy==1.2.0
Pointpillars returns an empty result -> I didn't further investigate as I am mainly interested in Centerpoint
I could get Centerpoint to run. The TRT engine produces outputs. However, there are some index errors probably coming from voxel_detection_model.py
and it seems that instead of cls_score
, bbox_pred
and dir_cls_pred
the outs
var in postprocess
has the keys cls_score0
, bbox_pred0
, ...
I tried several different combinations of CUDA11 + TRT but could not get them correctly running.
Unfortunately, even the GPU/Release container of this mmdeploy doesn't work as it runs into the TensorRT 8.2 issue. Which is discussed in other github issues + is mentioned in the docs.
As @sylivahf described, CUDA 10.2 + TRT 8.4 works with pointpillars. Regarding Centerpoint I run into the same index issues.
However it was a stuggle to create a Dockerfile that supports this. The official CUDA 10.2 images are not on dockerhub anymore as Ubuntu 18.04 reached its end of life.
Furthermore, this is not a solution for me (and probably also not for others) as CUDA 10.2 is NOT maintained by newer GPUs anymore. Even while I have an RTX2080 which still supports CUDA 10.2, the GPU I actually intend to use requires at least CUDA 11.
I have the feeling that this is a bigger strugges as it should be. IMO this is mainly due to the fact that the official docker container DOES NOT work with mmdetection3d due to the TRT 8.2 bug.
So I think it the best idea maybe is to create a separate new docker container (using CUDA > 11) where mmdet3d runs with centerpoint AND pointpillars. I am willing to help in this regard. However, as I don't have TRT experience I am struggling to debug the issues mentioned above.
@RunningLeon do you know anyone of the team who could help?
@MarvinKlemp hi, for cuda11.3, have you tried mmdeploy docker image openmmlab/mmdeploy:ubuntu20.04-cuda11.3-mmdeploy
+ TensorRT-8.4.1.5.Linux.x86_64-gnu.cuda-11.6.cudnn8.4.tar.gz
?
@JunLFang My environment is : 2023-07-12 21:58:59,166 - mmdeploy - INFO - TorchVision: 0.9.2+cu102 2023-07-12 21:58:59,166 - mmdeploy - INFO - OpenCV: 4.5.5 2023-07-12 21:58:59,167 - mmdeploy - INFO - MMCV: 1.5.3 2023-07-12 21:58:59,167 - mmdeploy - INFO - MMCV Compiler: GCC 7.5 2023-07-12 21:58:59,167 - mmdeploy - INFO - MMCV CUDA Compiler: 10.2 2023-07-12 21:58:59,167 - mmdeploy - INFO - MMDeploy: 0.9.0+unknown 2023-07-12 21:58:59,167 - mmdeploy - INFO -
2023-07-12 21:58:59,167 - mmdeploy - INFO - **Backend information** 2023-07-12 21:59:02,964 - mmdeploy - INFO - onnxruntime: 1.8.1 ops_is_avaliable : True 2023-07-12 21:59:03,039 - mmdeploy - INFO - tensorrt: 8.4.3.1 ops_is_avaliable : True 2023-07-12 21:59:03,073 - mmdeploy - INFO - ncnn: None ops_is_avaliable : False 2023-07-12 21:59:03,077 - mmdeploy - INFO - pplnn_is_avaliable: False 2023-07-12 21:59:03,088 - mmdeploy - INFO - openvino_is_avaliable: False 2023-07-12 21:59:03,101 - mmdeploy - INFO - snpe_is_available: False 2023-07-12 21:59:03,134 - mmdeploy - INFO - ascend_is_available: False 2023-07-12 21:59:03,158 - mmdeploy - INFO - coreml_is_available: False 2023-07-12 21:59:03,158 - mmdeploy - INFO -
2023-07-12 21:59:03,159 - mmdeploy - INFO - **Codebase information** 2023-07-12 21:59:03,342 - mmdeploy - INFO - mmdet: 2.24.0 2023-07-12 21:59:03,342 - mmdeploy - INFO - mmseg: 0.20.0 2023-07-12 21:59:03,342 - mmdeploy - INFO - mmcls: None 2023-07-12 21:59:03,342 - mmdeploy - INFO - mmocr: None 2023-07-12 21:59:03,342 - mmdeploy - INFO - mmedit: None 2023-07-12 21:59:03,343 - mmdeploy - INFO - mmdet3d: 1.0.0rc4 2023-07-12 21:59:03,343 - mmdeploy - INFO - mmpose: None 2023-07-12 21:59:03,343 - mmdeploy - INFO - mmrotate: None
Note, about centerpoint_pillar, i have changed post-process on mmdeploy codebase.
@MarvinKlemp About CUDA 10.2 images, i pull nvidia/cuda: 10.2-cudnn8-devel-ubuntu18.04 on RTX 2080 Ti, then i create a container and install package needed.
I have tried mmdeploy docker image openmmlab/mmdeploy:ubuntu20.04-cuda11.3-mmdeploy, but TRT engine outputs are empty .
@sylivahf nvidia/cuda: 10.2-cudnn8-devel-ubuntu18.04 doesnt exists anymore as 18.04 reached its EOL https://hub.docker.com/layers/nvidia/cuda/10.2-cudnn8-devel-ubuntu18.04/
Maybe you still have it locally and can pull it. But I created a container with 10.2 myself and got it running.
@RunningLeon
This should be a minimal Dockerfile to reproduce the indexing error. You only require the TensorRT-8.4.3.1.Linux.x86_64-gnu.cuda-11.6.cudnn8.4.tar.gz
in your current directory.
FROM openmmlab/mmdeploy:ubuntu20.04-cuda11.3-mmdeploy
# install TRT 8.4.3.1
COPY ./TensorRT-8.4.3.1.Linux.x86_64-gnu.cuda-11.6.cudnn8.4.tar.gz /root/workspace
RUN tar -xvf TensorRT-8.4.3.1.Linux.x86_64-gnu.cuda-11.6.cudnn8.4.tar.gz
RUN pip install TensorRT-8.4.3.1/python/tensorrt-8.4.3.1-cp38-none-linux_x86_64.whl
ENV TENSORRT_DIR=/root/workspace/TensorRT-8.4.3.1
ENV LD_LIBRARY_PATH=/root/workspace/TensorRT-8.4.3.1/lib:$LD_LIBRARY_PATH
# install mmdet3d + configs
RUN git clone https://github.com/open-mmlab/mmdetection3d.git -b v1.2.0 /root/workspace/mmdetection3d
RUN mim install "mmdet3d==1.2.0"
# Fix Error:
# mmengine 0.7.4 is not comppatible with mmdeploy 1.2.0/ mmdet3d 1.2.0
RUN mim install "mmengine==0.8.0"
# get weights from mmdet3d for centerpoint
RUN wget -P/root/workspace/weights https://download.openmmlab.com/mmdetection3d/v1.0.0_models/centerpoint/centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus/centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus_20220811_031844-191a3822.pth
ENV CUDA_VISIBLE_DEVICES=0
WORKDIR /root/workspace/mmdeploy
# Fix Error:
# 2023-07-14:07:39:00 - root - ERROR - Input shape should be between (5000, 20, 5) and (30000, 20, 5) but get (101, 20, 5).
RUN sed -i "s/5000,/50,/" /root/workspace/mmdeploy/configs/mmdet3d/voxel-detection/voxel-detection_tensorrt_dynamic-nus-20x5.py
RUN sed -i "s/5000],/50],/" /root/workspace/mmdeploy/configs/mmdet3d/voxel-detection/voxel-detection_tensorrt_dynamic-nus-20x5.py
# generate engine
RUN python3 tools/deploy.py --device="cuda" configs/mmdet3d/voxel-detection/voxel-detection_tensorrt_dynamic-nus-20x5.py \
/root/workspace/mmdetection3d/configs/centerpoint/centerpoint_pillar02_second_secfpn_head-circlenms_8xb4-cyclic-20e_nus-3d.py \
/root/workspace/weights/centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus_20220811_031844-191a3822.pth \
/root/workspace/mmdetection3d/tests/data/nuscenes/sweeps/LIDAR_TOP/n008-2018-09-18-12-07-26-0400__LIDAR_TOP__1537287083900561.pcd.bin \
--work-dir /root/workspace/centerpoint
What I always thought is stange is the two sed -i
commands I have to run.
This is for changing the default config so it works with the test pointcloud from mmdet3d
The error is actually the same as with CUDA 12. (Some indexing issues regarding outs
in voxel_detection_model::postprocess
)
Error:
2023-07-14:07:42:58 - root - ERROR - list indices must be integers or slices, not tuple
Traceback (most recent call last):
File "/root/workspace/mmdeploy/mmdeploy/utils/utils.py", line 41, in target_wrapper
result = target(*args, **kwargs)
File "/root/workspace/mmdeploy/mmdeploy/apis/visualize.py", line 72, in visualize_model
result = model.test_step(model_inputs)[0]
File "/usr/local/lib/python3.8/dist-packages/mmengine/model/base_model/base_model.py", line 145, in test_step
return self._run_forward(data, mode='predict') # type: ignore
File "/usr/local/lib/python3.8/dist-packages/mmengine/model/base_model/base_model.py", line 340, in _run_forward
results = self(**data, mode=mode)
File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/root/workspace/mmdeploy/mmdeploy/codebase/mmdet3d/deploy/voxel_detection_model.py", line 104, in forward
prediction = VoxelDetectionModel.postprocess(
File "/root/workspace/mmdeploy/mmdeploy/codebase/mmdet3d/deploy/voxel_detection_model.py", line 273, in postprocess
batch_heatmap = cls_score[:,
TypeError: list indices must be integers or slices, not tuple
@MarvinKlemp hi, could get the Tensor element from the list to Tensor for centerpoint after this line: https://github.com/open-mmlab/mmdeploy/blob/0a8cbe2286dcb226f3140d0bae8700cdfaf37a47/mmdeploy/codebase/mmdet3d/deploy/voxel_detection_model.py#L259
cls_score = cls_score[0]
bbox_pred = bbox_pred[0]
dir_cls_pred = dir_cls_pred[0]
Thats more or less what I used to fix the error. However, with this I get the same issue as with CUDA 12: The outputs are empty.
I added your fix to the Dockerfile. Do you get outputs?
FROM openmmlab/mmdeploy:ubuntu20.04-cuda11.3-mmdeploy
COPY ./TensorRT-8.4.3.1.Linux.x86_64-gnu.cuda-11.6.cudnn8.4.tar.gz /root/workspace
RUN tar -xvf TensorRT-8.4.3.1.Linux.x86_64-gnu.cuda-11.6.cudnn8.4.tar.gz
RUN pip install TensorRT-8.4.3.1/python/tensorrt-8.4.3.1-cp38-none-linux_x86_64.whl
ENV TENSORRT_DIR=/root/workspace/TensorRT-8.4.3.1
ENV LD_LIBRARY_PATH=/root/workspace/TensorRT-8.4.3.1/lib:$LD_LIBRARY_PATH
RUN git clone https://github.com/open-mmlab/mmdetection3d.git -b v1.1.1 /root/workspace/mmdetection3d
RUN mim install "mmdet3d==1.2.0"
# Fix Error:
# mmengine 0.7.4 is not comppatible with mmdeploy 1.2.0/ mmdet3d 1.2.0
RUN mim install "mmengine==0.8.0"
RUN wget -P/root/workspace/weights https://download.openmmlab.com/mmdetection3d/v1.0.0_models/centerpoint/centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus/centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus_20220811_031844-191a3822.pth
ENV CUDA_VISIBLE_DEVICES=0
WORKDIR /root/workspace/mmdeploy
# Fix Error:
# 2023-07-14:07:39:00 - root - ERROR - Input shape should be between (5000, 20, 5) and (30000, 20, 5) but get (101, 20, 5).
RUN sed -i "s/5000,/50,/" /root/workspace/mmdeploy/configs/mmdet3d/voxel-detection/voxel-detection_tensorrt_dynamic-nus-20x5.py
RUN sed -i "s/5000],/50],/" /root/workspace/mmdeploy/configs/mmdet3d/voxel-detection/voxel-detection_tensorrt_dynamic-nus-20x5.py
# Fix Index Error
COPY ./voxel_detection_model.py /root/workspace/mmdeploy/mmdeploy/codebase/mmdet3d/deploy/voxel_detection_model.py
# Create TRT Engine
RUN python3 tools/deploy.py --device="cuda" configs/mmdet3d/voxel-detection/voxel-detection_tensorrt_dynamic-nus-20x5.py \
/root/workspace/mmdetection3d/configs/centerpoint/centerpoint_pillar02_second_secfpn_head-circlenms_8xb4-cyclic-20e_nus-3d.py \
/root/workspace/weights/centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus_20220811_031844-191a3822.pth \
/root/workspace/mmdetection3d/tests/data/nuscenes/sweeps/LIDAR_TOP/n008-2018-09-18-12-07-26-0400__LIDAR_TOP__1537287083900561.pcd.bin \
--work-dir /root/workspace/centerpoint
# Run TRT Engine
RUN mim install "mmdeploy==1.2.0"
COPY run.py /root/workspace/mmdeploy/run.py
RUN python3 run.py
run.py
from mmdeploy.apis.utils import build_task_processor
from mmdeploy.utils import get_input_shape, load_config
import torch
if __name__ == "__main__":
base = "/root/workspace"
deploy_cfg = f'{base}/mmdeploy/configs/mmdet3d/voxel-detection/voxel-detection_tensorrt_dynamic-nus-20x5.py'
model_cfg = f'{base}/mmdetection3d/configs/centerpoint/centerpoint_pillar02_second_secfpn_head-circlenms_8xb4-cyclic-20e_nus-3d.py'
device = 'cuda:0'
backend_model = [f'{base}/centerpoint/end2end.engine']
image = f'{base}/mmdetection3d/tests/data/nuscenes/sweeps/LIDAR_TOP/n008-2018-09-18-12-07-26-0400__LIDAR_TOP__1537287083900561.pcd.bin'
deploy_cfg, model_cfg = load_config(deploy_cfg, model_cfg)
task_processor = build_task_processor(model_cfg, deploy_cfg, device)
model = task_processor.build_backend_model(backend_model)
input_shape = get_input_shape(deploy_cfg)
model_inputs, _ = task_processor.create_input(image, input_shape)
# do model inference
with torch.no_grad():
result = model.test_step(model_inputs)
print(result)
print(result[0].pred_instances_3d)
print(len(result[0].pred_instances_3d))
Output of python3 run.py
root@b21d53d40404:~/workspace/mmdeploy# python3 run.py
/usr/local/lib/python3.8/dist-packages/mmdet3d/evaluation/functional/kitti_utils/eval.py:10: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
def get_thresholds(scores: np.ndarray, num_gt, num_sample_pts=41):
07/14 10:55:10 - mmengine - WARNING - Failed to search registry with scope "mmdet3d" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmdet3d" is a correct scope, or whether the registry is initialized.
07/14 10:55:10 - mmengine - WARNING - Failed to search registry with scope "mmdet3d" in the "mmdet3d_tasks" registry tree. As a workaround, the current "mmdet3d_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmdet3d" is a correct scope, or whether the registry is initialized.
07/14 10:55:10 - mmengine - WARNING - Failed to search registry with scope "mmdet3d" in the "backend_voxel_detectors" registry tree. As a workaround, the current "backend_voxel_detectors" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmdet3d" is a correct scope, or whether the registry is initialized.
07/14 10:55:10 - mmengine - INFO - Successfully loaded tensorrt plugins from /root/workspace/mmdeploy/mmdeploy/lib/libmmdeploy_tensorrt_ops.so
07/14 10:55:10 - mmengine - INFO - Successfully loaded tensorrt plugins from /root/workspace/mmdeploy/mmdeploy/lib/libmmdeploy_tensorrt_ops.so
[07/14/2023-10:55:12] [TRT] [W] TensorRT was linked against cuDNN 8.4.1 but loaded cuDNN 8.2.0
[07/14/2023-10:55:12] [TRT] [W] TensorRT was linked against cuDNN 8.4.1 but loaded cuDNN 8.2.0
/usr/local/lib/python3.8/dist-packages/mmdet3d/models/task_modules/coders/centerpoint_bbox_coders.py:207: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
self.post_center_range = torch.tensor(
/usr/local/lib/python3.8/dist-packages/mmdet3d/models/task_modules/coders/centerpoint_bbox_coders.py:207: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
self.post_center_range = torch.tensor(
[<Det3DDataSample(
META INFORMATION
box_mode_3d: <Box3DMode.LIDAR: 0>
transformation_3d_flow: ['R', 'S', 'T']
pcd_vertical_flip: False
pcd_trans: array([0., 0., 0.])
axis_align_matrix: array([[1., 0., 0., 0.],
[0., 1., 0., 0.],
[0., 0., 1., 0.],
[0., 0., 0., 1.]])
box_type_3d: <class 'mmdet3d.structures.bbox_3d.lidar_box3d.LiDARInstance3DBoxes'>
lidar_path: '/root/workspace/mmdetection3d/tests/data/nuscenes/sweeps/LIDAR_TOP/n008-2018-09-18-12-07-26-0400__LIDAR_TOP__1537287083900561.pcd.bin'
pcd_horizontal_flip: False
pcd_rotation: tensor([[1., 0., 0.],
[-0., 1., 0.],
[0., 0., 1.]])
pcd_rotation_angle: 0.0
pcd_scale_factor: 1.0
flip: False
DATA FIELDS
pred_instances: <InstanceData(
META INFORMATION
DATA FIELDS
) at 0x7fb3121d4fd0>
gt_instances_3d: <InstanceData(
META INFORMATION
DATA FIELDS
) at 0x7fb3121d4ee0>
gt_instances: <InstanceData(
META INFORMATION
DATA FIELDS
) at 0x7fb3354b79a0>
eval_ann_info: None
pred_instances_3d: <InstanceData(
META INFORMATION
DATA FIELDS
scores_3d: tensor([], device='cuda:0')
labels_3d: tensor([], device='cuda:0', dtype=torch.int32)
bboxes_3d: LiDARInstance3DBoxes(
tensor([], device='cuda:0', size=(0, 9)))
) at 0x7fb3121d4df0>
gt_pts_seg: <PointData(
META INFORMATION
DATA FIELDS
) at 0x7fb3148c86a0>
) at 0x7fb3121d4f10>]
<InstanceData(
META INFORMATION
DATA FIELDS
scores_3d: tensor([], device='cuda:0')
labels_3d: tensor([], device='cuda:0', dtype=torch.int32)
bboxes_3d: LiDARInstance3DBoxes(
tensor([], device='cuda:0', size=(0, 9)))
) at 0x7fb3121d4df0>
0
changed voxel_detection_model.py (your changes cls_score = cls_core[0]...
)
(click details to see fully)
@MarvinKlemp hi, sorry for the trouble. I've reproduced the problem and the result was empty. I'll check if there's any workaround for cuda11.x. BTW, have you tried with cuda10.2+trt8.4?
Cuda 10.2 + TRT 8.4 also suffers from the index issues + empty results (For CenterPoint). It looks like PointPillars works with 10.2/8.4)
@JunLFang My environment is : 2023-07-12 21:58:59,166 - mmdeploy - INFO - TorchVision: 0.9.2+cu102 2023-07-12 21:58:59,166 - mmdeploy - INFO - OpenCV: 4.5.5 2023-07-12 21:58:59,167 - mmdeploy - INFO - MMCV: 1.5.3 2023-07-12 21:58:59,167 - mmdeploy - INFO - MMCV Compiler: GCC 7.5 2023-07-12 21:58:59,167 - mmdeploy - INFO - MMCV CUDA Compiler: 10.2 2023-07-12 21:58:59,167 - mmdeploy - INFO - MMDeploy: 0.9.0+unknown 2023-07-12 21:58:59,167 - mmdeploy - INFO -
2023-07-12 21:58:59,167 - mmdeploy - INFO - Backend information 2023-07-12 21:59:02,964 - mmdeploy - INFO - onnxruntime: 1.8.1 ops_is_avaliable : True 2023-07-12 21:59:03,039 - mmdeploy - INFO - tensorrt: 8.4.3.1 ops_is_avaliable : True 2023-07-12 21:59:03,073 - mmdeploy - INFO - ncnn: None ops_is_avaliable : False 2023-07-12 21:59:03,077 - mmdeploy - INFO - pplnn_is_avaliable: False 2023-07-12 21:59:03,088 - mmdeploy - INFO - openvino_is_avaliable: False 2023-07-12 21:59:03,101 - mmdeploy - INFO - snpe_is_available: False 2023-07-12 21:59:03,134 - mmdeploy - INFO - ascend_is_available: False 2023-07-12 21:59:03,158 - mmdeploy - INFO - coreml_is_available: False 2023-07-12 21:59:03,158 - mmdeploy - INFO -
2023-07-12 21:59:03,159 - mmdeploy - INFO - Codebase information 2023-07-12 21:59:03,342 - mmdeploy - INFO - mmdet: 2.24.0 2023-07-12 21:59:03,342 - mmdeploy - INFO - mmseg: 0.20.0 2023-07-12 21:59:03,342 - mmdeploy - INFO - mmcls: None 2023-07-12 21:59:03,342 - mmdeploy - INFO - mmocr: None 2023-07-12 21:59:03,342 - mmdeploy - INFO - mmedit: None 2023-07-12 21:59:03,343 - mmdeploy - INFO - mmdet3d: 1.0.0rc4 2023-07-12 21:59:03,343 - mmdeploy - INFO - mmpose: None 2023-07-12 21:59:03,343 - mmdeploy - INFO - mmrotate: None
Note, about centerpoint_pillar, i have changed post-process on mmdeploy codebase.
@MarvinKlemp About CUDA 10.2 images, i pull nvidia/cuda: 10.2-cudnn8-devel-ubuntu18.04 on RTX 2080 Ti, then i create a container and install package needed.
I have tried mmdeploy docker image openmmlab/mmdeploy:ubuntu20.04-cuda11.3-mmdeploy, but TRT engine outputs are empty .
Thank you very much for your feedback, now I am trying the ponitpillar , some other error happend , anyway , Thank you for your help
@RunningLeon can I assist you in any way?
@RunningLeon hi, i have a new trouble【mmdeploy - ERROR - mmdeploy.apis.pytorch2onnx.torch2onnx
with Call id: 0 failed】 in converting centerpoint_dynamic_pillar.
Details are below:
2023-07-18 08:33:48,690 - mmdeploy - INFO - Export PyTorch model to ONNX: /mmdeploy/result_centerpoint_dynamic/end2end.onnx.
2023-07-18 08:33:48,713 - mmdeploy - WARNING - Can not find torch.nn.functional._scaled_dot_product_attention, function rewrite will not be applied
2023-07-18 08:33:48,714 - mmdeploy - WARNING - Can not find torch._C._jit_pass_onnx_deduplicate_initializers, function rewrite will not be applied
=======centerpoint_dynamic_pillars forward test!!!=======
/usr/local/lib/python3.6/dist-packages/mmcv/ops/scatter_points.py:114: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if coors.size(-1) == 3:
/usr/local/lib/python3.6/dist-packages/mmcv/ops/deform_conv.py:185: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if not all(map(lambda s: s > 0, output_size)):
/usr/local/lib/python3.6/dist-packages/mmcv/ops/deform_conv.py:89: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
cur_im2col_step = min(ctx.im2col_step, input.size(0))
/usr/local/lib/python3.6/dist-packages/mmcv/ops/deform_conv.py:91: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
) == 0, 'batch size must be divisible by im2col_step'
Process Process-2:
Traceback (most recent call last):
File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
ret = func(*args, **kwargs)
File "/mmdeploy/mmdeploy/apis/pytorch2onnx.py", line 110, in torch2onnx
optimize=optimize)
File "/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 356, in _wrap
return self.call_function(func_name_, *args, **kwargs)
File "/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 326, in call_function
return self.call_function_local(func_name, *args, **kwargs)
File "/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 275, in call_function_local
return pipe_caller(*args, **kwargs)
File "/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
ret = func(*args, **kwargs)
File "/mmdeploy/mmdeploy/apis/onnx/export.py", line 132, in export
verbose=verbose)
File "/usr/local/lib/python3.6/dist-packages/torch/onnx/__init__.py", line 276, in export
custom_opsets, enable_onnx_checker, use_external_data_format)
File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 94, in export
use_external_data_format=use_external_data_format)
File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 701, in _export
dynamic_axes=dynamic_axes)
File "/mmdeploy/mmdeploy/core/rewriters/rewriter_utils.py", line 383, in wrapper
return self.func(self, *args, **kwargs)
File "/mmdeploy/mmdeploy/apis/onnx/optimizer.py", line 10, in model_to_graph__custom_optimizer
graph, params_dict, torch_out = ctx.origin_func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 468, in _model_to_graph
module=module)
File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 206, in _optimize_graph
graph = torch._C._jit_pass_onnx(graph, operator_export_type)
File "/usr/local/lib/python3.6/dist-packages/torch/onnx/__init__.py", line 309, in _run_symbolic_function
return utils._run_symbolic_function(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 997, in _run_symbolic_function
return symbolic_fn(g, *inputs, **attrs)
File "/usr/local/lib/python3.6/dist-packages/torch/onnx/symbolic_opset11.py", line 466, in constant_pad_nd
pad = _prepare_onnx_paddings(g, sym_help._get_tensor_rank(input), padding)
File "/mmdeploy/mmdeploy/core/rewriters/rewriter_utils.py", line 383, in wrapper
return self.func(self, *args, **kwargs)
File "/mmdeploy/mmdeploy/pytorch/ops/pad.py", line 32, in _prepare_onnx_paddings__tensorrt
return ctx.origin_func(g, input, pad)
File "/usr/local/lib/python3.6/dist-packages/torch/onnx/symbolic_opset11.py", line 445, in _prepare_onnx_paddings
extension = g.op("Sub", g.op("Mul", g.op("Constant", value_t=torch.tensor(dim, dtype=torch.int64)),
TypeError: an integer is required (got type NoneType)
(Occurred when translating constant_pad_nd).
2023-07-18 08:33:49,501 - mmdeploy - ERROR - `mmdeploy.apis.pytorch2onnx.torch2onnx` with Call id: 0 failed. exit.
I want to learn about rewriter function files, but i known nothing in mmdeploy.readthedocs. Do you have any guidance? Thank you for your interest and help.
@sylivahf hi, here's a short tutorial you can refer to.
This issue is marked as stale because it has been marked as invalid or awaiting response for 7 days without any further response. It will be closed in 5 days if the stale label is not removed or if there is no further response.
This issue is closed because it has been stale for 5 days. Please open a new issue if you have similar issues or you have any new updates now.
@sylivahf hi, maybe you could test with different pytorch(1.8-2.0) and tensorrt(8.2-8.6) and see if there's a good combination.
@RunningLeon Okay, maybe I'll try it later.
Now,i can deploy and infer pointpillars on cuda10.2+tensorrt8.4.3.1+onnxruntime1.8.1。
But i have a new question:I trained the model with mmdet3d:1.0.0rc4, and now mmdeploy version is v0.9. If I want to convert and infer CenterPoint (pillar&dynamic_pillar) on an existing mmdeploy(v0.9), can i refer mmdeploy: v0.11.0 to modify the local mmdeploy: v0.9?
Dear could share the dockerfile if you configure pointpillar env with docker , because I want to run pointpillar , but in cuda 11. the output is empty, I would like to try your configuration : cuda10.2+tensorrt8.4.3.1+onnxruntime1.8.1 Thank you very much
Checklist
Describe the bug
Q1: when load .pth file,print:The model and loaded state dict do not match exactly size mismatch for pts_voxel_encoder.pfn_layers.0.linear.weight: copying a param with shape torch.Size([64, 10]) from checkpoint, the shape in current model is torch.Size([64, 11]). Q2: results are not same. as follows: ======== torch模型推理 ============ bboxes: LiDARInstance3DBoxes( tensor([[-2.2048e+01, 4.5879e-01, -3.4730e+00, 5.5220e-01, 1.7534e+00, 1.0230e+00, -2.9996e+00, 6.4907e-09, -2.2300e-10], [-1.9456e+01, 2.7721e-01, -2.9449e+00, 4.9635e-01, 1.8013e+00, 1.0433e+00, 3.0218e+00, 6.4907e-09, -2.2300e-10], [-3.5420e+00, -2.5560e-01, -1.7169e+00, 1.5123e+00, 4.7465e-01, 1.1190e+00, 2.7349e+00, -1.2182e-09, -1.8843e-09], [-1.9399e+01, 3.0180e-01, -2.6115e+00, 2.0330e+00, 6.6581e-01, 1.3884e+00, 1.4075e+00, 1.4518e-02, 8.6695e-04], [-2.2165e+01, 5.3310e-01, -3.9107e+00, 2.0958e+00, 7.8873e-01, 1.6001e+00, -2.8884e-01, -1.6687e-05, 9.6859e-03], [-2.2057e+01, 1.1213e+00, -2.9663e+00, 6.6428e-01, 7.2668e-01, 1.8508e+00, 7.0642e-01, 4.0863e-02, 8.3566e-03], [-3.5352e+00, -1.4072e-01, -1.8142e+00, 6.2023e-01, 5.8055e-01, 1.7103e+00, -2.1606e+00, -1.1876e-03, 9.9198e-03], [-1.4823e+01, 4.4471e-01, -3.0109e+00, 6.4587e-01, 6.9740e-01, 1.8230e+00, 2.6232e+00, -1.4208e-09, -1.0301e-08]], device='cuda:0')) scores: tensor([0.1688, 0.1259, 0.1620, 0.1152, 0.1008, 0.1408, 0.1107, 0.1081], device='cuda:0') labels: tensor([5, 5, 7, 7, 6, 8, 8, 8], device='cuda:0', dtype=torch.int32)
======== onnx模型推理 ============ bboxes: LiDARInstance3DBoxes( tensor([[-1.3144e+01, -5.9227e-01, -2.2817e+00, 3.6645e-01, 2.5220e+00, 8.2899e-01, -1.1088e-01, -1.9604e-09, -4.6045e-10], [-1.3051e+01, 9.6707e-01, -2.3747e+00, 4.3470e-01, 3.1165e+00, 8.6941e-01, -1.1153e-01, -1.9604e-09, -4.6045e-10], [-1.7018e-01, -4.0455e-01, -9.8223e-01, 4.6753e-01, 4.9864e-01, 1.2611e+00, 3.2107e-01, -1.5343e-04, -7.2500e-05]])) scores: tensor([0.2222, 0.2105, 0.3128]) labels: tensor([5, 5, 9], dtype=torch.int32)
Q3: about .pth,executed again, the results are inconsistent. ======== torch模型推理 ============ bboxes: LiDARInstance3DBoxes( tensor([[-7.6455e+00, 1.2476e+00, -1.3899e+00, 8.5401e+00, 2.6876e+00, 3.4241e+00, 3.1323e+00, -4.9060e-10, 2.5482e-10], [-3.6816e+00, 2.8384e-01, -7.7362e-01, 2.0953e+00, 2.0531e+00, 3.2199e+00, 1.4697e+00, -1.6465e-09, 1.5545e-09], [-2.1928e+01, 4.8591e-01, -3.4773e+00, 3.9633e-01, 2.0722e+00, 8.9335e-01, 3.2418e-01, 6.4907e-09, -2.2300e-10], [-2.1966e+01, 6.0843e-01, -4.0183e+00, 2.0318e+00, 7.3325e-01, 1.4105e+00, 1.5185e+00, -1.4774e-02, -6.5357e-01], [-1.9332e+01, 2.8846e-01, -2.1425e+00, 1.9006e+00, 6.6670e-01, 1.2766e+00, 1.7748e+00, 2.3108e-03, 3.3878e-02], [-3.6679e+00, -2.1373e-01, -2.7283e-01, 2.0697e+00, 8.8521e-01, 1.5501e+00, 2.9671e+00, -1.2182e-09, -1.8843e-09], [-9.2660e+00, 2.3157e-01, -1.6942e+00, 6.6807e-01, 6.2215e-01, 1.7510e+00, -1.7736e+00, -4.5018e-03, -3.0482e-04], [-8.3196e+00, 2.0250e-01, -1.6046e+00, 6.5102e-01, 6.0909e-01, 1.7418e+00, -1.7251e+00, 3.9005e-04, 1.0049e-04], [-1.1603e+01, 5.7692e-01, -1.6174e+00, 6.4621e-01, 6.0476e-01, 1.7634e+00, -1.1972e+00, 2.0978e-02, -2.3189e-03]], device='cuda:0')) scores: tensor([0.1025, 0.5338, 0.1403, 0.2731, 0.1128, 0.1032, 0.1861, 0.1627, 0.1003], device='cuda:0') labels: tensor([2, 4, 5, 6, 6, 6, 8, 8, 8], device='cuda:0', dtype=torch.int32)
Reproduction
demo code : #
Environment
Error traceback
No response