-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
What is your question?
paraformer-zh导出onnx失败
Code
(funasr2) jincan@likai:~/Downloads$ funasr-export ++model=paraformer-zh ++quantize=false ++device=cpu
funasr version: 1.2.7.
Check update of funasr, and it would cost few times. You may disable it by set disable_update=True in AutoModel
You are using the latest version of funasr-1.2.7
[2025-11-13 16:05:59,638][root][INFO] - download models from model hub: ms
Downloading Model from https://www.modelscope.cn to directory: /home/jincan/.cache/modelscope/hub/models/iic/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch
[2025-11-13 16:06:00,439][root][WARNING] - trust_remote_code: False
[2025-11-13 16:06:01,625][root][INFO] - Loading pretrained params from /home/jincan/.cache/modelscope/hub/models/iic/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/model.pt
[2025-11-13 16:06:01,629][root][INFO] - ckpt: /home/jincan/.cache/modelscope/hub/models/iic/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/model.pt
[2025-11-13 16:06:02,231][root][INFO] - scope_map: ['module.', 'None']
[2025-11-13 16:06:02,231][root][INFO] - excludes: None
[2025-11-13 16:06:02,327][root][INFO] - Loading ckpt: /home/jincan/.cache/modelscope/hub/models/iic/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/model.pt, status:
Error executing job with overrides: ['++model=paraformer-zh', '++quantize=false', '++device=cpu']
Traceback (most recent call last):
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_compat.py", line 93, in export_compat
_dynamic_shapes.from_dynamic_axes_to_dynamic_shapes(
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_dynamic_shapes.py", line 95, in from_dynamic_axes_to_dynamic_shapes
dynamic_shapes = _unflatten_dynamic_shapes_with_inputs_tree(inputs, dynamic_shapes)
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_dynamic_shapes.py", line 307, in _unflatten_dynamic_shapes_with_inputs_tree
return _pytree.tree_unflatten(dynamic_shapes.values(), tree_structure)
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/torch/utils/_pytree.py", line 1299, in tree_unflatten
return treespec.unflatten(leaves)
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/torch/utils/_pytree.py", line 1195, in unflatten
raise ValueError(
ValueError: treespec.unflatten(leaves): leaves has length 4 but the spec refers to a pytree that holds 3 items (TreeSpec(list, None, [*,
*,
*])).
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/jincan/miniconda3/envs/funasr2/bin/funasr-export", line 7, in
sys.exit(main_hydra())
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/hydra/main.py", line 94, in decorated_main
_run_hydra(
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/hydra/_internal/utils.py", line 394, in _run_hydra
_run_app(
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/hydra/_internal/utils.py", line 457, in _run_app
run_and_report(
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/hydra/_internal/utils.py", line 223, in run_and_report
raise ex
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/hydra/_internal/utils.py", line 220, in run_and_report
return func()
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/hydra/_internal/utils.py", line 458, in
lambda: hydra.run(
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/hydra/_internal/hydra.py", line 132, in run
_ = ret.return_value
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/hydra/core/utils.py", line 260, in return_value
raise self._return_value
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/hydra/core/utils.py", line 186, in run_job
ret.return_value = task_function(task_cfg)
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/funasr/bin/export.py", line 30, in main_hydra
res = model.export(
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/funasr/auto/auto_model.py", line 691, in export
export_dir = export_utils.export(model=model, data_in=data_list, **kwargs)
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/funasr/utils/export_utils.py", line 22, in export
_onnx(
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/funasr/utils/export_utils.py", line 80, in _onnx
torch.onnx.export(
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/torch/onnx/init.py", line 296, in export
return _compat.export_compat(
File "/home/jincan/miniconda3/envs/funasr2/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_compat.py", line 103, in export_compat
raise RuntimeError(
RuntimeError: # Failed to convert 'dynamic_axes' to 'dynamic_shapes'. Please provide 'dynamic_shapes' directly. Refer to the documentation for 'torch.export.export' for more information on dynamic shapes.
What's your environment?
- OS (e.g., Linux):
- FunASR Version (1.2.7):
- ModelScope Version (1.31.0):
- PyTorch Version (2.9.0):
- How you installed funasr (
pip, source): - Python version: 3.10.18
- GPU (3080)
- CUDA/cuDNN version (cuda12.8):