Hi,
I trained a model with tensorflow and export it as .pb file. I then try to convert it to a .uff file with convert-to-uff. Then I get this error:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/conversion_helpers.py", line 18, in <module>
from tensorflow import GraphDef
ImportError: cannot import name 'GraphDef'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/convert-to-uff", line 7, in <module>
from uff.bin.convert_to_uff import main
File "/usr/local/lib/python3.6/dist-packages/uff/__init__.py", line 2, in <module>
from uff.converters.tensorflow.conversion_helpers import from_tensorflow # noqa
File "/usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/conversion_helpers.py", line 23, in <module>
https://www.tensorflow.org/install/""".format(err))
ImportError: ERROR: Failed to import module (cannot import name 'GraphDef')
Please make sure you have TensorFlow installed.
For installation instructions, see:
https://www.tensorflow.org/install/
Tensorflow is installed as version 2.0.0. TensorRT is installed as version 5.1.5.0 from the .tar file.
Any idea how to fix this?
Thank you!
'GraphDef' API has been removed in TensorFlow 2.0. I think you need to use TensorFlow-1.x for 'conver-to-uff'.
Indeed, using TF-1.13 made it work.
Thanks!
This is not a good solution, Now that tensorflow2.0 has deleted ‘GraphDef’, the UFF parser should follow up to support convert from not only the tensorflow's GraphDef, otherwise users of tensorflow2.0 are embarrassed. Does the UFF parser team know about this? Hurry up. 🙂 🙂 🙂 🙂 🙂 🙂
@rmccorm4
I modify UFF source code, it works.
package version:
tensorflow-gpu 2.1.0
tensorrt 6.0.1.5
uff 0.6.5
find uff package path
$ pip show uff
Name: uff
Version: 0.6.5
Summary: Toolkit for working with the Universal Framwork Format (UFF). Provides a converter from the tensorflow graph format to UFFwith support for more frameworks coming.
Home-page: https://developer.nvidia.com/tensorrt
Author: NVIDIA Corporation
Author-email: [email protected]
License: NVIDIA Software License
Location: ~/Desktop/deeplearning/venv/lib/python3.6/site-packages
Requires: numpy, protobuf
Required-by:
open ~/Desktop/deeplearning/venv/lib/python3.6/site-packages/uff/converters/tensorflow/conversion_helpers.py file
modify from tensorflow import GraphDef to from tensorflow.compat.v1 import GraphDef
test
>>> import uff
2020-05-03 10:36:33.209508: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libnvinfer.so.6
2020-05-03 10:36:33.210411: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libnvinfer_plugin.so.6
>>>
Most helpful comment
'GraphDef' API has been removed in TensorFlow 2.0. I think you need to use TensorFlow-1.x for 'conver-to-uff'.