huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
132.26k stars 26.34k forks source link

ValueError when converting dialogpt to onnx format #14187

Closed qiuxia-alone closed 2 years ago

qiuxia-alone commented 2 years ago

Environment info

Who can help

@patrickvonplaten, @LysandreJik

Information

Model I am using (dialogpt): when convert dialogpt to onnx, i meet ValueError: ValueError: The type of axis index is expected to be an integer

To reproduce

from transformers.convert_graph_to_onnx import convert
from pathlib import Path
convert(framework="pt", model="DialoGPT-medium/", output=Path("onnx/dilogpt.onnx"), opset=11)
patrickvonplaten commented 2 years ago

Gently pinging @michaelbenayoun here

patrickvonplaten commented 2 years ago

Gently pinging @lewtun here

lewtun commented 2 years ago

Thanks for the ping! Will take a look :)

lewtun commented 2 years ago

Hey @qiuxia-alone, thank you for raising this issue! The ONNX export API was overhauled in transformers v4.9.0 (link), and since then the recommended way to export models is via the transformers.onnx package.

For example, one can export the DialoGPT-medium checkpoint as follows:

python -m transformers.onnx --model=microsoft/DialoGPT-medium onnx/ --opset 11

Does running the above command solve your issue? You can find more information in the docs of your transformers version here.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.