在本地运行 Azure 机器学习服务管道



我正在使用Azure机器学习服务与azureml-sdk python库。

我正在使用 azureml.core 版本 1.0.8

我正在遵循这个 https://learn.microsoft.com/en-us/azure/machine-learning/service/how-to-create-your-first-pipeline 教程。

当我使用 Azure 计算资源时,我已经让它工作了。但我想在本地运行它。

我收到以下错误

raise ErrorResponseException(self._deserialize, response)
azureml.pipeline.core._restclients.aeva.models.error_response.ErrorResponseException: (BadRequest) Response status code does not indicate success: 400 (Bad Request).
Trace id: [uuid], message: Can't build command text for [train.py], moduleId [uuid] executionId [id]: Assignment for parameter Target is not specified

我的代码如下所示:

run_config = RunConfiguration()
compute_target = LocalTarget()
run_config.target = LocalTarget()    
run_config.environment.python.conda_dependencies = CondaDependencies(conda_dependencies_file_path='environment.yml')
run_config.environment.python.interpreter_path = 'C:/Projects/aml_test/.conda/envs/aml_test_env/python.exe'
run_config.environment.python.user_managed_dependencies = True
run_config.environment.docker.enabled = False
trainStep = PythonScriptStep(
    script_name="train.py",
    compute_target=compute_target,
    source_directory='.',
    allow_reuse=False,
    runconfig=run_config
)
steps = [trainStep]
# Build the pipeline
pipeline = Pipeline(workspace=ws, steps=[steps])
pipeline.validate()
experiment = Experiment(ws, 'Test')
# Fails, locally, works on Azure Compute
run = experiment.submit(pipeline)

# Works both locally and on Azure Compute
src = ScriptRunConfig(source_directory='.', script='train.py', run_config=run_config)
run = experiment.submit(src)

train.py是一个非常简单的独立脚本,仅依赖于近似 pi 的 numpy。

本地计算不能与 ML 管道一起使用。请参阅此文章。

根据文档,在本地计算机上进行培训(例如在开发期间)是可能的,并且非常容易: 如何设置培训目标

我在我的Windows计算机上执行此操作,如下所示:

定义本地环境:

sklearn_env = Environment("user-managed-env")
sklearn_env.python.user_managed_dependencies = True
# You can choose a specific Python environment by pointing to a Python path 
sklearn_env.python.interpreter_path = r'C:DevtutorialvenvScriptspython.exe'

compute_target='local'似乎是将脚本引导到我本地环境的神奇词。

src = ScriptRunConfig(source_directory=script_folder,
script='train_iris.py',
arguments=[dataset.as_named_input('iris')],
compute_target='local',
environment=sklearn_env)

然后,我需要确保我的本地环境具有脚本所需的所有依赖项。

此外,我需要在本地计算机上安装这些软件包:

  • Azureml-defaults
  • 包装

相关内容

最新更新