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

How to edit onnx(converted from tf with tf2onnx.convert --large_model) larger than 2GB with onnx_graphsurgeon? #3328

Closed
MsDidin opened this issue Sep 18, 2023 · 4 comments
Assignees
Labels
triaged Issue has been triaged by maintainers

Comments

@MsDidin
Copy link

MsDidin commented Sep 18, 2023

Description

I have a onnx model converted form tf with tf2onnx tool. when converted from tf, the model is large than 2GB so I have used the --large_model option

when I use onnx_graphsurgeon to get and modifed graph:
graph = gs.import_onnx(onnx.load(ori_onnx_path))

I got the following error:
File "onnx_surgery.py", line 72, in onnx_model_surgery
graph = gs.import_onnx(onnx.load(ori_onnx_path))
File "/usr/local/lib/python3.8/dist-packages/onnx/init.py", line 134, in load_model
model = load_model_from_string(s, format=format)
File "/usr/local/lib/python3.8/dist-packages/onnx/init.py", line 171, in load_model_from_string
return _deserialize(s, ModelProto())
File "/usr/local/lib/python3.8/dist-packages/onnx/init.py", line 108, in _deserialize
decoded = cast(Optional[int], proto.ParseFromString(s))
File "/usr/local/lib/python3.8/dist-packages/google/protobuf/message.py", line 202, in ParseFromString
return self.MergeFromString(serialized)
File "/usr/local/lib/python3.8/dist-packages/google/protobuf/internal/python_message.py", line 1128, in MergeFromString
if self._InternalParse(serialized, 0, length) != length:
File "/usr/local/lib/python3.8/dist-packages/google/protobuf/internal/python_message.py", line 1178, in InternalParse
raise message_mod.DecodeError('Field number 0 is illegal.')
google.protobuf.message.DecodeError: Field number 0 is illegal.

And I have found another issued got the similar problem , I have tried the solustion

    onnx.shape_inference.infer_shapes_path(ori_onnx_path, opt_onnx_path)
    graph = gs.import_onnx(onnx.load(opt_onnx_path))

but the graph loaded from opt_onnx_path has no nodes and inputs, I have no idea how to edit the grah? Is there any solution for my Scenario?

@MsDidin
Copy link
Author

MsDidin commented Sep 20, 2023

Is there any body follow this issue?

@zerollzeng
Copy link
Collaborator

@pranavm-nvidia ^ ^

@zerollzeng zerollzeng added the triaged Issue has been triaged by maintainers label Sep 20, 2023
@pranavm-nvidia
Copy link
Collaborator

Have you tried the instructions here?

@MsDidin
Copy link
Author

MsDidin commented Sep 27, 2023

Have you tried the instructions here?

Thanks a lot, this link solved my problem!

@MsDidin MsDidin closed this as completed Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Issue has been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

3 participants