[英]Distributed Tensorflow is getting stuck at sess.run()
我想在多台機器,多個GPU上運行tensorflow。 作為第一步,請在單台機器上試用分布式tensorflow(遵循tensorflow教程https://www.tensorflow.org/how_tos/distributed/ )
下面是sess.run()卡住的行
import tensorflow as tf
cluster = tf.train.ClusterSpec({"local": ["localhost:2222", "localhost:2223"]})
server = tf.train.Server(cluster, job_name="local", task_index=0)
a = tf.constant(8)
b = tf.constant(9)
sess = tf.Session('grpc://localhost:2222')
到這里一切都工作正常,但是當我運行sess.run()時,它卡住了。
sess.run(tf.mul(a,b))
如果有人已經在分布式張量流上工作,請告訴我該解決方案或其他效果很好的教程。
默認情況下,分布式TensorFlow將阻塞,直到tf.train.ClusterSpec
命名的所有服務器都已啟動。 這是在與服務器的第一次交互過程中發生的,通常是第一次sess.run()
調用。 因此,如果您還沒有啟動在localhost:2223
上偵聽的服務器,那么TensorFlow將阻塞直到您這樣做。
根據您以后的目標,有幾種解決方案:
在localhost:2223
上啟動服務器。 在另一個過程中,運行以下腳本:
import tensorflow as tf cluster = tf.train.ClusterSpec({"local": ["localhost:2222", "localhost:2223"]}) server = tf.train.Server(cluster, job_name="local", task_index=1) server.join() # Wait forever for incoming connections.
從原始tf.train.ClusterSpec
刪除任務1:
import tensorflow as tf cluster = tf.train.ClusterSpec({"local": ["localhost:2222"]}) server = tf.train.Server(cluster, job_name="local", task_index=0) # ...
創建tf.Session
時,請指定一個“設備過濾器”,以便該會話僅使用任務0。
# ... sess = tf.Session("grpc://localhost:2222", config=tf.ConfigProto(device_filters=["/job:local/task:0"]))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.