如何在azureml.core.Environment或azureml.core.ScriptRunConfigclass中使用azureml.core.runconfig.DockerConfigurationclass

How to use azureml.core.runconfig.DockerConfiguration class in azureml.core.Environment or azureml.core.ScriptRunConfig class

我使用 Microsoft Azure 机器学习 (Azure-ml) 运行 我的 (python) 实验。

为了指定 VM 和 python 我使用的环境:

from azureml.core import Environment
from azureml.core import ScriptRunConfig

# Other imports and code...

# Specify VM and Python environment:
vm_env = Environment.from_conda_specification(name='my-test-env', file_path=PATH_TO_YAML_FILE)
vm_env.docker.enabled = True
vm_env.docker.base_image = 'mcr.microsoft.com/azureml/openmpi3.1.2-cuda10.2-cudnn7-ubuntu18.04'

# Finally, use the environment in the ScriptRunConfig:
src = ScriptRunConfig(source_directory=DEPLOY_CONTAINER_FOLDER_PATH,
                      script=SCRIPT_FILE_TO_EXECUTE,
                      arguments=EXECUTE_ARGUMENTS,
                      compute_target=compute_target,
                      environment=vm_env)

我收到 vm_env.docker.enabled = True 行的以下警告:

'enabled' is deprecated. Please use the azureml.core.runconfig.DockerConfiguration object with the 'use_docker' param instead.

关于 DockerSection Class and DockerConfiguration Class 的文档对应用 DockerConfiguration Class 不是很清楚。

我不知道如何使用 azureml.core.runconfig.DockerConfiguration 对象。有人可以给我举个例子吗?谢谢!

ScriptRunConfig class 现在接受 docker_runtime_config 参数,这是您传递 DockerConfiguration 对象的地方。

所以,代码看起来像这样:

from azureml.core import Environment
from azureml.core import ScriptRunConfig
from azureml.core.runconfig import DockerConfiguration

# Other imports and code...

# Specify VM and Python environment:
vm_env = Environment.from_conda_specification(name='my-test-env', file_path=PATH_TO_YAML_FILE)
vm_env.docker.base_image = 'mcr.microsoft.com/azureml/openmpi3.1.2-cuda10.2-cudnn7-ubuntu18.04'

docker_config = DockerConfiguration(use_docker=True)

# Finally, use the environment in the ScriptRunConfig:
src = ScriptRunConfig(source_directory=DEPLOY_CONTAINER_FOLDER_PATH,
                      script=SCRIPT_FILE_TO_EXECUTE,
                      arguments=EXECUTE_ARGUMENTS,
                      compute_target=compute_target,
                      environment=vm_env,
                      docker_runtime_config=docker_config)

为使用 RunConfiguration 的任何人添加另一个示例:

变化:

run_config = RunConfiguration()
run_config.environment.docker.enabled = True

收件人:

run_config = RunConfiguration()
docker_config = DockerConfiguration(use_docker=True)
run_config.docker = docker_config

run_config 以后可以用作参数,例如PythonScriptStep.

请注意,docker 属性从内部 environment 直接移动到 RunConfiguration