mindyolo icon indicating copy to clipboard operation
mindyolo copied to clipboard

将ckpt文件模型导出为onnx时报错

Open southofwall opened this issue 1 year ago • 7 comments

Environment

Hardware Environment(Ascend/GPU/CPU):

Uncomment only one /device <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/device ascend /device gpu /device cpu

Software Environment:

  • MindSpore version (source or binary):
  • Python version (e.g., Python 3.7.5):
  • OS platform and distribution (e.g., Linux Ubuntu 16.04):
  • GCC/Compiler version (if compiled from source):

Describe the current behavior

Traceback (most recent call last): File "./deploy/export.py", line 84, in export_weight(args) File "./deploy/export.py", line 76, in export_weight export(network, input_arr, file_name=file_name, file_format=args.file_format) File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.7/site-packages/mindspore/train/serialization.py", line 915, in export _export(net, file_name, file_format, *inputs, **kwargs) File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.7/site-packages/mindspore/train/serialization.py", line 940, in _export _save_onnx(net, file_name, *inputs, **kwargs) File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.7/site-packages/mindspore/train/serialization.py", line 994, in _save_onnx onnx_stream = _executor._get_func_graph_proto(net, graph_id) File "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.7/site-packages/mindspore/common/api.py", line 1251, in _get_func_graph_proto return self._graph_executor.get_func_graph_proto(exec_id, ir_type) RuntimeError: Expected output of node out to be a single tensor. Instead got: Tuple[Tensor[Float32]*3]


  • C++ Call Stack: (For framework developers)

mindspore/ccsrc/transform/express_ir/onnx_exporter.cc:3279 GetOutputType

Describe the expected behavior

我想要将训练好的ckpt文件导出onnx,但是报错Expected output of node out to be a single tensor. Instead got: Tuple[Tensor[Float32]*3],请问我该如何修改?

Steps to reproduce the issue

Related log / screenshot

Special notes for this issue

southofwall avatar Aug 17 '23 05:08 southofwall

看报错应该onnx导出只支持一个Tensor的输出,这里默认返回了3个

zhanghuiyao avatar Aug 17 '23 06:08 zhanghuiyao

看报错应该onnx导出只支持一个Tensor的输出,这里默认返回了3个

请问我该如何如何正确导出onnx模型呢,air模型导出是成功的

southofwall avatar Aug 17 '23 06:08 southofwall

看报错应该onnx导出只支持一个Tensor的输出,这里默认返回了3个

请问我该如何如何正确导出onnx模型呢,air模型导出是成功的

看起来是onnx里面的限制,可以尝试在相应的head中修改模型的输出个数,合并成一个

zhanghuiyao avatar Aug 24 '23 01:08 zhanghuiyao

我也是一样的问题,想请问一下如何支持onnx导出; 这边用的是r0.1分支,MindSpore 1.9.1,Ascend 910B,训练结果的ckpt文件导出air/mindir成功,onnx相同错误

xmuhlw avatar Sep 18 '23 12:09 xmuhlw

我也是一样的问题,想请问一下如何支持onnx导出; 这边用的是r0.1分支,MindSpore 1.9.1,Ascend 910B,训练结果的ckpt文件导出air/mindir成功,onnx相同错误

想在200I dk A2上部署

xmuhlw avatar Sep 18 '23 12:09 xmuhlw

我也是一样的问题,想请问一下如何支持onnx导出; 这边用的是r0.1分支,MindSpore 1.9.1,Ascend 910B,训练结果的ckpt文件导出air/mindir成功,onnx相同错误

mindyolo 当前未适配onnx和910B,转的时候可能会遇到一些不可知的问题,可以尝试在 MindSpore 仓库上提issue解决;

zhanghuiyao avatar Sep 18 '23 12:09 zhanghuiyao

我也是一样的问题,想请问一下如何支持onnx导出; 这边用的是r0.1分支,MindSpore 1.9.1,Ascend 910B,训练结果的ckpt文件导出air/mindir成功,onnx相同错误

mindyolo 当前未适配onnx和910B,转的时候可能会遇到一些不可知的问题,可以尝试在 MindSpore 仓库上提issue解决;

收到,感谢回复!

xmuhlw avatar Sep 18 '23 12:09 xmuhlw