我想在多台机器,多个GPU上运行tensorflow。作为第一步,在单机上试用分布式tensorflow (遵循tensorflow教程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的工作,请让我知道解决方案或其他教程的工作良好。
发布于 2017-01-09 15:52:12
默认情况下,分布式TensorFlow将被阻塞,直到tf.train.ClusterSpec中指定的所有服务器都启动为止。这发生在与服务器的第一次交互中,这通常是第一次sess.run()调用。因此,如果您还没有启动侦听localhost:2223的服务器,那么TensorFlow会一直阻塞直到您启动为止。
对于这个问题有几个解决方案,取决于您以后的目标:
localhost:2223上启动服务器。在另一个进程中,运行以下脚本:
将tensorflow导入为tf群集=tf.train.ClusterSpec({“本地”:"localhost:2222","localhost:2223"})服务器=tf.train.Server( job_name="local",task_index=1) server.join() #永远等待传入连接。tf.train.ClusterSpec中删除任务1:
导入tf集群=tf.train.ClusterSpec({“本地”:"localhost:2222"})服务器=tf.train.Server(群集,job_name=“本地”,task_index=0) #.tf.Session时指定“设备筛选器”,以便会话只使用任务0.config=tf.ConfigProto(device_filters="/job:local/task:0")) = tf.Session("grpc://localhost:2222“)https://stackoverflow.com/questions/41544009
复制相似问题