-
Notifications
You must be signed in to change notification settings - Fork 3k
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
ValueError: Message onnx.ModelProto exceeds maximum protobuf size of 2GB: 2235646909 #15349
Comments
protobuf has a file size limit of 2GB. You could consider saving to external data using: https://github.com/onnx/onnx/blob/main/docs/ExternalData.md#converting-an-onnx-model-to-external-data. And then pass in the python3 -m onnxruntime.transformers.optimizer ... command. Let me know if that works for you. |
The cause is it uses ONNX shape inference which cannot handle model larger than 2GB. The solution is to upgrade to latest onnxruntime-gpu, which uses symbolic shape inference, and could avoid the limitation. Try install latest onnxruntime-gpu (fp16 need CUDA EP):
Note that I think |
I tried the solution you provided, but it didn't work. I encountered the same error again. Here's the code I used import onnx
onnx_model = onnx.load("/onnx_model/model.onnx")
onnx.save_model(onnx_model, "/optmized_model/model.onnx", save_as_external_data=True, all_tensors_to_one_file=True,
size_threshold=1024, convert_attribute=False, location='external_data') onnx_model is the model converted using torch.onnx.export |
got the same error when running command optimum-cli export onnx --model EleutherAI/pythia-2.8b /local_disk0/optimized_pythia_2.8b_fp16 --optimize O4 --task text-generation-with-past --framework pt --device cuda |
…ta (#17427) Some initializers are added without raw=True flag. That causes those tensors cannot be saved to external data. If those tensors exceed 2GB in total, optimized model cannot be saved due to protobuf limit. This change will save attention weights and bias in raw data. Note: it is optional to use raw data for shape tensor since they are tiny. ### Motivation and Context #17212 #15349
@toobashahid210 Hi, I ran into the same problem. Any good solution? |
If anyone encounter similar error during using onnxruntime.transformers.optimizer for onnxruntime version < 1.17, try install ort-nightly or ort-nightly-gpu package:
|
there might be some libraries compatibility issues on my side ig. I resolved it using following library versions torch==1.11.0 |
…ta (#17427) Some initializers are added without raw=True flag. That causes those tensors cannot be saved to external data. If those tensors exceed 2GB in total, optimized model cannot be saved due to protobuf limit. This change will save attention weights and bias in raw data. Note: it is optional to use raw data for shape tensor since they are tiny. ### Motivation and Context #17212 #15349
…ta (microsoft#17427) Some initializers are added without raw=True flag. That causes those tensors cannot be saved to external data. If those tensors exceed 2GB in total, optimized model cannot be saved due to protobuf limit. This change will save attention weights and bias in raw data. Note: it is optional to use raw data for shape tensor since they are tiny. ### Motivation and Context microsoft#17212 microsoft#15349
Hi
I successfully converted a XLM-Roberta-Large model to the ONNX format using torch.onnx.export(). The converted model size is around 2.1 GB.
However, when I try to optimize the converted model using onnxruntime.transformers.optimizer, I get the following error:
Here are the library versions I am using:
Can anyone suggest a solution to this problem or provide any guidance on how to optimize this model without running into this error?
Would appreciate a quick help on it.
The text was updated successfully, but these errors were encountered: