我尝试修改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
在我运行的第二个节点上运行...and:
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多GPU代码,我做了简单的修改,替换了train()
函数中的两行。以下一行:
with tf.Graph().as_default(), tf.device('/cpu:0'):
将...is替换为:
with tf.Graph().as_default(), tf.device('/job:local/task:0/cpu:0'):
以下一行:
with tf.device('/gpu:%d' % i):
将...is替换为:
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)
发布于 2016-03-18 06:35:05
我无法从您的程序中判断,但我的猜测是您还必须修改创建会话的行。以指定您的工作任务之一的地址。例如,考虑到上面的配置,您可能会编写:
sess = tf.Session(
"grpc://10.31.101.101:7777",
config=tf.ConfigProto(
allow_soft_placement=True,
log_device_placement=FLAGS.log_device_placement))
碰巧的是,我们一直在努力改进错误信息,以使其不那么混乱。如果您更新到GitHub中的最新版本并运行相同的代码,您应该会看到一条错误消息,它解释了设备规范无法满足的原因。
https://stackoverflow.com/questions/35909427
复制