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] 09/21 21:51:32 - mmengine - ERROR - mmdeploy/tools/deploy.py - create_process - 82 - visualize onnxruntime model failed. #2455

Closed gstariarch closed 11 months ago

gstariarch commented 11 months ago

Checklist

Describe the bug

(mmdeploy_fl_1.x) I:\AILab>python mmdeploy/tools/deploy.py ^ More? mmdeploy\configs\mmrotate\rotated-detection_onnxruntime_dynamic.py ^ More? 模型部署_230921\rotated_rtmdet_s_300e_FL_dota.py ^ More? 模型部署_230921/best_dota_mAP_epoch_368.pth ^ More? 模型部署_230921\test2_922x1844.png ^ More? --work-dir mmdeploy_model/rotrtmdet-cpu ^ More? --device cpu ^ More? --dump-info 09/21 21:51:16 - 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. 09/21 21:51:16 - 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. 09/21 21:51:17 - mmengine - INFO - Start pipeline mmdeploy.apis.pytorch2onnx.torch2onnx in subprocess 09/21 21:51:18 - 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. 09/21 21:51:18 - 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: 模型部署_230921/best_dota_mAP_epoch_368.pth 09/21 21:51:19 - mmengine - WARNING - "FileClient" will be deprecated in future. Please use io functions in https://mmengine.readthedocs.io/en/latest/api/fileio.html#file-io 09/21 21:51:19 - mmengine - WARNING - "HardDiskBackend" is the alias of "LocalBackend" and the former will be deprecated in future. 09/21 21:51:19 - mmengine - WARNING - DeprecationWarning: get_onnx_config will be deprecated in the future. 09/21 21:51:19 - mmengine - INFO - Export PyTorch model to ONNX: mmdeploy_model/rotrtmdet-cpu\end2end.onnx. i:\ailab\mmdeploy\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:\miniconda3\envs\mmdeploy_fl_1.x\lib\site-packages\torch\functional.py:504: 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:3191.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] i:\ailab\mmdeploy\mmdeploy\pytorch\functions\topk.py:28: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect. k = torch.tensor(k, device=input.device, dtype=torch.long) i:\ailab\mmdeploy\mmdeploy\mmcv\ops\nms_rotated.py:40: 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! if _boxes.shape[0] == 0: D:\miniconda3\envs\mmdeploy_fl_1.x\lib\site-packages\mmcv\ops\nms.py:401: 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! if dets.shape[0] == 0: D:\miniconda3\envs\mmdeploy_fl_1.x\lib\site-packages\torch\onnx\symbolic_opset9.py:5408: UserWarning: Exporting aten::index operator of advanced indexing in opset 11 is achieved by combination of multiple ONNX operators, including Reshape, Transpose, Concat, and Gather. If indices include negative values, the exported graph will produce incorrect results. warnings.warn( i:\ailab\mmdeploy\mmdeploy\mmcv\ops\nms_rotated.py:73: FutureWarning: 'torch.onnx._patch_torch._graph_op' is deprecated in version 1.13 and will be removed in version 1.14. Please note 'g.op()' is to be removed from torch.Graph. Please open a GitHub issue if you need this functionality.. return g.op( D:\miniconda3\envs\mmdeploy_fl_1.x\lib\site-packages\torch\onnx_patch_torch.py:81: UserWarning: The shape inference of mmdeploy::NMSRotated type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. (Triggered internally at C:\actions-runner_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\jit\passes\onnx\shape_type_inference.cpp:1888.) _C._jit_pass_onnx_node_shape_type_inference( D:\miniconda3\envs\mmdeploy_fl_1.x\lib\site-packages\torch\onnx\utils.py:687: UserWarning: The shape inference of mmdeploy::NMSRotated type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. (Triggered internally at C:\actions-runner_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\jit\passes\onnx\shape_type_inference.cpp:1888.) _C._jit_pass_onnx_graph_shape_type_inference( D:\miniconda3\envs\mmdeploy_fl_1.x\lib\site-packages\torch\onnx\utils.py:1178: UserWarning: The shape inference of mmdeploy::NMSRotated type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. (Triggered internally at C:\actions-runner_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\jit\passes\onnx\shape_type_inference.cpp:1888.) _C._jit_pass_onnx_graph_shape_type_inference( 09/21 21:51:28 - mmengine - INFO - Execute onnx optimize passes. 09/21 21:51:29 - mmengine - INFO - Finish pipeline mmdeploy.apis.pytorch2onnx.torch2onnx 09/21 21:51:29 - mmengine - INFO - Start pipeline mmdeploy.apis.utils.utils.to_backend in main process 09/21 21:51:29 - mmengine - INFO - Finish pipeline mmdeploy.apis.utils.utils.to_backend 09/21 21:51:29 - mmengine - INFO - visualize onnxruntime model start. 09/21 21:51:31 - 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. 09/21 21:51:31 - 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. 09/21 21:51:31 - mmengine - WARNING - Failed to search registry with scope "mmrotate" in the "backend_detectors" registry tree. As a workaround, the current "backend_detectors" 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. 09/21 21:51:31 - mmengine - INFO - Successfully loaded onnxruntime custom ops from i:\ailab\mmdeploy\mmdeploy\lib\mmdeploy_onnxruntime_ops.dll 09/21 21:51:32 - mmengine - WARNING - "FileClient" will be deprecated in future. Please use io functions in https://mmengine.readthedocs.io/en/latest/api/fileio.html#file-io 09/21 21:51:32 - mmengine - WARNING - "HardDiskBackend" is the alias of "LocalBackend" and the former will be deprecated in future. 09/21 21:51:32 - mmengine - ERROR - mmdeploy/tools/deploy.py - create_process - 82 - visualize onnxruntime model failed.

Reproduction

(mmdeploy_fl_1.x) I:\AILab>python mmdeploy/tools/deploy.py ^ More? mmdeploy\configs\mmrotate\rotated-detection_onnxruntime_dynamic.py ^ More? 模型部署_230921\rotated_rtmdet_s_300e_FL_dota.py ^ More? 模型部署_230921/best_dota_mAP_epoch_368.pth ^ More? 模型部署_230921\test2_922x1844.png ^ More? --work-dir mmdeploy_model/rotrtmdet-cpu ^ More? --device cpu ^ More? --dump-info

Environment

(mmdeploy_fl_1.x) I:\AILab>python mmdeploy\tools\check_env.py
09/21 21:55:36 - mmengine - INFO - 

09/21 21:55:36 - mmengine - INFO - **********Environmental information**********
09/21 21:55:43 - mmengine - INFO - sys.platform: win32
09/21 21:55:43 - mmengine - INFO - Python: 3.8.13 (default, Oct 19 2022, 22:38:03) [MSC v.1916 64 bit (AMD64)]
09/21 21:55:43 - mmengine - INFO - CUDA available: True
09/21 21:55:43 - mmengine - INFO - numpy_random_seed: 2147483648
09/21 21:55:43 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 4070 Laptop GPU
09/21 21:55:43 - mmengine - INFO - CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6
09/21 21:55:43 - mmengine - INFO - NVCC: Cuda compilation tools, release 11.6, V11.6.55
09/21 21:55:43 - mmengine - INFO - MSVC: 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.37.32824 版
09/21 21:55:43 - mmengine - INFO - GCC: n/a
09/21 21:55:43 - mmengine - INFO - PyTorch: 1.13.0+cu116
09/21 21:55:43 - 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.13.0, 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=OFF, USE_NNPACK=OFF, USE_OPENMP=ON, USE_ROCM=OFF,

09/21 21:55:43 - mmengine - INFO - TorchVision: 0.14.0+cu116
09/21 21:55:43 - mmengine - INFO - OpenCV: 4.8.0
09/21 21:55:43 - mmengine - INFO - MMEngine: 0.7.2
09/21 21:55:43 - mmengine - INFO - MMCV: 2.0.1
09/21 21:55:43 - mmengine - INFO - MMCV Compiler: MSVC 192930148
09/21 21:55:43 - mmengine - INFO - MMCV CUDA Compiler: 11.6
09/21 21:55:43 - mmengine - INFO - MMDeploy: 1.2.0+
09/21 21:55:43 - mmengine - INFO -

09/21 21:55:43 - mmengine - INFO - **********Backend information**********
09/21 21:55:43 - mmengine - INFO - tensorrt:    8.4.3.1
09/21 21:55:43 - mmengine - INFO - tensorrt custom ops: NotAvailable
09/21 21:55:43 - mmengine - INFO - ONNXRuntime: 1.8.1
09/21 21:55:43 - mmengine - INFO - ONNXRuntime-gpu:     None
09/21 21:55:43 - mmengine - INFO - ONNXRuntime custom ops:      Available
09/21 21:55:43 - mmengine - INFO - pplnn:       None
09/21 21:55:43 - mmengine - INFO - ncnn:        None
09/21 21:55:43 - mmengine - INFO - snpe:        None
09/21 21:55:43 - mmengine - INFO - openvino:    None
09/21 21:55:43 - mmengine - INFO - torchscript: 1.13.0+cu116
09/21 21:55:43 - mmengine - INFO - torchscript custom ops:      NotAvailable
09/21 21:55:43 - mmengine - INFO - rknn-toolkit:        None
09/21 21:55:43 - mmengine - INFO - rknn-toolkit2:       None
09/21 21:55:43 - mmengine - INFO - ascend:      None
09/21 21:55:43 - mmengine - INFO - coreml:      None
09/21 21:55:43 - mmengine - INFO - tvm: None
09/21 21:55:43 - mmengine - INFO - vacc:        None
09/21 21:55:43 - mmengine - INFO - 

09/21 21:55:43 - mmengine - INFO - **********Codebase information**********
09/21 21:55:43 - mmengine - INFO - mmdet:       3.0.0
09/21 21:55:43 - mmengine - INFO - mmseg:       None
09/21 21:55:43 - mmengine - INFO - mmpretrain:  None
09/21 21:55:43 - mmengine - INFO - mmocr:       None
09/21 21:55:43 - mmengine - INFO - mmagic:      None
09/21 21:55:43 - mmengine - INFO - mmdet3d:     None
09/21 21:55:43 - mmengine - INFO - mmpose:      None
09/21 21:55:43 - mmengine - INFO - mmrotate:    1.0.0rc1
09/21 21:55:43 - mmengine - INFO - mmaction:    None
09/21 21:55:43 - mmengine - INFO - mmrazor:     None
09/21 21:55:43 - mmengine - INFO - mmyolo:      None

Error traceback

No response

RunningLeon commented 11 months ago

hi, could you run visualize_model seperately with the end2end.onnx?

from mmdeploy.apis import visualize_model
from mmdeploy.apis.utils import to_backend

backend_files = ['xxx\end2end.onnx']
visualize_model(model_config_path, deploy_config_path, backend_files, test_img_path,
              args.device, backend=Backend.ONNXRUNTIME, output_file='./ort.png', show_result=True)
gstariarch commented 11 months ago

import argparse import logging import os import os.path as osp from functools import partial import mmengine

import torch.multiprocessing as mp from torch.multiprocessing import Process, set_start_method

from mmdeploy.apis import (create_calib_input_data, extract_model, get_predefined_partition_cfg, torch2onnx, torch2torchscript, visualize_model) from mmdeploy.apis.core import PIPELINE_MANAGER from mmdeploy.apis.utils import to_backend from mmdeploy.backend.sdk.export_info import export2SDK from mmdeploy.utils import (IR, Backend, get_backend, get_calib_filename, get_ir_config, get_partition_config, get_root_logger, load_config, target_wrapper)

from mmdeploy.apis import visualize_model from mmdeploy.apis.utils import to_backend

def main(): backend_files = ['I:\AILab\mmdeploy_model/rtmdet-cpu\end2end.onnx'] visualize_model('I:\AILab\模型部署_230921/rotated_rtmdet_s_300e_FL_dota.py', 'I:\AILab\MMDeploy\configs\mmrotate/rotated-detection_onnxruntime_dynamic.py', backend_files, 'I:\AILab\模型部署_230921/test2_922x1844.png', 'cpu', backend=Backend.ONNXRUNTIME, output_file='I:\AILab\模型部署_230921/test2_922x1844ort.png', show_result=True)

if name == 'main': main()

////////////////////////////////// (mmdeploy_fl_1.x) I:\AILab>python mmdeploy/tools/mytest.py 09/22 09:53:20 - 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. 09/22 09:53:20 - 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. 09/22 09:53:20 - mmengine - WARNING - Failed to search registry with scope "mmrotate" in the "backend_detectors" registry tree. As a workaround, the current "backend_detectors" 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. 09/22 09:53:21 - mmengine - INFO - Successfully loaded onnxruntime custom ops from i:\ailab\mmdeploy\mmdeploy\lib\mmdeploy_onnxruntime_ops.dll 09/22 09:53:21 - mmengine - WARNING - "FileClient" will be deprecated in future. Please use io functions in https://mmengine.readthedocs.io/en/latest/api/fileio.html#file-io 09/22 09:53:21 - mmengine - WARNING - "HardDiskBackend" is the alias of "LocalBackend" and the former will be deprecated in future.

gstariarch commented 11 months ago

可以运行 但没生成标注图片

github-actions[bot] commented 11 months 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 11 months 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.