0

I am trying to convert .onnx model to .pb format by using onnx-tf package, however, after invoking onnx_tf.backend.prepare function, the python kernel crashes. I am using the code below:

import onnx

from onnx_tf.backend import prepare
import tensorflow
onnx_model = onnx.load(<path-to-model>)  # load onnx model
tf_rep = prepare(onnx_model)  # <------ That's where python crashes
tf_rep.export_graph(<output-path>)  # export the model

I have double-checked package version dependencies, as wrong dependencies caused different errors while loading the .onnx model, and those are as follows:

onnx==1.7.0
onnx-tf==1.6.0
tensorflow==2.2.0
tensorflow-addons==0.10.0
torch==1.6.0+cu101

However, the dependencies seem to be correct, according to Github pages.

3 Answers 3

1

There were large changes between ONNX 1.6 and 1.7 that caused many dependency issues. Try with Onnx 1.6, which may be the source of your issue. Where did you find 1.7 mentioned as the required version?

Additionally, you mention the Python kernel crashing? Are you running in a Jupyter notebook?

I've found this package to be a lot more unstable in Juypter notebook, and not print out all of the relevant errors. If you could test your system in a standalone Python script you may get more information.

Sign up to request clarification or add additional context in comments.

2 Comments

Great! Could you confirm for future readers, was it Onnx 1.6 that solved the issue, or running in a standalone script?
Downgrading from 1.7 to 1.6 solved the issue! Indeed I was running it in Jupyter Notebook previously, however, the same crash happened while running it from the Python interpreter
0

Importing onnx and onnx-tf related libraries before tf and pytorch should help. The problem is probably caused by a version clash since both onnx and onnx-tf use tf.

1 Comment

As you can see from my code, the import order is as you suggested
0

Can you install onnx-tf of this commit 7d8fa7d88fab469253d75e5e11cf9cdcb90104c4

Between order of imports and this commit the issue was solved for me

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.