microsoft / microsoft/onnxruntime

ONNXOptimizer: ValueError: Message onnx.ModelProto exceeds maximum protobuf size of 2GB: 2215158499

Open
#12,359 7 comments 0 reactions 1 assignee View on GitHub

@yufenglee is already working on this.

Since Jul 28, 2022.

quantization
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 8h
Merged PRs (30d)
179

Description

@yufenglee I'm not sure this issue is fixed (tried using the latest onnxruntime-1.12.0 GPU). While disabling shape inference works for quantization, optimization is still broken for saving models such as albert-xxl. The issue seems to be that write_external_data_tensors isn't actually respecting the condition when it's set to true:

Traceback (most recent call last):
File "examples/onnxruntime/optimization/question-answering/run_qa.py", line 525, in
main()
File "examples/onnxruntime/optimization/question-answering/run_qa.py", line 311, in main
optimizer.export(
File "/home/mroyzen/train_files/optimum/optimum/onnxruntime/optimization.py", line 149, in export
optimizer.save_model_to_file(onnx_optimized_model_output_path, use_external_data_format=True)
File "/opt/conda/lib/python3.8/site-packages/onnxruntime/transformers/models/gpt2/../../onnx_model.py", line 934, in save_model_to_file
save_model(self.model, output_path)
File "/opt/conda/lib/python3.8/site-packages/onnx/init.py", line 202, in save_model
s = _serialize(proto)
File "/opt/conda/lib/python3.8/site-packages/onnx/init.py", line 71, in _serialize
result = proto.SerializeToString()
ValueError: Message onnx.ModelProto exceeds maximum protobuf size of 2GB: 2215158499

Your help would be appreciated. Linking to my issue in Huggingface's Optimum library, but everything seems to be working on their end as evidenced by the stack trace. Also linking the related ONNXQuantizer issue.

Your help would be appreciated. Thanks

Originally posted by @michaelroyzen in https://github.com/microsoft/onnxruntime/issues/11072#issuecomment-1197711143

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.