I am using TRT to create a engine following the https://docs.nvidia.com/deeplearning/sdk/tensorrt-developer-guide/index.html#import_tf_python.Here is a test case of my codes.I am creating my own model using tensorflow and try to parse it.
CODES:
import tensorflow as tf
import tensorrt as trt
from tensorflow.examples.tutorials.mnist import input_data
import time
import numpy as np
with tf.variable_scope(“scope”):
a = tf.placeholder(dtype=tf.float32, shape=[3, 3], name=“a”)
b = tf.Variable(tf.random_normal([3, 3,], mean=0, stddev=1, name=“b”))
c = tf.matmul(a, b, name=“c”)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
o = sess.run(c, feed_dict={a: np.ones([3, 3])})
print(sess.run(b))
print(o)
graphdef = tf.get_default_graph().as_graph_def()
frozen_graph = tf.graph_util.convert_variables_to_constants(sess,
graphdef,
["scope/c"])
frozen_model = tf.graph_util.remove_training_nodes(frozen_graph)
with open("test_uff", "wb") as ofile:
ofile.write(frozen_model.SerializeToString())
TRT_LOGGER = trt.Logger(trt.Logger.WARNING)
model_file = “test_uff”
with trt.Builder(TRT_LOGGER) as builder, builder.create_network() as network, trt.UffParser() as parser:
parser.register_input("scope/a", (3, 3))
parser.register_output("scope/c")
parser.parse(model_file, network)
It report an error like:
[TensorRT] ERROR: UFFParser: Unsupported number of graph 0
I see others solve the register_input problem by fixing the input graph name.But it doesnt work.
Does someone know how to resolve it?
Ubuntun:16.04
TensorRT:5.0.0.10
Cuda:9.0
Cudnn:7.1.2
Tensorflow:1.11.0