Hello,
I am trying to create a TensorRT enging from a frozen graph I have from TensorFlow. I receive an error during the uff parsing part
Here is my code:
def load_graph(frozen_graph_filename):
# We load the protobuf file from the disk and parse it to retrieve the
# unserialized graph_def
with tf.gfile.GFile(frozen_graph_filename, "rb") as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
# Then, we import the graph_def into a new Graph and returns it
with tf.Graph().as_default() as graph:
# The name var will prefix every op/nodes in your graph
# Since we load everything in a new graph, this is not needed
tf.import_graph_def(graph_def, name="prefix")
return graph
if __name__ == '__main__':
graph = load_graph(args.frozen_model_filename)
OUTPUT_NAMES = 'prefix/prediction'
INPUT_NAME = "prefix/imgs"
INPUT_SHAPE = (3, 224, 448)
tf_model_graphdef = graph.as_graph_def()
uff_model = uff.from_tensorflow(tf_model_graphdef, [OUTPUT_NAMES])
G_LOGGER = trt.infer.ConsoleLogger(trt.infer.LogSeverity.ERROR)
parser = uffparser.create_uff_parser()
parser.register_input(INPUT_NAME, INPUT_SHAPE, 0)
parser.register_output(OUTPUT_NAMES)
engine = trt.utils.uff_to_trt_engine(G_LOGGER, uff_model, parser, 1, 1 << 20)
print "engine created"
parser.destroy()
I receive the following error
Using output node prefix/prediction
Converting to UFF graph
Warning: No conversion function registered for layer: Slice yet.
Converting as custom op Slice prefix/Slice
name: "prefix/Slice"
op: "Slice"
input: "prefix/Shape_1"
input: "prefix/Slice/begin"
input: "prefix/Slice/size"
attr {
key: "Index"
value {
type: DT_INT32
}
}
attr {
key: "T"
value {
type: DT_INT32
}
}
Traceback (most recent call last):
File "test_frozen_model.py", line 110, in <module>
uff_model = uff.from_tensorflow(tf_model_graphdef, ['prefix/prediction'])
File "/home/adm.Z625637/.conda/envs/trtp2.7/lib/python2.7/site-packages/uff/converters/tensorflow/conversion_helpers.py", line 75, in from_tensorflow
name="main")
File "/home/adm.Z625637/.conda/envs/trtp2.7/lib/python2.7/site-packages/uff/converters/tensorflow/converter.py", line 64, in convert_tf2uff_graph
uff_graph, input_replacements)
File "/home/adm.Z625637/.conda/envs/trtp2.7/lib/python2.7/site-packages/uff/converters/tensorflow/converter.py", line 51, in convert_tf2uff_node
op, name, tf_node, inputs, uff_graph, tf_nodes=tf_nodes)
File "/home/adm.Z625637/.conda/envs/trtp2.7/lib/python2.7/site-packages/uff/converters/tensorflow/converter.py", line 28, in convert_layer
fields = cls.parse_tf_attrs(tf_node.attr)
File "/home/adm.Z625637/.conda/envs/trtp2.7/lib/python2.7/site-packages/uff/converters/tensorflow/converter.py", line 177, in parse_tf_attrs
for key, val in attrs.items()}
File "/home/adm.Z625637/.conda/envs/trtp2.7/lib/python2.7/site-packages/uff/converters/tensorflow/converter.py", line 177, in <dictcomp>
for key, val in attrs.items()}
File "/home/adm.Z625637/.conda/envs/trtp2.7/lib/python2.7/site-packages/uff/converters/tensorflow/converter.py", line 172, in parse_tf_attr_value
return cls.convert_tf2uff_field(code, val)
File "/home/adm.Z625637/.conda/envs/trtp2.7/lib/python2.7/site-packages/uff/converters/tensorflow/converter.py", line 146, in convert_tf2uff_field
return TensorFlowToUFFConverter.convert_tf2numpy_dtype(val)
File "/home/adm.Z625637/.conda/envs/trtp2.7/lib/python2.7/site-packages/uff/converters/tensorflow/converter.py", line 74, in convert_tf2numpy_dtype
return np.dtype(dt[dtype])
TypeError: list indices must be integers, not AttrValue
TensorFlow v. 1.4.1
TensorRT v. 3.0.1
Cuda compilation tools, release 8.0, V8.0.61
Any help on this issue please ?