无法在MLEngineTrainingOperator中指定master_type

问题描述 投票:2回答:1

我正在使用气流来调度管道,这将导致使用ai平台训练scikitlearn模型。我用这个DAG训练它

    with models.DAG(JOB_NAME,
                    schedule_interval=None,
                    default_args=default_args) as dag:

        # Tasks definition
        training_op = MLEngineTrainingOperator(
            task_id='submit_job_for_training',
            project_id=PROJECT,
            job_id=job_id,
            package_uris=[os.path.join(TRAINER_BIN)],
            training_python_module=TRAINER_MODULE,
            runtime_version=RUNTIME_VERSION,
            region='europe-west1',
            training_args=[
                '--base-dir={}'.format(BASE_DIR),
                '--event-date=20200212',
            ],
            python_version='3.5')
        training_op

该训练包将加载所需的csv文件,并在其上训练一个RandomForestClassifier。

这很好,直到文件的数量和大小增加。然后我得到这个错误:

ERROR - The replica master 0 ran out-of-memory and exited with a non-zero status of 9(SIGKILL). To find out more about why your job exited please check the logs:

文件的总大小约为4 Gb。我不知道使用的默认计算机是什么,但似乎还不够。希望这可以解决内存消耗问题,我尝试将分类器的参数n_jobs-1更改为1,没有更多的运气。

查看MLEngineTrainingOperator的代码和文档,我添加了一个自定义的scale_tier和一个master_type n1-highmem-8、8个CPU和52GB的RAM,如下所示:

with models.DAG(JOB_NAME,
                schedule_interval=None,
                default_args=default_args) as dag:

    # Tasks definition
    training_op = MLEngineTrainingOperator(
        task_id='submit_job_for_training',
        project_id=PROJECT,
        job_id=job_id,
        package_uris=[os.path.join(TRAINER_BIN)],
        training_python_module=TRAINER_MODULE,
        runtime_version=RUNTIME_VERSION,
        region='europe-west1',
        master_type="n1-highmem-8",
        scale_tier="custom",
        training_args=[
            '--base-dir={}'.format(BASE_DIR),
            '--event-date=20200116',
        ],
        python_version='3.5')
    training_op

这导致另一个错误:

ERROR - <HttpError 400 when requesting https://ml.googleapis.com/v1/projects/MY_PROJECT/jobs?alt=json returned "Field: master_type Error: Master type must be specified for the CUSTOM scale tier.">

我不知道出什么问题了,但是看来这不是解决问题的方法。

编辑:使用命令行,我设法启动作业:

gcloud ai-platform jobs submit training training_job_name --packages=gs://path/to/package/package.tar.gz --python-version=3.5 --region=europe-west1 --runtime-version=1.14 --module-name=trainer.train --scale-tier=CUSTOM --master-machine-type=n1-highmem-16

但是我想在气流中这样做。

任何帮助将不胜感激。

编辑:我的环境使用的是Apache Airflow的旧版本1.10.3,其中master_type参数不存在。将版本更新到1.10.6解决了此问题

out-of-memory airflow google-cloud-ml
1个回答
0
投票

我的环境使用的是Apache Airflow的旧版本1.10.3,其中不存在master_type参数。将版本更新到1.10.6解决了此问题

© www.soinside.com 2019 - 2024. All rights reserved.