我想让一名工人上“10.222.152.100”而另一名工人上“10.222.152.101”。 这是worker1.py:
worker_1="10.222.152.100:2222"
worker_2="10.222.152.101:2222"
worker_host=[worker_1,worker_2]
cluster_spec=tf.train.clusterSpec({"FirstJob":worker_host})
server=tf.train.Server(cluster_spec,job_name="FirstJob",task_index=0)
server.join()
这是worker2.py:
worker_1="10.222.152.100:2222"
worker_2="10.222.152.101:2222"
worker_host=[worker_1,worker_2]
cluster_spec=tf.train.clusterSpec({"FirstJob":worker_host})
server=tf.train.Server(cluster_spec,job_name="FirstJob",task_index=1)
server.join()
我希望让工人1和火车上的损失在woeker2上,Client.py是线性回归:
w=tf.Variable(0.0,name="W")
b=tf.Variable(0.0,name="b")
with tf.devic("job:FirstJob/task:0/"):
loss=tf.square(Y-tf.mul(X,w)-b)
with tf.devic("job:FirstJob/task:1/"):
train=tf.train.GradientDescentOptimizer(0.01).minimize(loss)
with tf.Session(target) as sess:
init=tf.initialize_all_variables()
sess.run(init)
for i in range(100):
for (x,y) in zip (Train_X,Train_Y):
sess.run(train,feed_dic={X:x,Y:y})
我的IP是“10.222.152.100”,当target =“10.222.152.100:2222”时,它打印出来:
Could not satisfy explicit device specification '/job:FirstJob/task:1'
当target =“10.222.152.101:2222”时,它会打印:
tensorflow.python.framework.errors.UnimplementedError
希望你的帮助>>>