open-mmlab / mmdeploy

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

[Bug] Could not find any implementation for node {ForeignNode[onnx::Equal_453...Transpose_115 + Reshape_119]} #2381

Closed leemayi closed 1 year ago

leemayi commented 1 year ago

Checklist

Describe the bug

export mmocr satrn model to tensorrt backend, I got an error:

[08/28/2023-15:06:56] [TRT] [W] Tensor DataType is determined at build time for tensors not marked as input or output. [08/28/2023-15:06:56] [TRT] [W] Tensor DataType is determined at build time for tensors not marked as input or output. [08/28/2023-15:06:56] [TRT] [W] Tensor DataType is determined at build time for tensors not marked as input or output. [08/28/2023-15:06:59] [TRT] [I] Graph optimization time: 1.85392 seconds. [08/28/2023-15:06:59] [TRT] [I] Local timing cache in use. Profiling results in this builder pass will not be stored. [08/28/2023-15:07:02] [TRT] [E] 10: Could not find any implementation for node {ForeignNode[onnx::Equal_453...Transpose_115 + Reshape_119]}. [08/28/2023-15:07:03] [TRT] [E] 10: [optimizer.cpp::nvinfer1::builder::cgraph::LeafCNode::computeCosts::3869] Error Code 10: Internal Error (Could not find any implementation for node {ForeignNode[onnx::Equal_453...Transpose_115 + Reshape_119]}.) Traceback (most recent call last): File "C:\ProgramData\Miniconda3\envs\mmdeploy_1.0\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\ProgramData\Miniconda3\envs\mmdeploy_1.0\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "c:\Users\jushiPC.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy__main.py", line 39, in cli.main() File "c:\Users\jushiPC.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main
run() File "c:\Users\jushiPC.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file runpy.run_path(target, run_name="main") File "c:\Users\jushiPC.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 321, in run_path return _run_module_code(code, init_globals, run_name, File "c:\Users\jushiPC.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code _run_code(code, mod_globals, init_globals, File "c:\Users\jushiPC.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code exec(code, run_globals) File "D:\mmdep\for_deploy_1.0\conver_ocr_rec.py", line 23, in onnx2tensorrt(work_dir, save_file, model_id, deploy_cfg, onnx_model, device) File "d:\mmdep\for_deploy_1.0\mmdeploy-1.2.0\mmdeploy\apis\core\pipeline_manager.py", line 356, in _wrap return self.call_function(funcname, *args, kwargs) File "d:\mmdep\for_deploy_1.0\mmdeploy-1.2.0\mmdeploy\apis\core\pipeline_manager.py", line 326, in call_function return self.call_function_local(func_name, *args, *kwargs) File "d:\mmdep\for_deploy_1.0\mmdeploy-1.2.0\mmdeploy\apis\core\pipeline_manager.py", line 275, in call_function_local return pipe_caller(args, kwargs) File "d:\mmdep\for_deploy_1.0\mmdeploy-1.2.0\mmdeploy\apis\core\pipeline_manager.py", line 107, in
call__ ret = func(*args, **kwargs) File "d:\mmdep\for_deploy_1.0\mmdeploy-1.2.0\mmdeploy\backend\tensorrt\onnx2tensorrt.py", line 79, in onnx2tensorrt from_onnx( File "d:\mmdep\for_deploy_1.0\mmdeploy-1.2.0\mmdeploy\backend\tensorrt\utils.py", line 248, in from_onnx assert engine is not None, 'Failed to create TensorRT engine' AssertionError: Failed to create TensorRT engine

Reproduction

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

img = '.\1.bmp' work_dir = 'work_dir/trt/satrn_b20' save_file = 'end2end.onnx' deploy_cfg = 'mmdeploy-1.2.0/configs/mmocr/text-recognition/text-recognition_tensorrt_dynamic-32x32-32x640.py' model_cfg = 'satrn.py' model_checkpoint = 'satrn.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

08/28 15:15:29 - mmengine - INFO -

08/28 15:15:29 - mmengine - INFO - **********Environmental information**********
08/28 15:15:33 - mmengine - INFO - sys.platform: win32
08/28 15:15:33 - mmengine - INFO - Python: 3.8.16 (default, Jun 12 2023, 21:00:42) [MSC v.1916 64 bit (AMD64)]
08/28 15:15:33 - mmengine - INFO - CUDA available: True
08/28 15:15:33 - mmengine - INFO - numpy_random_seed: 2147483648
08/28 15:15:33 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 3060
08/28 15:15:33 - mmengine - INFO - CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6
08/28 15:15:33 - mmengine - INFO - NVCC: Cuda compilation tools, release 11.6, V11.6.112
08/28 15:15:33 - mmengine - INFO - MSVC: 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.33.31629 版
08/28 15:15:33 - mmengine - INFO - GCC: n/a
08/28 15:15:33 - mmengine - INFO - PyTorch: 1.12.1+cu116
08/28 15:15:33 - mmengine - 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,

08/28 15:15:33 - mmengine - INFO - TorchVision: 0.13.1+cu116
08/28 15:15:33 - mmengine - INFO - OpenCV: 4.7.0
08/28 15:15:33 - mmengine - INFO - MMEngine: 0.7.4
08/28 15:15:33 - mmengine - INFO - MMCV: 2.0.0
08/28 15:15:33 - mmengine - INFO - MMCV Compiler: MSVC 192829924
08/28 15:15:33 - mmengine - INFO - MMCV CUDA Compiler: 11.6
08/28 15:15:33 - mmengine - INFO - MMDeploy: 1.2.0+
08/28 15:15:33 - mmengine - INFO -

08/28 15:15:33 - mmengine - INFO - **********Backend information**********
08/28 15:15:33 - mmengine - INFO - tensorrt:    8.6.1
08/28 15:15:33 - mmengine - INFO - tensorrt custom ops: Available
08/28 15:15:33 - mmengine - INFO - ONNXRuntime: None
08/28 15:15:33 - mmengine - INFO - pplnn:       None
08/28 15:15:33 - mmengine - INFO - ncnn:        None
08/28 15:15:33 - mmengine - INFO - snpe:        None
08/28 15:15:33 - mmengine - INFO - openvino:    None
08/28 15:15:33 - mmengine - INFO - torchscript: 1.12.1+cu116
08/28 15:15:33 - mmengine - INFO - torchscript custom ops:      NotAvailable
08/28 15:15:33 - mmengine - INFO - rknn-toolkit:        None
08/28 15:15:33 - mmengine - INFO - rknn-toolkit2:       None
08/28 15:15:33 - mmengine - INFO - ascend:      None
08/28 15:15:33 - mmengine - INFO - coreml:      None
08/28 15:15:33 - mmengine - INFO - tvm: None
08/28 15:15:33 - mmengine - INFO - vacc:        None
08/28 15:15:33 - mmengine - INFO -

08/28 15:15:33 - mmengine - INFO - **********Codebase information**********
08/28 15:15:33 - mmengine - INFO - mmdet:       3.0.0
08/28 15:15:33 - mmengine - INFO - mmseg:       None
08/28 15:15:33 - mmengine - INFO - mmpretrain:  None
08/28 15:15:33 - mmengine - INFO - mmocr:       1.0.0
08/28 15:15:33 - mmengine - INFO - mmagic:      None
08/28 15:15:33 - mmengine - INFO - mmdet3d:     None
08/28 15:15:33 - mmengine - INFO - mmpose:      None
08/28 15:15:33 - mmengine - INFO - mmrotate:    None
08/28 15:15:33 - mmengine - INFO - mmaction:    None
08/28 15:15:33 - mmengine - INFO - mmrazor:     None
08/28 15:15:33 - mmengine - INFO - mmyolo:      None

Error traceback

[08/28/2023-15:06:56] [TRT] [W] Tensor DataType is determined at build time for tensors not marked as input or output.
[08/28/2023-15:06:56] [TRT] [W] Tensor DataType is determined at build time for tensors not marked as input or output.
[08/28/2023-15:06:56] [TRT] [W] Tensor DataType is determined at build time for tensors not marked as input or output.
[08/28/2023-15:06:59] [TRT] [I] Graph optimization time: 1.85392 seconds.
[08/28/2023-15:06:59] [TRT] [I] Local timing cache in use. Profiling results in this builder pass will not be stored.
[08/28/2023-15:07:02] [TRT] [E] 10: Could not find any implementation for node {ForeignNode[onnx::Equal_453...Transpose_115 + Reshape_119]}.
[08/28/2023-15:07:03] [TRT] [E] 10: [optimizer.cpp::nvinfer1::builder::cgraph::LeafCNode::computeCosts::3869] Error Code 10: Internal Error (Could not find any implementation for node {ForeignNode[onnx::Equal_453...Transpose_115 + Reshape_119]}.)
Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\mmdeploy_1.0\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\ProgramData\Miniconda3\envs\mmdeploy_1.0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:\Users\jushiPC\.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 39, in <module>
    cli.main()
  File "c:\Users\jushiPC\.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main     
    run()
  File "c:\Users\jushiPC\.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file 
    runpy.run_path(target, run_name="__main__")
  File "c:\Users\jushiPC\.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "c:\Users\jushiPC\.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "c:\Users\jushiPC\.vscode\extensions\ms-python.python-2023.14.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "D:\mmdep\for_deploy_1.0\conver_ocr_rec.py", line 23, in <module>
    onnx2tensorrt(work_dir, save_file, model_id, deploy_cfg, onnx_model, device)
  File "d:\mmdep\for_deploy_1.0\mmdeploy-1.2.0\mmdeploy\apis\core\pipeline_manager.py", line 356, in _wrap
    return self.call_function(func_name_, *args, **kwargs)
  File "d:\mmdep\for_deploy_1.0\mmdeploy-1.2.0\mmdeploy\apis\core\pipeline_manager.py", line 326, in call_function
    return self.call_function_local(func_name, *args, **kwargs)
  File "d:\mmdep\for_deploy_1.0\mmdeploy-1.2.0\mmdeploy\apis\core\pipeline_manager.py", line 275, in call_function_local
    return pipe_caller(*args, **kwargs)
  File "d:\mmdep\for_deploy_1.0\mmdeploy-1.2.0\mmdeploy\apis\core\pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "d:\mmdep\for_deploy_1.0\mmdeploy-1.2.0\mmdeploy\backend\tensorrt\onnx2tensorrt.py", line 79, in onnx2tensorrt
    from_onnx(
  File "d:\mmdep\for_deploy_1.0\mmdeploy-1.2.0\mmdeploy\backend\tensorrt\utils.py", line 248, in from_onnx
    assert engine is not None, 'Failed to create TensorRT engine'
AssertionError: Failed to create TensorRT engine
leemayi commented 1 year ago

the mmdeploy-1.2.0/configs/mmocr/text-recognition/text-recognition_tensorrt_dynamic-32x32-32x640.py:

base = [ './text-recognition_dynamic.py', '../../base/backends/tensorrt.py' ]

backend_config = dict( common_config=dict(max_workspace_size=1 << 31), model_inputs=[ dict( input_shapes=dict( input=dict( min_shape=[20, 3, 32, 32], opt_shape=[20, 3, 32, 64], max_shape=[20, 3, 32, 640]))) ])

leemayi commented 1 year ago

but when I use tensorrt-fp16.py, I can succeed

AllentDan commented 1 year ago

hmmm, sounds like a bug of TensorRT. I did not get this error.

github-actions[bot] commented 1 year ago

This issue is marked as stale because it has been marked as invalid or awaiting response for 7 days without any further response. It will be closed in 5 days if the stale label is not removed or if there is no further response.

github-actions[bot] commented 1 year ago

This issue is closed because it has been stale for 5 days. Please open a new issue if you have similar issues or you have any new updates now.

maichm commented 1 year ago

same here