【发布时间】:2016-06-24 21:08:06
【问题描述】:
我尝试修改 CIFAR-10 示例以在新的 TensorFlow 分布式运行时上运行。但是,尝试运行程序时出现以下错误:
InvalidArgumentError: Cannot assign a device to node 'softmax_linear/biases/ExponentialMovingAverage':
Could not satisfy explicit device specification '/job:local/task:0/device:CPU:0'
我使用以下命令启动集群。在我运行的第一个节点上:
bazel-bin/tensorflow/core/distributed_runtime/rpc/grpc_tensorflow_server --cluster_spec='local|10.31.101.101:7777;10.31.101.224:7778' --job_name=local --task_id=0
...在我运行的第二个节点上:
bazel-bin/tensorflow/core/distributed_runtime/rpc/grpc_tensorflow_server --cluster_spec='local|10.31.101.101:7777;10.31.101.224:7778' --job_name=local --task_id=1
对于CIFAR-10 multi-GPU code,我进行了简单的修改,替换了train() 函数中的两行。以下行:
with tf.Graph().as_default(), tf.device('/cpu:0'):
...替换为:
with tf.Graph().as_default(), tf.device('/job:local/task:0/cpu:0'):
以及以下行:
with tf.device('/gpu:%d' % i):
...替换为:
with tf.device('/job:local/task:0/gpu:%d' % i):
据我了解,第二次替换应该处理模型替换。运行一个更简单的示例,如下面的代码,可以正常工作:
with tf.device('/job:local/task:0/cpu:0'):
c = tf.constant("Hello, distributed TensorFlow!")
sess.run(c)
print(c)
【问题讨论】:
标签: python runtime distributed tensorflow