open-mmlab / mmdeploy

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

[Bug] YOLOX and RTMpose model fail to be inferenced in python sdk on openvino backend. #1916

Closed aixiaodewugege closed 1 year ago

aixiaodewugege commented 1 year ago

Checklist

Describe the bug

YOLOX and RTMpose model fail to be inferenced in python sdk on openvino backend.

Converted models are downloaded from mmdeploy website. image

Reproduction

detector = Detector(model_path='mmdeploy_models/mmdetection/yolox_openvino_mmdet', device_name='cpu')

Environment

03/24 16:42:54 - mmengine - INFO - 

03/24 16:42:54 - mmengine - INFO - **********Environmental information**********
03/24 16:42:54 - mmengine - INFO - sys.platform: linux
03/24 16:42:54 - mmengine - INFO - Python: 3.7.16 (default, Jan 17 2023, 22:20:44) [GCC 11.2.0]
03/24 16:42:54 - mmengine - INFO - CUDA available: True
03/24 16:42:54 - mmengine - INFO - numpy_random_seed: 2147483648
03/24 16:42:54 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 3090
03/24 16:42:54 - mmengine - INFO - CUDA_HOME: /usr/local/cuda
03/24 16:42:54 - mmengine - INFO - NVCC: Cuda compilation tools, release 11.7, V11.7.64
03/24 16:42:54 - mmengine - INFO - GCC: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
03/24 16:42:54 - mmengine - INFO - PyTorch: 1.13.1+cu117
03/24 16:42:54 - mmengine - INFO - PyTorch compiling details: PyTorch built with:
  - GCC 9.3
  - C++ Version: 201402
  - Intel(R) Math Kernel Library Version 2020.0.0 Product Build 20191122 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 11.7
  - 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_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
  - CuDNN 8.5
  - Magma 2.6.1
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.7, CUDNN_VERSION=8.5.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.13.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, 

03/24 16:42:54 - mmengine - INFO - TorchVision: 0.14.1+cu117
03/24 16:42:54 - mmengine - INFO - OpenCV: 4.7.0
03/24 16:42:54 - mmengine - INFO - MMEngine: 0.6.0
03/24 16:42:54 - mmengine - INFO - MMCV: 2.0.0rc4
03/24 16:42:54 - mmengine - INFO - MMCV Compiler: GCC 9.3
03/24 16:42:54 - mmengine - INFO - MMCV CUDA Compiler: 11.7
03/24 16:42:54 - mmengine - INFO - MMDeploy: 1.0.0rc3+
03/24 16:42:54 - mmengine - INFO - 

03/24 16:42:54 - mmengine - INFO - **********Backend information**********
03/24 16:42:54 - mmengine - INFO - tensorrt:    8.4.2.4
03/24 16:42:54 - mmengine - INFO - tensorrt custom ops: NotAvailable
03/24 16:42:54 - mmengine - INFO - ONNXRuntime: None
03/24 16:42:54 - mmengine - INFO - ONNXRuntime-gpu:     1.14.1
03/24 16:42:54 - mmengine - INFO - ONNXRuntime custom ops:      NotAvailable
03/24 16:42:54 - mmengine - INFO - pplnn:       None
03/24 16:42:54 - mmengine - INFO - ncnn:        None
03/24 16:42:54 - mmengine - INFO - snpe:        None
03/24 16:42:54 - mmengine - INFO - openvino:    2022.3.0
03/24 16:42:54 - mmengine - INFO - torchscript: 1.13.1
03/24 16:42:54 - mmengine - INFO - torchscript custom ops:      NotAvailable
03/24 16:42:55 - mmengine - INFO - rknn-toolkit:        None
03/24 16:42:55 - mmengine - INFO - rknn-toolkit2:       None
03/24 16:42:55 - mmengine - INFO - ascend:      None
03/24 16:42:55 - mmengine - INFO - coreml:      None
03/24 16:42:55 - mmengine - INFO - tvm: None
03/24 16:42:55 - mmengine - INFO - vacc:        None
03/24 16:42:55 - mmengine - INFO - 

03/24 16:42:55 - mmengine - INFO - **********Codebase information**********
03/24 16:42:55 - mmengine - INFO - mmdet:       3.0.0rc6
03/24 16:42:55 - mmengine - INFO - mmseg:       None
03/24 16:42:55 - mmengine - INFO - mmcls:       None
03/24 16:42:55 - mmengine - INFO - mmocr:       None
03/24 16:42:55 - mmengine - INFO - mmedit:      None
03/24 16:42:55 - mmengine - INFO - mmdet3d:     None
03/24 16:42:55 - mmengine - INFO - mmpose:      1.0.0rc0
03/24 16:42:55 - mmengine - INFO - mmrotate:    None
03/24 16:42:55 - mmengine - INFO - mmaction:    1.0.0rc3

Error traceback

error for yolox 
[2023-03-24 16:43:13.826] [mmdeploy] [info] [model.cpp:35] [DirectoryModel] Load model: "mmdeploy_models/mmdetection/yolox_openvino_mmdet"
[2023-03-24 16:43:13.884] [mmdeploy] [error] [openvino_net.cpp:136] unhandled exception when creating OpenVINO: Cannot create NonMaxSuppression layer NonMaxSuppression_487 id:750 from unsupported opset: opset9
[2023-03-24 16:43:13.885] [mmdeploy] [error] [openvino_net.cpp:261] error creating OpenVINONet: unknown (6) @ /home/wushuchen/projects/mmyolo/mmdeploy/csrc/mmdeploy/net/openvino/openvino_net.cpp:137
[2023-03-24 16:43:13.885] [mmdeploy] [error] [net_module.cpp:54] Failed to create Net backend: openvino, config: {
  "context": {
    "device": "<any>",
    "model": "<any>",
    "stream": "<any>"
  },
  "input": [
    "prep_output"
  ],
  "input_map": {
    "img": "input"
  },
  "is_batched": true,
  "module": "Net",
  "name": "yolox",
  "output": [
    "infer_output"
  ],
  "output_map": {},
  "type": "Task"
}
[2023-03-24 16:43:13.885] [mmdeploy] [error] [task.cpp:99] error parsing config: {
  "context": {
    "device": "<any>",
    "model": "<any>",
    "stream": "<any>"
  },
  "input": [
    "prep_output"
  ],
  "input_map": {
    "img": "input"
  },
  "is_batched": true,
  "module": "Net",
  "name": "yolox",
  "output": [
    "infer_output"
  ],
  "output_map": {},
  "type": "Task"
}
Segmentation fault (core dumped)

error for RTMpose

[2023-03-24 16:44:23.555] [mmdeploy] [info] [model.cpp:35] [DirectoryModel] Load model: "mmdeploy_models/rtmpose_openvino"
[2023-03-24 16:44:23.656] [mmdeploy] [error] [module_adapter.h:31] unhandled exception: invalid argument (1) @ /home/wushuchen/projects/mmyolo/mmdeploy/csrc/mmdeploy/core/value.h:770
terminate called after throwing an instance of 'system_error2::status_error<mmdeploy::StatusDomain>'
  what():  unknown (6) @ /home/wushuchen/projects/mmyolo/mmdeploy/csrc/mmdeploy/experimental/module_adapter.h:32
Aborted (core dumped)
irexyc commented 1 year ago

For yolox, we can't reproduce your problem. Which openvino version do you use?

For RTMpose, the problem is because the generated deploy.json is wrong. @tpoisonooo Could you please have a look into this?

# generated
onnx_config = dict(
    type='onnx',
    export_params=True,
    keep_initializers_as_inputs=False,
    opset_version=11,
    save_file='end2end.onnx',
    input_names=['input'],
    output_names=['output'],
    input_shape=[256, 256],
    optimize=True)
codebase_config = dict(type='mmpose', task='PoseDetection')
backend_config = dict(
    type='openvino',
    model_inputs=[dict(opt_shapes=dict(input=[1, 3, 256, 192]))])

# should be
onnx_config = dict(
    type='onnx',
    export_params=True,
    keep_initializers_as_inputs=False,
    opset_version=11,
    save_file='end2end.onnx',
    input_names=['input'],
    output_names=['simcc_x', 'simcc_y'],
    input_shape=[192, 256],
    optimize=True)
codebase_config = dict(type='mmpose', task='PoseDetection')
backend_config = dict(
    type='openvino',
    model_inputs=[dict(opt_shapes=dict(input=[1, 3, 256, 192]))])