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

时间:2019-01-18 13:16:51

标签: azure-machine-learning-workbench azure-machine-learning-service

我正在将Azure Machine Learning Service与azureml-sdk python库一起使用。

我正在使用azureml.core版本1.0.8

我正在关注本https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-create-your-first-pipeline教程。

当我使用Azure Compute资源时,它已经开始工作。但我想在本地运行。

我收到以下错误

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。

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:-1)

根据文档,可以在本地机器上进行训练(例如在开发期间)并且非常容易:how-to-set-up-training-targets

我在我的 Windows 计算机上按如下方式执行此操作:

定义本地环境:

# deployment.py

# …

INSTALLED_APPS += ['debug_toolbar']

# …

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:\Dev\tutorial\venv\Scripts\python.exe' 似乎是将脚本定向到我的本地环境的神奇词。

compute_target='local'

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

另外,我需要在我的本地机器上安装这些包:

  • azureml-defaults
  • 包装