# Error exporting T5 model to ONNX with optimum-cli

**URL:** <https://discuss.huggingface.co/t/error-exporting-t5-model-to-onnx-with-optimum-cli/85026>\
**Category:** 🤗Optimum\
**Created:** [May 3, 2024, 3:34pm UTC](https://discuss.huggingface.co/t/error-exporting-t5-model-to-onnx-with-optimum-cli/85026 "2024-05-03T15:34:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamesXanda](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@JamesXanda](https://discuss.huggingface.co/u/JamesXanda)\
**Post date:** [May 3, 2024, 3:34pm UTC](https://discuss.huggingface.co/t/error-exporting-t5-model-to-onnx-with-optimum-cli/85026/1 "2024-05-03T15:34:39Z")

</div>

I have tried exporting the google-t5/t5-small model to ONNX format using optimum.

I have tried exporting this model 2 ways.

The first was I used the ORTModelForSeq2SeqLM class as defined in optimum and then used save\_pretrained method. This seemed to work swimmingly but only outputs:

1. encoder\_model.onnx
2. decoder\_model.onnx
3. decoder\_with\_past\_model.onnx

And I need the decoder\_model\_merged.onnx. I then tried with the optimum-cli using:

optimum-cli export onnx --model google-t5/t5-small onnx\_model

This throws the error:

Exception: An error occured during validation, but the model was saved nonetheless at onnx\_model. Detailed error: [ONNXRuntimeError] : 1 : FAIL : Load model from onnx\_model/decoder\_model\_merged.onnx failed:/Users/runner/work/1/s/onnxruntime/core/graph/model.cc:180 onnxruntime::Model::Model(ModelProto &&, const PathString &, const IOnnxRuntimeOpSchemaRegistryList \*, const logging::Logger &, const ModelOptions &) Unsupported model IR version: 10, max supported IR version: 9

My package versions are:

optimum==1.18.0  
onnxruntime==1.17.3  
onnx==1.16.0  
transformers==4.39.3

Anyone have any ideas?

---

<div class="post-metadata">

**Author:** ![regisss](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/regisss/32/22467_2.png) [@regisss](https://discuss.huggingface.co/u/regisss)\
**Post date:** [May 3, 2024, 6:29pm UTC](https://discuss.huggingface.co/t/error-exporting-t5-model-to-onnx-with-optimum-cli/85026/2 "2024-05-03T18:29:46Z")

</div>

@JamesXanda Can you update Optimum with `pip install -U optimum` and try again please?

```auto
optimum-cli export onnx --model google-t5/t5-small onnx_model

```

runs well on my laptop with latest stable release of Optimum.

---

<div class="post-metadata">

**Author:** ![JamesXanda](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@JamesXanda](https://discuss.huggingface.co/u/JamesXanda)\
**Post date:** [May 7, 2024, 8:24am UTC](https://discuss.huggingface.co/t/error-exporting-t5-model-to-onnx-with-optimum-cli/85026/3 "2024-05-07T08:24:42Z")

</div>

> [@regisss](#):
>
> `optimum-cli export onnx --model google-t5/t5-small onnx_model`

This worked, thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](https://discuss.huggingface.co/u/system)\
**Post date:** [May 7, 2024, 8:25pm UTC](https://discuss.huggingface.co/t/error-exporting-t5-model-to-onnx-with-optimum-cli/85026/4 "2024-05-07T20:25:06Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
