Skip to content
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

TensorFlow SavedModel: export failure: Message third_party.py.keras.protobuf.SavedMetadata exceeds maximum protobuf size of 2GB: 2283672738 #6262

Closed
2 tasks done
glenn-jocher opened this issue Jan 11, 2022 · 2 comments · Fixed by #6292
Assignees
Labels
bug Something isn't working

Comments

@glenn-jocher
Copy link
Member

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

Export

Bug

YOLOv5x SavedModel format is over a 2GB TF limit:

TensorFlow SavedModel: export failure: Message third_party.py.keras.protobuf.SavedMetadata exceeds maximum protobuf size of 2GB: 2283672738

First noted in #251 (comment)

@zldrobit could you help on this?

Environment

Colab Notebook
https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb

Minimal Reproducible Example

In Colab notebook after running Setup cell:
https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb

!python export.py --weights yolov5x.pt --img 640 --include saved_model

Additional

See tensorflow/tensorflow#45041 for the official TF issue

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@glenn-jocher glenn-jocher added the bug Something isn't working label Jan 11, 2022
@glenn-jocher glenn-jocher self-assigned this Jan 11, 2022
@zldrobit
Copy link
Contributor

zldrobit commented Jan 11, 2022

@glenn-jocher I can confirm the problem with your provided notebook. I also found some links about the 2GB size limit: https://stackoverflow.com/a/42906762/3036450, tensorflow/tensorflow#4291 and https://stackoverflow.com/questions/59558170/tensorflow-graph-bigger-than-2gb. According to those links, we should not break the 2GB limit of protobuf. One way to get a saved model smaller than 2GB is wrap the yolov5x pb model (~350MB) in a saved model format.

EDIT:
The exported pb model is 90% smaller than the saved_model.
image

@zldrobit
Copy link
Contributor

@glenn-jocher I sent a PR to address this issue, but it breaks backward compatibility for saved_model export. Here's a notebook for validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants