【问题标题】:TensorFlow Distributed Runtime Model Parallel CIFAR-10TensorFlow 分布式运行时模型并行 CIFAR-10
【发布时间】: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


    【解决方案1】:

    我无法从您的程序中看出,但我猜您还必须修改 line that creates the session 以指定您的工作任务之一的地址。例如,给定上面的配置,您可能会这样写:

    sess = tf.Session(
        "grpc://10.31.101.101:7777",
        config=tf.ConfigProto(
            allow_soft_placement=True,
            log_device_placement=FLAGS.log_device_placement))
    

    碰巧的是,我们一直在努力改进该错误消息,使其不那么令人困惑。如果您在 GitHub 中更新到最新版本并运行相同的代码,您应该会看到一条错误消息,说明为什么无法满足设备规范。

    【讨论】:

      猜你喜欢
      • 2016-04-16
      • 2018-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-09
      • 2016-10-10
      • 1970-01-01
      • 2017-11-08
      相关资源
      最近更新 更多