microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.41k stars 2.89k forks source link

Converting GPT2 to ONNX format does not work with `onnxruntime-tools==1.6.0` #7080

Closed mrshu closed 3 years ago

mrshu commented 3 years ago

Describe the bug

I believe there are two problems here:

  1. the 1.6.0 version of onnxruntime-tools does not work with transformers of version >4.2
  2. even when using transformers in version 4.2.2, the conversion is unsuccessful -- the command bellow finishes with non-zero exit code whilst not creating a .onnx model:
python -m onnxruntime_tools.transformers.convert_to_onnx -m gpt2 --model_class GPT2LMHeadModel --output gpt2.onnx -p fp32

Urgency I am not sure how to assess this, but I also don't see how to currently make use of GPT2 with onnxruntime-tools

System information

To Reproduce

All the steps to reproduce, along with all the related experiments, can be found in the following Google Colab notebook:

https://colab.research.google.com/drive/1HSYS32OtkRVJa3fShRVp_q0mxyGgpDqY

Expected behavior I would expect an .onnx model to be created.

wangyems commented 3 years ago

Please use onnxruntime.transformers.convert_to_onnx

mrshu commented 3 years ago

Thanks @wangyems! Does that mean the onnxruntime_tools package is now deprecated?

wangyems commented 3 years ago

Thanks @wangyems! Does that mean the onnxruntime_tools package is now deprecated?

Yes, if you take a look at readme: https://github.com/microsoft/onnxruntime/tree/master/onnxruntime/python/tools/transformers#gpt-2-model-conversion