Error convert tensorflow frozen model (pb) to TRT Inference model (uff)

I made tensorflow frozen model using google colab based on following nodebook.

And, I tried to convert pb file to uff file using uff.from_tensorflow_frozen_model.

uff.from_tensorflow_frozen_model(‘frozen_inference_graph.pb’, output_filename=‘model.uff’, debug_mode=False)

But, the following errors occurred. How can I make uff file?
Thank you for your help.

Converting FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_depthwise/act_quant/FakeQuantWithMinMaxVars as custom op: FakeQuantWithMinMaxVars
Traceback (most recent call last):
  File "", line 4, in <module>
    uff.from_tensorflow_frozen_model('frozen_inference_graph.pb', output_filename='model.uff', debug_mode=False)
  File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/", line 276, in from_tensorflow_frozen_model
    return from_tensorflow(graphdef, output_nodes, preprocessor, **kwargs)
  File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/", line 225, in from_tensorflow
  File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/", line 141, in convert_tf2uff_graph
    uff_graph, input_replacements, debug_mode=debug_mode)
  File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/", line 126, in convert_tf2uff_node
    op, name, tf_node, inputs, uff_graph, tf_nodes=tf_nodes, debug_mode=debug_mode)
  File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/", line 94, in convert_layer
    return cls.registry_[op](name, tf_node, inputs, uff_graph, **kwargs)
  File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/", line 455, in convert_depthwise_conv2d_native
    return _conv2d_helper(name, tf_node, inputs, uff_graph, func="depthwise", **kwargs)
  File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/", line 480, in _conv2d_helper
    number_groups = int(wt.attr['value'].tensor.tensor_shape.dim[2].size)
  File "/usr/local/lib/python3.6/dist-packages/google/protobuf/internal/", line 209, in __getitem__
    return self._values[key]
IndexError: list index out of range


uff.from_tensorflow_frozen_model(‘frozen_inference_graph.pb’, output_filename=‘model.uff’, debug_mode=False)

Could you set up the output_nodes and try it again?


  • graphdef ( tensorflow.GraphDef ) – The TensorFlow graph to convert.
  • output_nodes ( list ( str ) ) – The names of the outputs of the graph. If not provided, graphsurgeon is used to automatically deduce output nodes.


Thank you for your help.

I wanted to find node_names from my pb file. But, I could not get node_names.

My environment is:

tensorboard                   1.15.0
tensorflow                    1.15.4+nv20.10
tensorflow-estimator          1.15.1

My program is:

import tensorflow as tf

def load_graph(model_file):
  graph = tf.Graph()
  graph_def = tf.GraphDef()

  with open(model_file, "rb") as f:
  with graph.as_default():

  for node in graph_def.node:

  return graph

graph = load_graph('frozen_inference_graph.pb')
ops = graph.get_operations()

Error is:

2020-11-14 21:15:27.528828: I tensorflow/stream_executor/platform/default/] Successfully opened dynamic library
WARNING:tensorflow:Deprecation warnings have been disabled. Set TF_ENABLE_DEPRECATION_WARNINGS=1 to re-enable them.
Traceback (most recent call last):
  File "", line 1, in <module>
    import tensorflow as tf
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/", line 101, in <module>
    from tensorflow_core import *
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/", line 36, in <module>
    from tensorflow._api.v1 import compat
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/_api/v1/compat/", line 24, in <module>
    from tensorflow._api.v1.compat import v2
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/_api/v1/compat/v2/", line 323, in <module>
    from tensorboard.summary._tf import summary
  File "/home/totti/09.DeepStreamTotti/model/", line 3, in <module>
    with tf.Session() as sess:
AttributeError: module 'tensorflow' has no attribute 'Session'

I think, I can use “Session” on Tensor flow 1.x. What is my mistake?

Thank you for your help. I deleted I can get node_names using my program!