open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.56k stars 9.46k forks source link

convert yolox to tensorrt,error occured #6313

Closed jiejie1993 closed 2 years ago

jiejie1993 commented 3 years ago

I have install onnxruntime and tensorrt in this command MMCV_WITH_OPS=1 MMCV_WITH_TRT=1 MMCV_WITH_ORT=1 pip install -e . and set env export ONNX_BACKEND=MMCVTensorRT. I have successfully verify the pipeline pth->onnx->trt in yolov3.

  1. successfully convert the yolox model to onnx in the following command:python tools/deployment/pytorch2onnx.py ../model_store/haiyangshengwu_Yolox_tiny_416/haiyangshengwu_Yolox_tiny_416.py ../model_store/haiyangshengwu_Yolox_tiny_416/latest.pth --output-file ../model_store/haiyangshengwu_Yolox_tiny_416/haiyangshengwu_Yolox_tiny_416.onnx --test-img /media/gyj/c1a9654c-8209-4be0-9416-e22679fc0040/1.datasets/2.object_detect/haiyangshengwu/JPEGImages/Angelas20201117_165705.217.jpg --shape 416
  2. but when I convert the onnx model into tensorrt in this command: python tools/deployment/onnx2tensorrt.py ../model_store/haiyangshengwu_Yolox_tiny_416/haiyangshengwu_Yolox_tiny_416.py ../model_store/haiyangshengwu_Yolox_tiny_416/haiyangshengwu_Yolox_tiny_416.onnx --trt-file ../model_store/haiyangshengwu_Yolox_tiny_416/haiyangshengwu_Yolox_tiny_416.trt --input-img demo/demo.jpg --shape 416 --verify error occured:Traceback (most recent call last): File "tools/deployment/onnx2tensorrt.py", line 254, in <module> verbose=args.verbose) File "tools/deployment/onnx2tensorrt.py", line 45, in onnx2tensorrt max_workspace_size=max_workspace_size) File "/home/gyj/software/mmcv/mmcv/tensorrt/tensorrt_utils.py", line 65, in onnx2trt raise RuntimeError(f'parse onnx failed:\n{error_msgs}') RuntimeError: parse onnx failed: In node -1 (importRange): UNSUPPORTED_NODE: Assertion failed: inputs.at(0).isInt32() && "For range operator with dynamic inputs, this version of TensorRT only supports INT32!"
hhaAndroid commented 3 years ago

@jiejie1993 Sorry, we haven't tested yolox on trt yet.