【问题标题】:Distributed Keras Tuner on Google Cloud Platform ML Engine / AI PlatformGoogle Cloud Platform ML Engine / AI Platform 上的分布式 Keras Tuner
【发布时间】:2020-06-16 19:53:58
【问题描述】:

我正在尝试在 Google Cloud Platform (GCP) ML 引擎(又名 AI 平台)上实现这个分布式 Keras Tuner 示例: https://github.com/keras-team/keras-tuner/blob/master/docs/templates/tutorials/distributed-tuning.md

这是我的 ML 训练输入 .yaml:

scaleTier : CUSTOM
masterType: standard
masterConfig:
   imageUri: tensorflow/tensorflow:2.1.0-gpu-py3
workerCount: 8
workerType: standard_gpu
workerConfig:
   imageUri: tensorflow/tensorflow:2.1.0-gpu-py3

在python脚本的顶部,我添加:

tf_config = json.loads(os.environ['TF_CONFIG'])

cluster = tf_config['cluster']
task = tf_config['task']

master_addr = cluster['master'][0].split(':')
os.environ['KERASTUNER_ORACLE_IP'] = master_addr[0]
os.environ['KERASTUNER_ORACLE_PORT'] = '8000'

if task['type'] == 'master':
    os.environ['KERASTUNER_TUNER_ID'] = 'chief'
else:
    os.environ['KERASTUNER_TUNER_ID'] = 'tuner{}'.format(task['index'])

很遗憾,这不起作用。 master返回错误:

server_chttp2.cc:40] {"created":"@1580940408.588629852","description":"No address added out of total 1 resolved","file":"src/core/ext/transport/chttp2/server/chttp2_server.cc","file_line":395,"referenced_errors":[{"created":"@1580940408.588623412","description":"Unable to configure socket","fd":22,"file":"src/core/lib/iomgr/tcp_server_utils_posix_common.cc","file_line":208,"referenced_errors":[{"created":"@1580940408.588609041","description":"Cannot assign requested address","errno":99,"file":"src/core/lib/iomgr/tcp_server_utils_posix_common.cc","file_line":181,"os_error":"Cannot assign requested address","syscall":"bind"}]}]}

因此,master 似乎无法绑定到监听端口。

所以,我想真正的问题是:如何绑定到 GCP ML 引擎上的监听端口?这允许吗?

感谢您现在就如何在 GCP ML 引擎上运行分布式 Keras Tuning 提供任何见解。

【问题讨论】:

标签: python tensorflow keras google-cloud-platform


【解决方案1】:

就错误消息而言,我遇到了与 OP 类似的问题。我不确定真正的原因是什么,但对我有用的解决方法是为首席绑定 0.0.0.0(即os.environ['KERASTUNER_ORACLE_IP'] = '0.0.0.0'),同时仍然使用来自 TF_CONFIG 的首席 IP 用于工作人员

【讨论】:

    【解决方案2】:

    KERASTUNER_ORACLE_IP 需要 IP 地址,而不是主机名。

    这是我在项目中使用的函数,见https://github.com/vlasenkoalexey/gcp_runner/blob/master/entry_point.ipynb

    import os
    import json
    import socket
    
    def setup_keras_tuner_config():
        if 'TF_CONFIG' in os.environ:
            try:
                tf_config = json.loads(os.environ['TF_CONFIG'])
                cluster = tf_config['cluster']
                task = tf_config['task']
                chief_addr = cluster['chief'][0].split(':')
                chief_ip = socket.gethostbyname(chief_addr[0])
                chief_port = chief_addr[1]
                os.environ['KERASTUNER_ORACLE_IP'] = chief_ip
                os.environ['KERASTUNER_ORACLE_PORT'] = chief_port
                if task['type'] == 'chief':
                    os.environ['KERASTUNER_TUNER_ID'] = 'chief'
                else:
                    os.environ['KERASTUNER_TUNER_ID'] = 'tuner{}'.format(task['index'])
    
                print('set following environment arguments:')
                print('KERASTUNER_ORACLE_IP: %s' % os.environ['KERASTUNER_ORACLE_IP'])
                print('KERASTUNER_ORACLE_PORT: %s' % os.environ['KERASTUNER_ORACLE_PORT'])
                print('KERASTUNER_TUNER_ID: %s' % os.environ['KERASTUNER_TUNER_ID'])
            except Exception as ex:
                print('Error setting up keras tuner config: %s' % str(ex))
    

    对于 TF2.x,在 TF_CONFIG 中,“master”被替换为“chief”。您可以通过--use-chief-in-tf-config 进行更新。 确认它可以在 Google AI 平台和 Kubernetes 上运行。

    【讨论】:

      猜你喜欢
      • 2019-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-15
      相关资源
      最近更新 更多