open-mmlab / mmdeploy

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

[Bug] mmrotate redet model 2 onnx error #1523

Open lukebor opened 1 year ago

lukebor commented 1 year ago

Checklist

Describe the bug

Hello, i want to deploy redet model from mmrotate framework. I didn't see that Redet is supported but still wanted to try. If there is knowledge that Redet will not work on onnx please tell me.

!python ../mmdeploy/tools/deploy.py \
../mmdeploy/configs/mmrotate/rotated-detection_onnxruntime_dynamic.py \
./configs/redet/redet_custom2.py \
./mmrotate_exp15/epoch_9.pth \
/content/drive/MyDrive/datasets/ac2.png \
--work-dir /content/drive/MyDrive/datasets/mmrotate/redet_work_dir/ort \
--device cuda:0

Reproduction

!python ../mmdeploy/tools/deploy.py \
../mmdeploy/configs/mmrotate/rotated-detection_onnxruntime_dynamic.py \
./configs/redet/redet_custom2.py \
./mmrotate_exp15/epoch_9.pth \
/content/drive/MyDrive/datasets/ac2.png \
--work-dir /content/drive/MyDrive/datasets/mmrotate/redet_work_dir/ort \
--device cuda:0

Environment

/usr/local/lib/python3.8/dist-packages/mmcv/__init__.py:20: UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove components related to the training process and add a data transformation module. In addition, it will rename the package names mmcv to mmcv-lite and mmcv-full to mmcv. See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md for more details.
  warnings.warn(
2022-12-12 15:51:11,040 - mmdeploy - INFO - 

2022-12-12 15:51:11,040 - mmdeploy - INFO - **********Environmental information**********
2022-12-12 15:51:11,473 - mmdeploy - INFO - sys.platform: linux
2022-12-12 15:51:11,473 - mmdeploy - INFO - Python: 3.8.16 (default, Dec  7 2022, 01:12:13) [GCC 7.5.0]
2022-12-12 15:51:11,473 - mmdeploy - INFO - CUDA available: True
2022-12-12 15:51:11,473 - mmdeploy - INFO - GPU 0: Tesla T4
2022-12-12 15:51:11,473 - mmdeploy - INFO - CUDA_HOME: /usr/local/cuda
2022-12-12 15:51:11,473 - mmdeploy - INFO - NVCC: Cuda compilation tools, release 11.2, V11.2.152
2022-12-12 15:51:11,473 - mmdeploy - INFO - GCC: x86_64-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
2022-12-12 15:51:11,473 - mmdeploy - INFO - PyTorch: 1.13.0+cu116
2022-12-12 15:51:11,473 - mmdeploy - 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.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_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.3.2  (built against CUDA 11.5)
  - Magma 2.6.1
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.6, CUDNN_VERSION=8.3.2, 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.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=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, 

2022-12-12 15:51:11,473 - mmdeploy - INFO - TorchVision: 0.14.0+cu116
2022-12-12 15:51:11,473 - mmdeploy - INFO - OpenCV: 4.6.0
2022-12-12 15:51:11,473 - mmdeploy - INFO - MMCV: 1.7.0
2022-12-12 15:51:11,473 - mmdeploy - INFO - MMCV Compiler: GCC 9.3
2022-12-12 15:51:11,473 - mmdeploy - INFO - MMCV CUDA Compiler: 11.6
2022-12-12 15:51:11,473 - mmdeploy - INFO - MMDeploy: 0.11.0+bc1ced4
2022-12-12 15:51:11,474 - mmdeploy - INFO - 

2022-12-12 15:51:11,474 - mmdeploy - INFO - **********Backend information**********
2022-12-12 15:51:12,313 - mmdeploy - INFO - onnxruntime: 1.13.1 ops_is_avaliable : False
2022-12-12 15:51:12,324 - mmdeploy - INFO - tensorrt: None  ops_is_avaliable : False
2022-12-12 15:51:12,384 - mmdeploy - INFO - ncnn: None  ops_is_avaliable : False
2022-12-12 15:51:12,394 - mmdeploy - INFO - pplnn_is_avaliable: False
2022-12-12 15:51:12,403 - mmdeploy - INFO - openvino_is_avaliable: False
2022-12-12 15:51:12,458 - mmdeploy - INFO - snpe_is_available: False
2022-12-12 15:51:12,470 - mmdeploy - INFO - ascend_is_available: False
2022-12-12 15:51:12,479 - mmdeploy - INFO - coreml_is_available: False
2022-12-12 15:51:12,479 - mmdeploy - INFO - 

2022-12-12 15:51:12,479 - mmdeploy - INFO - **********Codebase information**********
2022-12-12 15:51:15,151 - mmdeploy - INFO - mmdet:  2.26.0
2022-12-12 15:51:15,151 - mmdeploy - INFO - mmseg:  None
2022-12-12 15:51:15,151 - mmdeploy - INFO - mmcls:  None
2022-12-12 15:51:15,151 - mmdeploy - INFO - mmocr:  None
2022-12-12 15:51:15,151 - mmdeploy - INFO - mmedit: None
2022-12-12 15:51:15,151 - mmdeploy - INFO - mmdet3d:    None
2022-12-12 15:51:15,151 - mmdeploy - INFO - mmpose: None
2022-12-12 15:51:15,151 - mmdeploy - INFO - mmrotate:   0.3.3
2022-12-12 15:51:15,151 - mmdeploy - INFO - mmaction:   None

Error traceback

2022-12-12 15:44:35,821 - mmdeploy - WARNING - DeprecationWarning: get_onnx_config will be deprecated in the future. 
2022-12-12 15:44:35,822 - mmdeploy - INFO - Export PyTorch model to ONNX: /content/drive/MyDrive/datasets/mmrotate/redet_work_dir/ort/end2end.onnx.
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/core/optimizers/function_marker.py:158: 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)
/usr/local/lib/python3.8/dist-packages/e2cnn/nn/geometric_tensor.py:164: 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!
  assert tensor.shape[1] == type.size, \
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/pytorch/functions/tensor_setitem.py:37: 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!
  stop = stop if stop >= 0 else self_shape[i] + stop
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/pytorch/functions/tensor_setitem.py:35: 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!
  start = start if start >= 0 else self_shape[i] + start
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/pytorch/functions/tensor_setitem.py:42: 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!
  elif out.numel() == 1:
/usr/local/lib/python3.8/dist-packages/mmdet/models/dense_heads/anchor_head.py:123: UserWarning: DeprecationWarning: anchor_generator is deprecated, please use "prior_generator" instead
  warnings.warn('DeprecationWarning: anchor_generator is deprecated, '
/usr/local/lib/python3.8/dist-packages/mmdet/core/anchor/anchor_generator.py:333: UserWarning: ``grid_anchors`` would be deprecated soon. Please use ``grid_priors`` 
  warnings.warn('``grid_anchors`` would be deprecated soon. '
/usr/local/lib/python3.8/dist-packages/mmdet/core/anchor/anchor_generator.py:369: UserWarning: ``single_level_grid_anchors`` would be deprecated soon. Please use ``single_level_grid_priors`` 
  warnings.warn(
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/codebase/mmrotate/models/dense_heads/rotated_rpn_head.py:78: 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!
  assert cls_score.size()[-2:] == bbox_pred.size()[-2:]
/content/drive/MyDrive/datasets/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)
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/codebase/mmdet/core/bbox/delta_xywh_bbox_coder.py:39: 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!
  assert pred_bboxes.size(0) == bboxes.size(0)
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/codebase/mmdet/core/bbox/delta_xywh_bbox_coder.py:41: 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!
  assert pred_bboxes.size(1) == bboxes.size(1)
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/codebase/mmdet/deploy/utils.py:47: TracerWarning: Using len to get tensor shape might cause the trace to be incorrect. Recommended usage would be tensor.shape[0]. Passing a tensor of different shape might lead to errors or silently give incorrect results.
  assert len(max_shape) == 2, '`max_shape` should be [h, w]'
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/codebase/mmdet/core/post_processing/bbox_nms.py:95: 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.
  iou_threshold = torch.tensor([iou_threshold], dtype=torch.float32)
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/codebase/mmdet/core/post_processing/bbox_nms.py:96: 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.
  score_threshold = torch.tensor([score_threshold], dtype=torch.float32)
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/mmcv/ops/nms.py:38: TracerWarning: Converting a tensor to a Python float 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!
  score_threshold = float(score_threshold)
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/mmcv/ops/nms.py:39: TracerWarning: Converting a tensor to a Python float 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!
  iou_threshold = float(iou_threshold)
/usr/local/lib/python3.8/dist-packages/mmcv/ops/nms.py:171: 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!
  assert boxes.size(1) == 4
/usr/local/lib/python3.8/dist-packages/mmcv/ops/nms.py:172: 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!
  assert boxes.size(0) == scores.size(0)
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/codebase/mmrotate/models/roi_heads/roi_trans_roi_head.py:34: 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!
  assert rois.shape[0] == 1, ('Only support one input image '
/usr/local/lib/python3.8/dist-packages/mmcv/ops/roi_align.py:83: 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!
  assert rois.size(1) == 5, 'RoI must be (idx, x1, y1, x2, y2)!'
/content/drive/MyDrive/datasets/mmrotate/mmrotate/core/bbox/coder/delta_xywha_hbbox_coder.py:102: 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!
  assert pred_bboxes.size(0) == bboxes.size(0)
/content/drive/MyDrive/datasets/mmrotate/mmrotate/core/bbox/coder/delta_xywha_hbbox_coder.py:104: 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!
  assert pred_bboxes.size(1) == bboxes.size(1)
/content/drive/MyDrive/datasets/mmrotate/mmrotate/core/bbox/coder/delta_xywha_hbbox_coder.py:105: 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!
  assert bboxes.size(-1) == 4
/content/drive/MyDrive/datasets/mmrotate/mmrotate/core/bbox/coder/delta_xywha_hbbox_coder.py:106: 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!
  assert pred_bboxes.size(-1) == 5
/content/drive/MyDrive/datasets/mmrotate/mmrotate/models/roi_heads/roi_extractors/rotate_single_level_roi_extractor.py:135: 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 inds.numel() > 0:
/content/drive/MyDrive/datasets/mmrotate/mmrotate/core/bbox/coder/delta_xywha_rbbox_coder.py:101: 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!
  assert pred_bboxes.size(0) == bboxes.size(0)
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/mmcv/ops/nms_rotated.py:38: 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:
/usr/local/lib/python3.8/dist-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(
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/mmcv/ops/nms.py:81: 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..
  max_output_boxes_per_class = g.op(
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/mmcv/ops/nms.py:95: 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('NonMaxSuppression', boxes, scores,
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/mmcv/ops/roi_align.py:66: 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..
  g.op(
/usr/local/lib/python3.8/dist-packages/torch/onnx/symbolic_opset11.py:207: 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("Gather", self, index, axis_i=dim)
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/mmcv/ops/roi_align.py:62: 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..
  g.op(
/usr/local/lib/python3.8/dist-packages/torch/onnx/symbolic_opset9.py:3382: 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("Cast", input, to_i=to_i)
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/mmcv/ops/roi_align.py:72: 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..
  g.op(
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/mmcv/ops/roi_align.py:83: 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..
  g.op(
/usr/local/lib/python3.8/dist-packages/torch/onnx/symbolic_opset9.py:356: 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("Add", self, other)
/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/mmcv/ops/roi_align.py:87: 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(
Process Process-2:
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/apis/pytorch2onnx.py", line 96, in torch2onnx
    export(
  File "/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 356, in _wrap
    return self.call_function(func_name_, *args, **kwargs)
  File "/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 326, in call_function
    return self.call_function_local(func_name, *args, **kwargs)
  File "/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 275, in call_function_local
    return pipe_caller(*args, **kwargs)
  File "/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/apis/onnx/export.py", line 122, in export
    torch.onnx.export(
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 504, in export
    _export(
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1529, in _export
    graph, params_dict, torch_out = _model_to_graph(
  File "/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/core/rewriters/rewriter_utils.py", line 379, in wrapper
    return self.func(self, *args, **kwargs)
  File "/content/drive/MyDrive/datasets/mmdeploy/mmdeploy/apis/onnx/optimizer.py", line 10, in model_to_graph__custom_optimizer
    graph, params_dict, torch_out = ctx.origin_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1115, in _model_to_graph
    graph = _optimize_graph(
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 663, in _optimize_graph
    graph = _C._jit_pass_onnx(graph, operator_export_type)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1867, in _run_symbolic_function
    return symbolic_fn(graph_context, *inputs, **attrs)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/symbolic_opset9.py", line 6664, in onnx_placeholder
    return torch._C._jit_onnx_convert_pattern_from_subblock(block, node, env)
RuntimeError: Dangling node reference
2022-12-12 15:44:49,209 - mmdeploy - ERROR - `mmdeploy.apis.pytorch2onnx.torch2onnx` with Call id: 0 failed. exit.
grimoire commented 1 year ago

As for the origin config of redet in MMRotate. Most modules should have been supported by MMDeploy besides RiRoIAlignRotated, which is a custom op in MMCV. You might need to add your custom implementation in backend_ops. Since you are using your custom config, you might have added some functions that have not been supported yet. You can add a custom rewriter for the function. There are may example here. And it is worth mentioning that torch1.13 has done some update to the ONNX export, which might broken some tricks here. We are working on fixing it. It is recommended to use torch1.12 for now.

lukebor commented 1 year ago

Thank you for your reply, this is what i was suspecting. Good luck with torch1.13 fix :)

TInaZhouzzzzz commented 1 year ago

RuntimeError: Dangling node reference 2023-02-28 16:21:08,264 - mmdeploy - ERROR - mmdeploy.apis.pytorch2onnx.torch2onnx with Call id: 0 failed. exit.

I encountered the same error when generating centerpoint onnx. Is there any way to quickly locate what operation caused this problem?

thanks!