lucasjinreal / yolov7_d2

🔥🔥🔥🔥 (Earlier YOLOv7 not official one) YOLO with Transformers and Instance Segmentation, with TensorRT acceleration! 🔥🔥🔥
GNU General Public License v3.0
3.13k stars 483 forks source link

ONNX export failed: Couldn't export Python operator _DeformConv #199

Open XYudong opened 1 year ago

XYudong commented 1 year ago

Hi,

Error log:

Traceback (most recent call last):
  File "export.py", line 285, in <module>
    torch.onnx.export(
  File "/opt/conda/lib/python3.8/site-packages/torch/onnx/__init__.py", line 305, in export
    return utils.export(model, args, f, export_params, verbose, training,
  File "/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py", line 118, in export
    _export(model, args, f, export_params, verbose, training, input_names, output_names,
  File "/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py", line 738, in _export
    proto, export_map, val_use_external_data_format = graph._export_onnx(
RuntimeError: ONNX export failed: Couldn't export Python operator _DeformConv

Defined at:
/yolov7_d2/detectron2/detectron2/layers/deform_conv.py(394): forward
/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py(1098): _slow_forward
/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py(1110): _call_impl
/yolov7_d2/yolov7/modeling/backbone/resnetvd.py(105): forward
/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py(1098): _slow_forward
/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py(1110): _call_impl
/opt/conda/lib/python3.8/site-packages/torch/nn/modules/container.py(141): forward
/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py(1098): _slow_forward
/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py(1110): _call_impl
/yolov7_d2/yolov7/modeling/backbone/resnetvd.py(509): forward
/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py(1098): _slow_forward
/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py(1110): _call_impl
/yolov7_d2/yolov7/modeling/meta_arch/sparseinst.py(147): forward
/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py(1098): _slow_forward
/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py(1110): _call_impl
/opt/conda/lib/python3.8/site-packages/torch/jit/_trace.py(118): wrapper
/opt/conda/lib/python3.8/site-packages/torch/jit/_trace.py(127): forward
/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py(1110): _call_impl
/opt/conda/lib/python3.8/site-packages/torch/jit/_trace.py(1166): _get_trace_graph
/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py(391): _trace_and_get_graph_from_model
/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py(440): _create_jit_graph
/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py(499): _model_to_graph
/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py(719): _export
/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py(118): export
/opt/conda/lib/python3.8/site-packages/torch/onnx/__init__.py(305): export
export.py(285): <module>
leandro-svg commented 1 year ago

You can check this git issue where @jinfagang asked about DCN aswell : https://github.com/onnx/onnx/issues/2395

lucasjinreal commented 1 year ago

DCN onnx export is not supported by yolov7-d2

XYudong commented 1 year ago

DCN onnx export is not supported by yolov7-d2

OK, thanks.

So, if I want to use DCN in TensorRT, I have to convert it directly from Pytorch to .trt?