无法在 MLEngineTrainingOperator 中指定 master_type

unable to specify master_type in MLEngineTrainingOperator

我正在使用气流来安排管道,该管道将导致使用 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 解决了这个问题

我的环境使用旧版本的 apache airflow,1.10.3,其中 master_type 参数不存在。将版本更新到 1.10.6 解决了这个问题