open-mmlab / mmskeleton

A OpenMMLAB toolbox for human pose estimation, skeleton-based action recognition, and action synthesis.
Apache License 2.0
2.93k stars 1.04k forks source link

Failed to export an ONNX attribute 'onnx::Gather', since it's not constant #415

Open RobotTim opened 3 years ago

RobotTim commented 3 years ago

I have tried to export an ONNX. However, the error below occurs. Could you have any solutions? torch==1.2.0 torchvision==0.4.0

Traceback (most recent call last): File "mmskl.py", line 124, in main() File "mmskl.py", line 118, in main call_obj(cfg.processor_cfg) File "/home/jtm/models/models_pth/ST_GCN/mmskeleton/mmskeleton/utils/importer.py", line 24, in call_obj return import_obj(type)(kwargs) File "/home/jtm/models/models_pth/ST_GCN/mmskeleton/mmskeleton/processor/recognition.py", line 115, in test torch.onnx.export(model, dummy_input, "st-gcn_kinetics-skeleton.onnx") File "/usr/local/python3.7.5/lib/python3.7/site-packages/torch/onnx/init.py", line 276, in export custom_opsets, enable_onnx_checker, use_external_data_format) File "/usr/local/python3.7.5/lib/python3.7/site-packages/torch/onnx/utils.py", line 94, in export use_external_data_format=use_external_data_format) File "/usr/local/python3.7.5/lib/python3.7/site-packages/torch/onnx/utils.py", line 701, in _export dynamic_axes=dynamic_axes) File "/usr/local/python3.7.5/lib/python3.7/site-packages/torch/onnx/utils.py", line 468, in _model_to_graph module=module) File "/usr/local/python3.7.5/lib/python3.7/site-packages/torch/onnx/utils.py", line 206, in _optimize_graph graph = torch._C._jit_pass_onnx(graph, operator_export_type) File "/usr/local/python3.7.5/lib/python3.7/site-packages/torch/onnx/init.py", line 309, in _run_symbolic_function return utils._run_symbolic_function(*args, *kwargs) File "/usr/local/python3.7.5/lib/python3.7/site-packages/torch/onnx/utils.py", line 997, in _run_symbolic_function return symbolic_fn(g, inputs, **attrs) File "/usr/local/python3.7.5/lib/python3.7/site-packages/torch/onnx/symbolic_helper.py", line 143, in wrapper for arg, arg_desc, arg_name in zip(args, arg_descriptors, arg_names)] # type: ignore File "/usr/local/python3.7.5/lib/python3.7/site-packages/torch/onnx/symbolic_helper.py", line 143, in for arg, arg_desc, arg_name in zip(args, arg_descriptors, arg_names)] # type: ignore File "/usr/local/python3.7.5/lib/python3.7/site-packages/torch/onnx/symbolic_helper.py", line 84, in _parse_arg "', since it's not constant, please try to make " RuntimeError: Failed to export an ONNX attribute 'onnx::Gather', since it's not constant, please try to make things (e.g., kernel size) static if possible

minglu2019 commented 3 years ago

You can replace mmskeleton/models/backbones/st_gcn_aaai18.py line104 with: x = F.avg_pool2d(x, [75,18])

mmchen88 commented 2 years ago

ONNX export failure: Tensors must have same number of dimensions: got 1 and 2

mmchen88 commented 2 years ago

You can replace mmskeleton/models/backbones/st_gcn_aaai18.py line104 with: x = F.avg_pool2d(x, [75,18])

ONNX export failure: Tensors must have same number of dimensions: got 1 and 2