【问题标题】:TensorFlow Estimator: how to do prediction when using parameter server?TensorFlow Estimator:使用参数服务器时如何进行预测?
【发布时间】:2020-01-24 02:11:23
【问题描述】:

TensorFlow Estimator 易于使用参数服务器策略进行分布式训练。但我无法使用参数服务器策略进行预测。我找不到任何资源来介绍这部分。

预测示例代码:

    run_config = tf.estimator.RunConfig()
    model = tf.estimator.Estimator(
        model_fn=self.model_fn,
        model_dir=self._config.model_path,
        config=run_config,
        params=self.params())
    results = model.predict(
        input_fn=lambda: test_data.build(
            batch_size=self._config.eval_batch_size,
            num_epochs=1))

TF_CONFIG:

{'task': {'index': '0', 'type': 'ps'}, 'cluster': {'chief': ['127.0.0.1:2320'], 'ps': ['127.0.0.1:2220', '127.0.0.1:2221']}}
{'task': {'index': '1', 'type': 'ps'}, 'cluster': {'chief': ['127.0.0.1:2320'], 'ps': ['127.0.0.1:2220', '127.0.0.1:2221']}}
{'task': {'index': '0', 'type': 'chief'}, 'cluster': {'chief': ['127.0.0.1:2320'], 'ps': ['127.0.0.1:2220', '127.0.0.1:2221']}}

结果:PS 和 Woker 都做了预测。

有什么建议吗?非常感谢。

【问题讨论】:

    标签: tensorflow distributed tensorflow-estimator parameter-server


    【解决方案1】:

    在Estimator predict 中,每个ps 和worker 使用MonitoredSession 启动一个从现有检查点恢复的节点。做分布式预测可以参考Estimator training。

    • start ps
    • run_worker 创建MonitoredTrainingSession 而不是MonitoredSession
      • 记得启动工作服务器。
    • estimator.predict 收到 path 用于检查点,MonitoredTrainingSession 收到 directory 用于检查点。

    您可以成功启动所有服务器和分布式预测。但是会出现全局步长不增加等警告。

    Detailed code on Github

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-05
      • 2018-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-21
      • 1970-01-01
      相关资源
      最近更新 更多