【问题标题】:Failed to import metagraph while loading frozen inference graph for tensorrt optimization加载冻结推理图以进行张量优化时无法导入元图
【发布时间】:2019-08-16 19:04:37
【问题描述】:

我正在尝试使用 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.

【问题讨论】:

    标签: python tensorflow tensorrt


    【解决方案1】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-09
      相关资源
      最近更新 更多