4

我正在尝试使用 tensorrt 优化我训练有素的冻结推理图。

https://docs.nvidia.com/deeplearning/dgx/integrate-tf-trt/index.html#using-savedmodel

with tf.Graph().as_default() as tf_graph:                                                  
    with tf.Session() as tf_sess:
        with tf.gfile.GFile(path, 'rb') as f:                           
            graph_def = tf.GraphDef()
            graph_def.ParseFromString(f.read())
        infer_graph=  trt.create_inference_graph(
                                              graph_def,                                                                                                                        
                                              outputs=outputs_,
                                              is_dynamic_op=False,
                                     max_workspace_size_bytes=1<<30,
                                               precision_mode='FP16')

Error:

->  362    transformed_graph_def = tf_optimizer.OptimizeGraph(session_config_with_trt, grappler_meta_graph_def, graph_id=b"tf_graph")

/home/dell/.local/lib/python2.7/site-packages/tensorflow/python/grappler/tf_optimizer.pyc in 

-> 41 tf_opt.TF_OptimizeGraph(cluster.tf_cluster,config_proto.SerializeToString(),metagraph.SerializeToString(),verbose, graph_id, status)


/home/dell/.local/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.pyc in __exit__(self, type_arg, value_arg, traceback_arg)

--> 528  
c_api.TF_GetCode(self.status.status))

529
# Delete the underlying status object from memory otherwise it stays alive

530
# as there is a reference to status from this from the traceback due to

InvalidArgumentError: Failed to import metagraph, check error log for more info.
4

1 回答 1

0

我敢打赌,在图形定义中找不到提取节点。从 TensorFlow 日志(不是在谈论您的问题中包含的回溯),您可能会读到以下内容:

E tensorflow/core/grappler/grappler_item_builder.cc:631] Fetch node <outputs_> doesn't exist in graph

您可以通过更正输出节点(outputs_变量)的名称来解决此问题。

如果您不是神经网络的作者,则使用 TensorBoard 检查图形有助于找到正确的节点名称。

于 2020-02-06T22:12:06.487 回答