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

onnxruntime 转换报错 #40

Open
duyuankai1992 opened this issue Jul 13, 2023 · 4 comments
Open

onnxruntime 转换报错 #40

duyuankai1992 opened this issue Jul 13, 2023 · 4 comments

Comments

@duyuankai1992
Copy link

执行命令:python -m transformers.onnx --model weights/hand-write --feature=vision2seq-lm onnx/
transformers: 4.30.2
onnxrun:1.14.1
image

onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Reshape node. Name:'Reshape_53' Status Message: /onnxruntime_src/onnxruntime/core/providers/cpu/tensor/reshape_helper.h:40 onnxruntime::ReshapeHelper::ReshapeHelper(const onnxruntime::TensorShape&, onnxruntime::TensorShapeVector&, bool) gsl::narrow_cast<int64_t>(input_shape.Size()) == size was false. The input tensor cannot be reshaped to the requested shape. Input shape:{3,578,384}, requested shape:{2,578,6,64}

@LUXUS1
Copy link

LUXUS1 commented Aug 11, 2023

可以使用optimum-cli进行转换
1、pip install optimum[exporters]
2、其他环境版本:pytorch=2.0.0 onnx=1.14.1
3、转换命令:optimum-cli export onnx --model weights/weights/ --task image-to-text --opset 18 onnx_test/
其中--model weights/weights/ 为模型路径,--opset 18可选,onnx_test/为保存路径

@LaplaTom
Copy link

您好,我执行第一个作者的命令可以转换成功,但是在测试的时候会提示 onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Invalid Feed Input Name:attention_mask

采用optimum-cli转换的话,是这个问题 UnboundLocalError: local variable 'all_files' referenced before assignment

@LUXUS1
Copy link

LUXUS1 commented Oct 20, 2023

这个问题我没遇到过,哈哈。你可以更换一下torch或者opset的版本试一下。

@jonesky
Copy link

jonesky commented Jun 14, 2024

请教大佬,后面有解决吗?遇到同样的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants