open-mmlab / mmdeploy

OpenMMLab Model Deployment Framework

Home Page:https://mmdeploy.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] /TopK This version of TensorRT only supports input K as an initializer.

fpeanut opened this issue · comments

Checklist

  • I have searched related issues but cannot get the expected help.
  • 2. I have read the FAQ documentation but cannot get the expected help.
  • 3. The bug has not been fixed in the latest version.

Describe the bug

我使用mmdeploy 对marsk rcnn进行onnx模型生成,然后利用tensorrt trtexc转换成engine模型,出现 /TopK
This version of TensorRT only supports input K as an initializer.错误,我在你们之前相关帖子看到类似问题,但是没懂你们具体的解决办法,请问怎么解决这个问题

Reproduction

python3 tools/deploy.py configs/mmdet/instance-seg/instance-seg_onnxruntime_dynamic.py ../mmdetection/configs/mask_rcnn/mask-rcnn_r50_fpn_1x_coco.py ./checkpoints/mask_rcnn_r50_fpn_1x_coco_20200205-d4b0c5d6.pth ../mmdetection/demo/demo.jpg --work-dir out/ --device cuda:0 --dump-info

Environment

tensorrt7 tensorrt8

Error traceback

[03/22/2024-03:24:30] [V] [TRT] Registering layer: onnx::Where_685 for ONNX node: onnx::Where_685
[03/22/2024-03:24:30] [V] [TRT] Registering layer: /Less for ONNX node: /Less
[03/22/2024-03:24:30] [V] [TRT] Registering tensor: /Less_output_0 for ONNX tensor: /Less_output_0
[03/22/2024-03:24:30] [V] [TRT] /Less [Less] outputs: [/Less_output_0 -> ()[BOOL]], 
[03/22/2024-03:24:30] [V] [TRT] Parsing node: /Where [Where]
[03/22/2024-03:24:30] [V] [TRT] Searching for input: /Less_output_0
[03/22/2024-03:24:30] [V] [TRT] Searching for input: onnx::Where_685
[03/22/2024-03:24:30] [V] [TRT] Searching for input: /Add_output_0
[03/22/2024-03:24:30] [V] [TRT] /Where [Where] inputs: [/Less_output_0 -> ()[BOOL]], [onnx::Where_685 -> ()[INT32]], [/Add_output_0 -> ()[INT32]], 
[03/22/2024-03:24:30] [V] [TRT] Registering layer: /Where for ONNX node: /Where
[03/22/2024-03:24:30] [V] [TRT] Registering tensor: /Where_output_0 for ONNX tensor: /Where_output_0
[03/22/2024-03:24:30] [V] [TRT] /Where [Where] outputs: [/Where_output_0 -> ()[INT32]], 
[03/22/2024-03:24:30] [V] [TRT] Parsing node: /Constant_7 [Constant]
[03/22/2024-03:24:30] [V] [TRT] /Constant_7 [Constant] inputs: 
[03/22/2024-03:24:30] [V] [TRT] /Constant_7 [Constant] outputs: [/Constant_7_output_0 -> (1)[INT32]], 
[03/22/2024-03:24:30] [V] [TRT] Parsing node: /Reshape_3 [Reshape]
[03/22/2024-03:24:30] [V] [TRT] Searching for input: /Where_output_0
[03/22/2024-03:24:30] [V] [TRT] Searching for input: /Constant_7_output_0
[03/22/2024-03:24:30] [V] [TRT] /Reshape_3 [Reshape] inputs: [/Where_output_0 -> ()[INT32]], [/Constant_7_output_0 -> (1)[INT32]], 
[03/22/2024-03:24:30] [V] [TRT] Registering layer: /Reshape_3 for ONNX node: /Reshape_3
[03/22/2024-03:24:30] [V] [TRT] Registering tensor: /Reshape_3_output_0 for ONNX tensor: /Reshape_3_output_0
[03/22/2024-03:24:30] [V] [TRT] /Reshape_3 [Reshape] outputs: [/Reshape_3_output_0 -> (1)[INT32]], 
[03/22/2024-03:24:30] [V] [TRT] Parsing node: /TopK [TopK]
[03/22/2024-03:24:30] [V] [TRT] Searching for input: /Squeeze_output_0
[03/22/2024-03:24:30] [V] [TRT] Searching for input: /Reshape_3_output_0
[03/22/2024-03:24:30] [V] [TRT] /TopK [TopK] inputs: [/Squeeze_output_0 -> (1, 182400)[FLOAT]], [/Reshape_3_output_0 -> (1)[INT32]], 
[03/22/2024-03:24:30] [E] [TRT] ModelImporter.cpp:726: While parsing node number 201 [TopK -> "/TopK_output_0"]:
[03/22/2024-03:24:30] [E] [TRT] ModelImporter.cpp:727: --- Begin node ---
[03/22/2024-03:24:30] [E] [TRT] ModelImporter.cpp:728: input: "/Squeeze_output_0"
input: "/Reshape_3_output_0"
output: "/TopK_output_0"
output: "/TopK_output_1"
name: "/TopK"
op_type: "TopK"
attribute {
  name: "axis"
  i: 1
  type: INT
}
attribute {
  name: "largest"
  i: 1
  type: INT
}
attribute {
  name: "sorted"
  i: 1
  type: INT
}

[03/22/2024-03:24:30] [E] [TRT] ModelImporter.cpp:729: --- End node ---
[03/22/2024-03:24:30] [E] [TRT] ModelImporter.cpp:732: ERROR: ModelImporter.cpp:168 In function parseGraph:
[6] Invalid Node - /TopK
This version of TensorRT only supports input K as an initializer. Try applying constant folding on the model using Polygraphy: https://github.com/NVIDIA/TensorRT/tree/master/tools/Polygraphy/examples/cli/surgeon/02_folding_constants

我也是这个问题,如果用tool/deploy.py一步转换的话获得engine文件,无法直接推理,不知道怎么加载插件库

我也是这个问题,如果用tool/deploy.py一步转换的话获得engine文件,无法直接推理,不知道怎么加载插件库

插件可以通过ctypes.cdll.LoadLibrary加载

我也是这个问题,如果用tool/deploy.py一步转换的话获得engine文件,无法直接推理,不知道怎么加载插件库

插件可以通过ctypes.cdll.LoadLibrary加载
我是使用python生成engine文件,然后打算用C++推理,该去哪找插件,C++推理又怎么加载。谢谢