open-mmlab / mmdeploy

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

模型转换报错 #2168

Closed kc-w closed 1 year ago

kc-w commented 1 year ago

Checklist

Describe the bug

06/08 16:37:22 - mmengine - WARNING - Failed to search registry with scope "mmrotate" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmrotate" is a correct scope, or whether the registry is initialized. 06/08 16:37:22 - mmengine - WARNING - Failed to search registry with scope "mmrotate" in the "mmrotate_tasks" registry tree. As a workaround, the current "mmrotate_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmrotate" is a correct scope, or whether the registry is initialized. 06/08 16:37:24 - mmengine - INFO - Start pipeline mmdeploy.apis.pytorch2onnx.torch2onnx in subprocess 06/08 16:37:26 - mmengine - WARNING - Failed to search registry with scope "mmrotate" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmrotate" is a correct scope, or whether the registry is initialized. 06/08 16:37:26 - mmengine - WARNING - Failed to search registry with scope "mmrotate" in the "mmrotate_tasks" registry tree. As a workaround, the current "mmrotate_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmrotate" is a correct scope, or whether the registry is initialized. Loads checkpoint by local backend from path: E:/DLTrainKit/x64/Release/DeepLearningProject/Project_002/temp/epoch_200.pth 06/08 16:37:28 - mmengine - WARNING - "FileClient" will be deprecated in future. Please use io functions in https://mmengine.readthedocs.io/en/latest/api/fileio.html#file-io 06/08 16:37:28 - mmengine - WARNING - "HardDiskBackend" is the alias of "LocalBackend" and the former will be deprecated in future. 06/08 16:37:29 - mmengine - WARNING - DeprecationWarning: get_onnx_config will be deprecated in the future. 06/08 16:37:29 - mmengine - INFO - Export PyTorch model to ONNX: E:\projectTest\mmdeploy-1.0.0\tools/rtmdet_fp16\end2end.onnx. 06/08 16:37:29 - mmengine - WARNING - Can not find torch._C._jit_pass_onnx_autograd_function_process, function rewrite will not be applied 06/08 16:37:29 - mmengine - WARNING - Can not find torch._C._jit_pass_onnx_deduplicate_initializers, function rewrite will not be applied 06/08 16:37:29 - mmengine - WARNING - Can not find mmdet.models.utils.transformer.PatchMerging.forward, function rewrite will not be applied E:\projectTest\mmdeploy-1.0.0\mmdeploy\codebase\mmdet\models\detectors\single_stage.py:84: TracerWarning: Iterating over a tensor might cause the trace to be incorrect. Passing a tensor of different shape won't change the number of iterations executed (and might lead to errors or silently give incorrect results). img_shape = [int(val) for val in img_shape] E:\projectTest\mmdeploy-1.0.0\mmdeploy\codebase\mmdet\models\detectors\single_stage.py:84: TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! img_shape = [int(val) for val in img_shape] E:\projectTest\mmdeploy-1.0.0\mmdeploy\core\optimizers\function_marker.py:160: TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! ys_shape = tuple(int(s) for s in ys.shape) D:\Python\Python39\lib\site-packages\torch\functional.py:568: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at C:\actions-runner_work\pytorch\pytorch\builder\windows\pytorch\aten\src\ATen\native\TensorShape.cpp:2228.) return _VF.meshgrid(tensors, kwargs) # type: ignore[attr-defined] E:\projectTest\mmdeploy-1.0.0\mmdeploy\pytorch\functions\mod.py:20: UserWarning: floordiv is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor'). return input - (input // other) other E:\projectTest\mmdeploy-1.0.0\mmdeploy\mmcv\ops\nms_rotated.py:303: TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! int(scores.shape[-1]), E:\projectTest\mmdeploy-1.0.0\mmdeploy\mmcv\ops\nms_rotated.py:121: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! out_boxes = min(num_boxes, after_topk) WARNING: The shape inference of mmdeploy::TRTBatchedRotatedNMS type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. WARNING: The shape inference of mmdeploy::TRTBatchedRotatedNMS type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. WARNING: The shape inference of mmdeploy::TRTBatchedRotatedNMS type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. WARNING: The shape inference of mmdeploy::TRTBatchedRotatedNMS type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. WARNING: The shape inference of mmdeploy::TRTBatchedRotatedNMS type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. WARNING: The shape inference of mmdeploy::TRTBatchedRotatedNMS type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. 06/08 16:37:38 - mmengine - INFO - Execute onnx optimize passes. 06/08 16:37:39 - mmengine - INFO - Finish pipeline mmdeploy.apis.pytorch2onnx.torch2onnx 06/08 16:37:41 - mmengine - INFO - Start pipeline mmdeploy.apis.utils.utils.to_backend in subprocess 06/08 16:37:41 - mmengine - WARNING - Could not load the library of tensorrt plugins. Because the file does not exist: [06/08/2023-16:37:41] [TRT] [I] [MemUsageChange] Init CUDA: CPU +450, GPU +0, now: CPU 11288, GPU 1157 (MiB) [06/08/2023-16:37:42] [TRT] [I] [MemUsageChange] Init builder kernel library: CPU +346, GPU +104, now: CPU 11818, GPU 1261 (MiB) [06/08/2023-16:37:42] [TRT] [I] ---------------------------------------------------------------- [06/08/2023-16:37:42] [TRT] [I] Input filename: E:\projectTest\mmdeploy-1.0.0\tools/rtmdet_fp16\end2end.onnx [06/08/2023-16:37:42] [TRT] [I] ONNX IR version: 0.0.6 [06/08/2023-16:37:42] [TRT] [I] Opset version: 11 [06/08/2023-16:37:42] [TRT] [I] Producer name: pytorch [06/08/2023-16:37:42] [TRT] [I] Producer version: 1.11.0 [06/08/2023-16:37:42] [TRT] [I] Domain:
[06/08/2023-16:37:42] [TRT] [I] Model version: 0 [06/08/2023-16:37:42] [TRT] [I] Doc string:
[06/08/2023-16:37:42] [TRT] [I] ---------------------------------------------------------------- [06/08/2023-16:37:43] [TRT] [W] onnx2trt_utils.cpp:369: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32. [06/08/2023-16:37:43] [TRT] [W] onnx2trt_utils.cpp:395: One or more weights outside the range of INT32 was clamped Process Process-3: Traceback (most recent call last): File "D:\Python\Python39\lib\multiprocessing\process.py", line 315, in _bootstrap self.run() File "D:\Python\Python39\lib\multiprocessing\process.py", line 108, in run self._target(
self._args,
self._kwargs) File "E:\projectTest\mmdeploy-1.0.0\mmdeploy\apis\core\pipeline_manager.py", line 108, in call ret = func(*args, **kwargs) File "E:\projectTest\mmdeploy-1.0.0\mmdeploy\apis\utils\utils.py", line 100, in to_backend a = backend_mgr.to_backend( File "E:\projectTest\mmdeploy-1.0.0\mmdeploy\backend\tensorrt\backend_manager.py", line 127, in to_backend onnx2tensorrt( File "E:\projectTest\mmdeploy-1.0.0\mmdeploy\backend\tensorrt\onnx2tensorrt.py", line 79, in onnx2tensorrt from_onnx( File "E:\projectTest\mmdeploy-1.0.0\mmdeploy\backend\tensorrt\utils.py", line 185, in from_onnx raise RuntimeError(f'Failed to parse onnx, {error_msgs}') RuntimeError: Failed to parse onnx, In node 386 (importFallbackPluginImporter): UNSUPPORTED_NODE: Assertion failed: creator && "Plugin not found, are the plugin name, version, and namespace correct?"

[06/08/2023-16:37:43] [TRT] [I] No importer registered for op: TRTBatchedRotatedNMS. Attempting to import as plugin. [06/08/2023-16:37:43] [TRT] [I] Searching for plugin: TRTBatchedRotatedNMS, plugin_version: 1, plugin_namespace: [06/08/2023-16:37:43] [TRT] [E] ModelImporter.cpp:773: While parsing node number 386 [TRTBatchedRotatedNMS -> "dets"]: [06/08/2023-16:37:43] [TRT] [E] ModelImporter.cpp:774: --- Begin node --- [06/08/2023-16:37:43] [TRT] [E] ModelImporter.cpp:775: input: "mmdeploy::TRTBatchedRotatedNMS_1119" input: "y.4" output: "dets" output: "labels" name: "TRTBatchedRotatedNMS_386" op_type: "TRTBatchedRotatedNMS" attribute { name: "background_label_id" i: -1 type: INT } attribute { name: "clip_boxes" i: 0 type: INT } attribute { name: "iou_threshold" f: 0.1 type: FLOAT } attribute { name: "is_normalized" i: 0 type: INT } attribute { name: "keep_topk" i: 2000 type: INT } attribute { name: "num_classes" i: 1 type: INT } attribute { name: "score_threshold" f: 0.05 type: FLOAT } attribute { name: "topk" i: 3000 type: INT } domain: "mmdeploy"

[06/08/2023-16:37:43] [TRT] [E] ModelImporter.cpp:776: --- End node --- [06/08/2023-16:37:43] [TRT] [E] ModelImporter.cpp:779: ERROR: builtin_op_importers.cpp:4890 In function importFallbackPluginImporter: [8] Assertion failed: creator && "Plugin not found, are the plugin name, version, and namespace correct?" 06/08 16:37:43 - mmengine - ERROR - E:\projectTest\mmdeploy-1.0.0\mmdeploy\apis\core\pipeline_manager.py - pop_mp_output - 81 - mmdeploy.apis.utils.utils.to_backend with Call id: 1 failed. exit.

Reproduction

image

Environment

06/08 16:35:13 - mmengine - INFO - **********Environmental information**********
06/08 16:35:18 - mmengine - INFO - sys.platform: win32
06/08 16:35:18 - mmengine - INFO - Python: 3.9.12 (tags/v3.9.12:b28265d, Mar 23 2022, 23:52:46) [MSC v.1929 64 bit (AMD64)]
06/08 16:35:18 - mmengine - INFO - CUDA available: True
06/08 16:35:18 - mmengine - INFO - numpy_random_seed: 2147483648
06/08 16:35:18 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 3060
06/08 16:35:18 - mmengine - INFO - CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3
06/08 16:35:18 - mmengine - INFO - NVCC: Cuda compilation tools, release 11.3, V11.3.109
06/08 16:35:18 - mmengine - INFO - MSVC: 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30147 版
06/08 16:35:18 - mmengine - INFO - GCC: n/a
06/08 16:35:18 - mmengine - INFO - PyTorch: 1.11.0+cu113
06/08 16:35:18 - 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.5.2 (Git Hash a9302535553c73243c632ad3c4c80beec3d19a1e)
  - OpenMP 2019
  - LAPACK is enabled (usually provided by MKL)
  - CPU capability usage: AVX2
  - CUDA Runtime 11.3
  - 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.2
  - Magma 2.5.4
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.3, CUDNN_VERSION=8.2.0, 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.11.0, 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, 

06/08 16:35:18 - mmengine - INFO - TorchVision: 0.12.0+cu113
06/08 16:35:18 - mmengine - INFO - OpenCV: 4.5.3
06/08 16:35:18 - mmengine - INFO - MMEngine: 0.7.3
06/08 16:35:18 - mmengine - INFO - MMCV: 2.0.0
06/08 16:35:18 - mmengine - INFO - MMCV Compiler: MSVC 192829924
06/08 16:35:18 - mmengine - INFO - MMCV CUDA Compiler: 11.3
06/08 16:35:18 - mmengine - INFO - MMDeploy: 1.0.0+
06/08 16:35:18 - mmengine - INFO - 

06/08 16:35:18 - mmengine - INFO - **********Backend information**********
tensorrt
06/08 16:35:19 - mmengine - INFO - tensorrt:    8.4.1.5
06/08 16:35:19 - mmengine - INFO - tensorrt custom ops: NotAvailable
onnxruntime
06/08 16:35:19 - mmengine - INFO - ONNXRuntime: 1.13.1
06/08 16:35:19 - mmengine - INFO - ONNXRuntime-gpu: None
06/08 16:35:19 - mmengine - INFO - ONNXRuntime custom ops:  NotAvailable
pplnn
06/08 16:35:19 - mmengine - INFO - pplnn:   None
ncnn
06/08 16:35:19 - mmengine - INFO - ncnn:    None
snpe
06/08 16:35:19 - mmengine - INFO - snpe:    None
openvino
06/08 16:35:19 - mmengine - INFO - openvino:    2022.1.0
torchscript
06/08 16:35:19 - mmengine - INFO - torchscript: 1.11.0+cu113
06/08 16:35:19 - mmengine - INFO - torchscript custom ops:  NotAvailable
rknn
06/08 16:35:19 - mmengine - INFO - rknn-toolkit:    None
06/08 16:35:19 - mmengine - INFO - rknn-toolkit2:   None
ascend
06/08 16:35:19 - mmengine - INFO - ascend:  None
coreml
06/08 16:35:19 - mmengine - INFO - coreml:  None
tvm
06/08 16:35:19 - mmengine - INFO - tvm: None
vacc
06/08 16:35:19 - mmengine - INFO - vacc:    None
06/08 16:35:19 - mmengine - INFO - 

06/08 16:35:19 - mmengine - INFO - **********Codebase information**********
06/08 16:35:19 - mmengine - INFO - mmdet:   3.0.0
06/08 16:35:19 - mmengine - INFO - mmseg:   1.0.0
06/08 16:35:19 - mmengine - INFO - mmcls:   None
06/08 16:35:19 - mmengine - INFO - mmocr:   None
06/08 16:35:19 - mmengine - INFO - mmedit:  None
06/08 16:35:19 - mmengine - INFO - mmdet3d: None
06/08 16:35:19 - mmengine - INFO - mmpose:  None
06/08 16:35:19 - mmengine - INFO - mmrotate:    1.0.0rc1
06/08 16:35:19 - mmengine - INFO - mmaction:    None
06/08 16:35:19 - mmengine - INFO - mmrazor: None

Error traceback

No response

mm-assistant[bot] commented 1 year ago

We recommend using English or English & Chinese for issues so that we could have broader discussion.

RunningLeon commented 1 year ago

@kc-w hi, did you build the custom ops for tensorrt? pls. refer to https://mmdeploy.readthedocs.io/en/latest/05-supported-backends/tensorrt.html#build-custom-ops

kc-w commented 1 year ago

ok,There is no problem!

maochenyu1 commented 2 weeks ago

请问你怎么解决的,我也遇见了同样的问题。