【问题标题】:Can we see the Send nodes and the Receive nodes in the tensorflow GraphDef?我们可以看到 tensorflow GraphDef 中的 Send 节点和 Receive 节点吗?
【发布时间】:2016-10-31 17:44:04
【问题描述】:

我们可以在tensorflow GraphDef中看到Send节点和Receive节点,还是使用python API?

我试试下面的代码

import tensorflow as tf

with tf.device("/gpu:0"):
    x = tf.constant(1.0)
with tf.device("/gpu:1"):
    y = tf.constant(2.0)
with tf.device("/cpu:0"):
    sum = tf.add(x, y)

graph_def = tf.get_default_graph().as_graph_def()
print(graph_def)

graph_def 中没有发送/接收节点。图表中是否添加了任何发送/接收节点以将xy 传输到cpu

【问题讨论】:

    标签: python tensorflow


    【解决方案1】:

    send 和 recv 节点仅在您第一次尝试执行图形时添加到图形中,在调用 tf.Session.run()... 时,实际上,添加的 send 和 recv 节点集将取决于您在该调用中提供和获取的特定张量。

    您可以通过将tf.RunOptions(output_partition_graphs=True) 传递给Session.run() 调用来查看在每个设备上执行的确切图表,包括发送和接收节点,如下所示:

    options = tf.RunOptions(output_partition_graphs=True)
    metadata = tf.RunMetadata()
    
    sess.run(..., options=options, metadata=metadata)
    
    for partition_graph_def in metadata.partition_graphs:
        print partition_graph_def  # Contains all the nodes that ran on a single device.
    

    【讨论】:

    • 如果是分布式配置,这两个节点如何传递张量?通过 gRPC?谢谢
    • 是的,分布式设置中机器之间的默认传输使用 gRPC 传输张量内容。但是,也可以使用其他传输方式,包括 MPI 和 RDMA 动词。此处的架构文档对其工作原理进行了高级概述:tensorflow.org/extend/architecture#worker_service
    • 非常感谢!我现在正在深入研究分布式 TensorFlow 如何在运行时传递 protobuf 信息的细节,rendezvous_mgrrpc_rendezvous_mgrbase_rendezvous_mgr 之间有什么区别?
    • my answer here 有一些讨论,但这个问题确实太大了,无法在 600 个字符的评论中处理!
    • 如果这里不适合讨论,请告诉我。但仍然非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2021-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-09
    • 2016-07-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多