open-mmlab / mmdeploy

OpenMMLab Model Deployment Framework
https://mmdeploy.readthedocs.io/en/latest/
Apache License 2.0
2.69k stars 618 forks source link

[Bug] [instance_segmentation.cpp:68] invalid argument (1) #2461

Closed leemayi closed 11 months ago

leemayi commented 11 months ago

Checklist

Describe the bug

when use sdk to predict trt model, i got invalid argument error

the detail.json

{ "version": "0.11.0", "codebase": { "task": "ObjectDetection", "codebase": "mmdet", "version": "2.26.0", "pth": "D:\mmdep\mm\datas\seg_44573\latest.pth", "config": "D:\mmdep\mm\datas\seg_44573\config.py" }, "codebase_config": { "type": "mmdet", "task": "ObjectDetection", "model_type": "end2end", "post_processing": { "score_threshold": 0.05, "confidence_threshold": 0.005, "iou_threshold": 0.5, "max_output_boxes_per_class": 200, "pre_top_k": 5000, "keep_top_k": 100, "background_label_id": -1 } }, "onnx_config": { "type": "onnx", "export_params": true, "keep_initializers_as_inputs": false, "opset_version": 11, "save_file": "end2end.onnx", "input_names": [ "input" ], "output_names": [ "dets", "labels" ], "input_shape": null, "optimize": true, "dynamic_axes": { "input": { "0": "batch", "2": "height", "3": "width" }, "dets": { "0": "batch", "1": "num_dets" }, "labels": { "0": "batch", "1": "num_dets" } } }, "backend_config": { "type": "tensorrt", "common_config": { "fp16_mode": false, "max_workspace_size": 1073741824 }, "model_inputs": [ { "input_shapes": { "input": { "min_shape": [ 1, 3, 800, 800 ], "opt_shape": [ 1, 3, 800, 1333 ], "max_shape": [ 1, 3, 1333, 1333 ] } } } ] }, "calib_config": {} }

the pipeline.json

{ "pipeline": { "input": [ "img" ], "output": [ "post_output" ], "tasks": [ { "type": "Task", "module": "Transform", "name": "Preprocess", "input": [ "img" ], "output": [ "prep_output" ], "transforms": [ { "type": "LoadImageFromFile" }, { "type": "Resize", "keep_ratio": true, "size": [ 800, 1333 ] }, { "type": "Normalize", "mean": [ 123.675, 116.28, 103.53 ], "std": [ 58.395, 57.12, 57.375 ], "to_rgb": true }, { "type": "Pad", "size_divisor": 32 }, { "type": "DefaultFormatBundle" }, { "type": "Collect", "keys": [ "img" ], "meta_keys": [ "scale_factor", "img_norm_cfg", "img_shape", "ori_shape", "pad_shape", "valid_ratio", "filename", "flip_direction", "flip", "ori_filename" ] } ], "sha256": "83ba9eb66901a32e1fe5ebcff0a6375706597472e185e1d94aee2043a7399d3b", "fuse_transform": false }, { "name": "maskrcnn", "type": "Task", "module": "Net", "is_batched": true, "input": [ "prep_output" ], "output": [ "infer_output" ], "input_map": { "img": "input" }, "output_map": {} }, { "type": "Task", "module": "mmdet", "name": "postprocess", "component": "ResizeInstanceMask", "params": { "rpn": { "nms_pre": 1000, "max_per_img": 1000, "nms": { "type": "nms", "iou_threshold": 0.7 }, "min_bbox_size": 0 }, "rcnn": { "score_thr": 0.05, "nms": { "type": "nms", "iou_threshold": 0.5 }, "max_per_img": 100, "mask_thr_binary": 0.5 }, "min_bbox_size": 0, "score_thr": 0.05, "mask_thr_binary": 0.5 }, "output": [ "post_output" ], "input": [ "prep_output", "infer_output" ] } ] } }

Reproduction

from mmdeploy.apis import torch2onnx from mmdeploy.apis.tensorrt import onnx2tensorrt from mmdeploy.backend.sdk.export_info import export2SDK import os

img = r'D:\mmdep\mm\datas\1.jpeg' work_dir = r'work_dir/trt/' save_file = r'end2end.onnx' deploycfg = r'D:\mmdep\mm\mmdeploy\configs\mmdet_base\base_tensorrt_dynamic-1333x800.py' model_cfg = r'D:\mmdep\mm\datas\seg_44573\config.py' model_checkpoint = r'D:\mmdep\mm\datas\seg_44573\latest.pth' device = 'cuda'

torch2onnx(img, work_dir, save_file, deploy_cfg, model_cfg, model_checkpoint, device)

onnx_model = os.path.join(work_dir, save_file) save_file = 'end2end.engine' model_id = 0 device = 'cuda' onnx2tensorrt(work_dir, save_file, model_id, deploy_cfg, onnx_model, device)

export2SDK(deploy_cfg, model_cfg, work_dir, pth=model_checkpoint, device=device)

Environment

2023-09-25 11:45:42,795 - mmdeploy - INFO - sys.platform: win32
2023-09-25 11:45:42,795 - mmdeploy - INFO - Python: 3.8.15 (default, Nov 24 2022, 14:38:14) [MSC v.1916 64 bit (AMD64)]
2023-09-25 11:45:42,795 - mmdeploy - INFO - CUDA available: True
2023-09-25 11:45:42,795 - mmdeploy - INFO - GPU 0: NVIDIA GeForce RTX 3060
2023-09-25 11:45:42,795 - mmdeploy - INFO - CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6
2023-09-25 11:45:42,795 - mmdeploy - INFO - NVCC: Cuda compilation tools, release 11.6, V11.6.112
2023-09-25 11:45:42,795 - mmdeploy - INFO - MSVC: 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.33.31629 版
2023-09-25 11:45:42,795 - mmdeploy - INFO - GCC: n/a
2023-09-25 11:45:42,795 - mmdeploy - INFO - PyTorch: 1.12.1+cu116
2023-09-25 11:45:42,795 - mmdeploy - INFO - PyTorch compiling details: PyTorch built with:
  - C++ Version: 199711
  - MSVC 192829337
  - Intel(R) Math Kernel Library Version 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
  - OpenMP 2019
  - LAPACK is enabled (usually provided by MKL)
  - CPU capability usage: AVX2
  - CUDA Runtime 11.6
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=compute_37
  - CuDNN 8.3.2  (built against CUDA 11.5)
  - Magma 2.5.4
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.6, CUDNN_VERSION=8.3.2, CXX_COMPILER=C:/actions-runner/_work/pytorch/pytorch/builder/windows/tmp_bin/sccache-cl.exe, CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj -DUSE_PTHREADPOOL -openmp:experimental -IC:/actions-runner/_work/pytorch/pytorch/builder/windows/mkl/include -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.12.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=OFF, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=OFF, USE_OPENMP=ON, USE_ROCM=OFF,

2023-09-25 11:45:42,796 - mmdeploy - INFO - TorchVision: 0.13.1+cu116
2023-09-25 11:45:42,796 - mmdeploy - INFO - OpenCV: 4.5.4
2023-09-25 11:45:42,796 - mmdeploy - INFO - MMCV: 1.7.1
2023-09-25 11:45:42,796 - mmdeploy - INFO - MMCV Compiler: MSVC 192829924
2023-09-25 11:45:42,796 - mmdeploy - INFO - MMCV CUDA Compiler: 11.6
2023-09-25 11:45:42,796 - mmdeploy - INFO - MMDeploy: 0.11.0+
2023-09-25 11:45:42,796 - mmdeploy - INFO -

2023-09-25 11:45:42,796 - mmdeploy - INFO - **********Backend information**********
D:\mmdep\TensorRT-8.2.3.0\lib\nvinfer.dll
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\bin\cublas64_11.dll
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\bin\cublasLt64_11.dll
D:\mmdep\cudnn-11.4-windows-x64-v8.2.2.26\cuda\bin\cudnn64_8.dll
D:\mmdep\TensorRT-8.2.3.0\lib\nvinfer_plugin.dll
D:\mmdep\TensorRT-8.2.3.0\lib\nvonnxparser.dll
D:\mmdep\TensorRT-8.2.3.0\lib\nvparsers.dll
2023-09-25 11:45:42,917 - mmdeploy - INFO - tensorrt:   8.2.3.0
2023-09-25 11:45:42,917 - mmdeploy - INFO - tensorrt custom ops:        Available
2023-09-25 11:45:42,920 - mmdeploy - INFO - ONNXRuntime:        None
2023-09-25 11:45:42,924 - mmdeploy - INFO - pplnn:      None
2023-09-25 11:45:42,957 - mmdeploy - INFO - ncnn:       None
2023-09-25 11:45:43,021 - mmdeploy - INFO - snpe:       None
2023-09-25 11:45:43,025 - mmdeploy - INFO - openvino:   None
2023-09-25 11:45:43,027 - mmdeploy - INFO - torchscript:        1.12.1+cu116
2023-09-25 11:45:43,028 - mmdeploy - INFO - torchscript custom ops:     NotAvailable
2023-09-25 11:45:43,142 - mmdeploy - INFO - rknn-toolkit:       None
2023-09-25 11:45:43,142 - mmdeploy - INFO - rknn2-toolkit:      None
2023-09-25 11:45:43,145 - mmdeploy - INFO - ascend:     None
2023-09-25 11:45:43,148 - mmdeploy - INFO - coreml:     None
2023-09-25 11:45:43,150 - mmdeploy - INFO - tvm:        None
2023-09-25 11:45:43,150 - mmdeploy - INFO -

2023-09-25 11:45:43,150 - mmdeploy - INFO - **********Codebase information**********
C:\Users\jushiPC\.conda\envs\mmdeploy\lib\site-packages\scipy.libs\libopenblas-57db09cfe174768fb409a6bb5a530d4c.dll
2023-09-25 11:45:44,977 - mmdeploy - INFO - mmdet:      2.26.0
2023-09-25 11:45:44,977 - mmdeploy - INFO - mmseg:      None
2023-09-25 11:45:44,977 - mmdeploy - INFO - mmcls:      0.25.0
2023-09-25 11:45:44,977 - mmdeploy - INFO - mmocr:      0.6.3
2023-09-25 11:45:44,977 - mmdeploy - INFO - mmedit:     None
2023-09-25 11:45:44,977 - mmdeploy - INFO - mmdet3d:    None
2023-09-25 11:45:44,977 - mmdeploy - INFO - mmpose:     None
2023-09-25 11:45:44,977 - mmdeploy - INFO - mmrotate:   0.3.4
2023-09-25 11:45:44,978 - mmdeploy - INFO - mmaction:   None

Error traceback

loading mmdeploy_execution ...
loading mmdeploy_cpu_device ...
loading mmdeploy_cuda_device ...
loading mmdeploy_graph ...
loading mmdeploy_directory_model ...
loading mmdeploy_operation ...
loading mmdeploy_operation_cpu ...
loading mmdeploy_operation_cuda ...
loading mmdeploy_operation_dummy ...
loading mmdeploy_transform ...
loading mmdeploy_transform_module ...
loading mmdeploy_trt_net ...
loading mmdeploy_ort_net ...
loading mmdeploy_net_module ...
loading mmdeploy_mmcls ...
loading mmdeploy_mmdet ...
loading mmdeploy_mmseg ...
loading mmdeploy_mmocr ...
loading mmdeploy_mmedit ...
loading mmdeploy_mmpose ...
loading mmdeploy_mmrotate ...
loading mmdeploy_mmaction ...
[2023-09-25 11:42:55.573] [mmdeploy] [info] [model.cpp:35] [DirectoryModel] Load model: "D:\mmdep\mm\work_dir\trt\44573_dyn"
[2023-09-25 11:42:55.674] [mmdeploy] [info] [inference.cpp:44] {
  "context": {
    "device": "<any>",
    "model": "<any>",
    "stream": "<any>"
  },
  "pipeline": {
    "input": [
      "img"
    ],
    "output": [
      "post_output"
    ],
    "tasks": [
      {
        "fuse_transform": false,
        "input": [
          "img"
        ],
        "module": "Transform",
        "name": "Preprocess",
        "output": [
          "prep_output"
        ],
        "sha256": "83ba9eb66901a32e1fe5ebcff0a6375706597472e185e1d94aee2043a7399d3b",
        "transforms": [
          {
            "type": "LoadImageFromFile"
          },
          {
            "keep_ratio": true,
            "size": [
              800,
              1333
            ],
            "type": "Resize"
          },
          {
            "mean": [
              123.675,
              116.28,
              103.53
            ],
            "std": [
              58.395,
              57.12,
              57.375
            ],
            "to_rgb": true,
            "type": "Normalize"
          },
          {
            "size_divisor": 32,
            "type": "Pad"
          },
          {
            "type": "DefaultFormatBundle"
          },
          {
            "keys": [
              "img"
            ],
            "meta_keys": [
              "scale_factor",
              "img_norm_cfg",
              "img_shape",
              "ori_shape",
              "pad_shape",
              "valid_ratio",
              "filename",
              "flip_direction",
              "flip",
              "ori_filename"
            ],
            "type": "Collect"
          }
        ],
        "type": "Task"
      },
      {
        "input": [
          "prep_output"
        ],
        "input_map": {
          "img": "input"
        },
        "is_batched": true,
        "module": "Net",
        "name": "maskrcnn",
        "output": [
          "infer_output"
        ],
        "output_map": {},
        "type": "Task"
      },
      {
        "component": "ResizeInstanceMask",
        "input": [
          "prep_output",
          "infer_output"
        ],
        "module": "mmdet",
        "name": "postprocess",
        "output": [
          "post_output"
        ],
        "params": {
          "mask_thr_binary": 0.5,
          "min_bbox_size": 0,
          "rcnn": {
            "mask_thr_binary": 0.5,
            "max_per_img": 100,
            "nms": {
              "iou_threshold": 0.5,
              "type": "nms"
            },
            "score_thr": 0.05
          },
          "rpn": {
            "max_per_img": 1000,
            "min_bbox_size": 0,
            "nms": {
              "iou_threshold": 0.7,
              "type": "nms"
            },
            "nms_pre": 1000
          },
          "score_thr": 0.05
        },
        "type": "Task"
      }
    ]
  }
}
[2023-09-25 11:42:59.298] [mmdeploy] [info] [inference.cpp:56] ["img"] <- ["image"]
[2023-09-25 11:42:59.298] [mmdeploy] [info] [inference.cpp:67] ["post_output"] -> ["dets"]
[2023-09-25 11:43:03.264] [mmdeploy] [error] [instance_segmentation.cpp:68] invalid argument (1)
irexyc commented 11 months ago

instance_segmentation.cpp 对应的是 mmseg,Semantic Segmentation 任务。

用 demo/csrc/c/object_detection.cpp 试试,对应的是mmdet

leemayi commented 11 months ago

instance_segmentation.cpp 对应的是 mmseg,Semantic Segmentation 任务。

用 demo/csrc/c/object_detection.cpp 试试,对应的是mmdet

I'm so sorry,I used a wrong confi file!