Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

streaming onnx export #2586

Open
chopperWang opened this issue Jul 26, 2024 · 4 comments
Open

streaming onnx export #2586

chopperWang opened this issue Jul 26, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@chopperWang
Copy link

chopperWang commented Jul 26, 2024

当我想导出自己训练的u2pp_conformer的流式模型时报错,请问这是什么原因呢?

Traceback (most recent call last):
  File "/mnt/workspace/wenet/examples/aishell/s0/wenet/bin/export_onnx_gpu.py", line 1228, in <module>
    onnx_config = export_enc_func(model, configs, args, logger,
  File "/mnt/workspace/wenet/examples/aishell/s0/wenet/bin/export_onnx_gpu.py", line 943, in export_online_encoder
    torch.onnx.export(
  File "/usr/local/lib/python3.10/dist-packages/torch/onnx/utils.py", line 516, in export
    _export(
  File "/usr/local/lib/python3.10/dist-packages/torch/onnx/utils.py", line 1596, in _export
    graph, params_dict, torch_out = _model_to_graph(
  File "/usr/local/lib/python3.10/dist-packages/torch/onnx/utils.py", line 1135, in _model_to_graph
    graph, params, torch_out, module = _create_jit_graph(model, args)
  File "/usr/local/lib/python3.10/dist-packages/torch/onnx/utils.py", line 1011, in _create_jit_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args)
  File "/usr/local/lib/python3.10/dist-packages/torch/onnx/utils.py", line 915, in _trace_and_get_graph_from_model
    trace_graph, torch_out, inputs_states = torch.jit._get_trace_graph(
  File "/usr/local/lib/python3.10/dist-packages/torch/jit/_trace.py", line 1285, in _get_trace_graph
    outs = ONNXTracedModule(
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/jit/_trace.py", line 133, in forward
    graph, out = torch._C._create_graph_by_tracing(
  File "/usr/local/lib/python3.10/dist-packages/torch/jit/_trace.py", line 124, in wrapper
    outs.append(self.inner(*trace_inputs))
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1508, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/mnt/workspace/wenet/examples/aishell/s0/wenet/bin/export_onnx_gpu.py", line 172, in forward
    xs, _, new_att_cache, new_cnn_cache = layer(
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1508, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/mnt/workspace/wenet/wenet/transformer/encoder_layer.py", line 225, in forward
    x_att, new_att_cache = self.self_attn(x, x, x, mask, pos_emb,
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1508, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/mnt/workspace/wenet/wenet/transformer/attention.py", line 380, in forward
    k, v, new_cache = self._update_kv_and_cache(k, v, cache)
  File "/mnt/workspace/wenet/wenet/transformer/attention.py", line 196, in _update_kv_and_cache
    key_cache, value_cache = cache
ValueError: too many values to unpack (expected 2)
@chopperWang
Copy link
Author

似乎是v3.1.0才有的问题,版本切回到v3.0.1就可以导出了

@Mddct Mddct self-assigned this Aug 7, 2024
@Mddct Mddct added the bug Something isn't working label Aug 7, 2024
@Tirushamandava
Copy link

Hey @chopperWang I also got the same error. Which version are you talking about?

@dahu1
Copy link

dahu1 commented Oct 31, 2024

导出流式的时候报错,导出离线的时候正常。

@Mddct
Copy link
Collaborator

Mddct commented Nov 8, 2024

最新的main是可以的

截屏2024-11-08 17 09 37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants