【问题标题】:Distributed Tensorflow save fails no device分布式 TensorFlow 保存失败,没有设备
【发布时间】:2017-02-23 00:53:24
【问题描述】:

我正在按照示例 here 创建一个带有参数服务器和 n 个工作人员的分布式张量流模型。我没有任何 GPU,所有工作都分布在 CPU 上

在首席工作者中,我想每隔几步保存我的变量,但调用保护程序会导致以下异常:

Cannot assign a device to node 'save_1/RestoreV2_21': 
Could not satisfy explicit device specification 
'/job:ps/task:0/device:CPU:0' because no devices matching that 
specification are registered in this process; available devices: 
/job:localhost/replica:0/task:0/cpu:0

[[Node: save_1/RestoreV2_21 = RestoreV2[dtypes=[DT_INT32],
_device="/job:ps/task:0/device:CPU:0"](save_1/Const, 
save_1/RestoreV2_21/tensor_names, save_1/RestoreV2_21/shape_and_slices)]]

我试过了:

server = tf.train.Server(cluster,
                         job_name=self.calib.params['job_name'],
                         task_index=self.calib.params['task_index'],
                         config=tf.ConfigProto(allow_soft_placement=True)

我正在使用主管:

sv = tf.train.Supervisor(
                         is_chief=is_chief,
                        ...)

并按如下方式创建我的会话:

sess = sv.prepare_or_wait_for_session(server.target)

但我仍然有完全相同的错误

【问题讨论】:

    标签: tensorflow


    【解决方案1】:

    错误信息中的这一行:

    available devices: /job:localhost/replica:0/task:0/cpu:0
    

    ...建议您的tf.Session 未连接到您创建的tf.train.Server。特别是,它似乎是一个本地(或“直接”)会话,只能访问本地进程中的设备。

    要解决此问题,请在创建会话时将 server.target 传递给初始化程序。例如,根据您用于创建会话的 API,您可能希望使用以下方法之一:

    # Creating a session explicitly.
    with tf.Session(server.target) as sess:
      # ...
    
    # Using a `tf.train.Supervisor` called `sv`.
    with sv.managed_session(server.target):
      # ...
    
    # Using a `tf.train.MonitoredTrainingSession`.
    with tf.train.MonitoredTrainingSession(server.target):
      # ...
    

    【讨论】:

    • 谢谢。正如你所说,我正在创建会话。我在问题中添加它
    • 我更新了问题以明确我已经在会话创建中这样做了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-16
    • 1970-01-01
    • 2022-12-30
    • 1970-01-01
    • 2018-02-13
    • 1970-01-01
    相关资源
    最近更新 更多