728x90
반응형

 

 

mmdetection 으로부터 학습한 딥러닝 모델을 ONNX 모델로 변환하고, TensorRT 로 변환하는 과정에서

아래와 같이 importTopK 레이어(노드)를 TensorRT 에서 인식을 못하여 변환이 안되는 문제가 발생하였다. 

 

In node -1 (importTopK): UNSUPPORTED_NODE: Assertion failed: inputs.at(1).is_weights()

 

ERROR: builtin_op_importers.cpp:3455 In function importTopK:
[8] Assertion failed: inputs.at(1).is_weights()

 

 

 

mmdetection 에서는 아래와 같이 여러 TensorRT Plugin 을 제공하고 있다. 아마 이 플러그인들을 처리하는 과정에서 importTopK 노드를 처리하는 것 같다. 그리고 참고로 mmdetection 에서는 object detection 의 NMS 과정을 플러그인으로 처리하고 있기 때문에, NMS 과정을 CPU 에서 연산하지 않아도 된다는 장점이 있다. 

 

 

 

따라서 pytorch2onnx.py 를 실행하기 전에 아래와 같이 ONNX backend 의 path 를 export 해주어야한다.

(물론 그 전에 TensorRT 를 포함하여 mmcv를 빌드해야한다. )

 

export ONNX_BACKEND=MMCVTensorRT

 

 

그럼 아래와 같은 문제는 사라진다. 

Assertion failed: inputs.at(1).is_weights()

 

 

참고로 mmcv 의 TensorRT를 빌드하는 과정은 아래와 같다. 

 

 

이미 TensorRT(python version)가 설치되어 있다면, path export 만 해주고, build 하면 될 것 같다. 

$ cd mmcv # to MMCV root directory
$ MMCV_WITH_OPS=1 MMCV_WITH_TRT=1 pip install -e .

 

 

 

 

 

 

 

참고자료 1 : https://github.com/open-mmlab/mmdetection/issues/5033

 

TensorRT conversion error for faster_rcnn_r50 · Issue #5033 · open-mmlab/mmdetection

Pretty much duplicate of this issue, but the offered solutions do not work I think (and the problem still persists). I installed mmcv with plugins as described in docs. assert is_tensorrt_plugin_lo...

github.com

 

참고자료 2 : https://github.com/open-mmlab/mmdetection/issues/5383

 

[Nvidia Jetson] Different NMS in ONNX and MMCV plugins · Issue #5383 · open-mmlab/mmdetection

My goal is to use YoloV3 in TensorRT on Nvidia Jetson I use YoloV3 https://github.com/open-mmlab/mmdetection/blob/master/configs/yolo/yolov3_d53_mstrain-608_273e_coco.py python tools/deployment/pyt...

github.com

 

728x90
반응형