BatchCompute 类

在 Azure 机器学习中管理 Batch 计算目标。

Azure Batch 用于在云中高效运行大规模并行高性能计算 (HPC) 应用程序。 可以在 Azure 机器学习管道中使用 BatchCompute,以使用 AzureBatchStep 将作业提交到 Azure Batch 计算机池。 有关详细信息,请参阅什么是 Azure 机器学习中的计算目标?

类 ComputeTarget 构造函数。

检索与提供的工作区关联的 Compute 对象的云表示形式。 返回与检索的 Compute 对象的特定类型对应的子类的实例。

继承
BatchCompute

构造函数

BatchCompute(workspace, name)

参数

workspace
Workspace
必需

包含要检索的 BatchCompute 对象的工作区对象。

name
str
必需

要检索的 BatchCompute 对象的名称。

workspace
Workspace
必需

包含要检索的 Compute 对象的工作区对象。

name
str
必需

要检索的 Compute 对象的 的名称。

注解

在使用之前创建 Azure Batch 帐户。 要创建 Batch 帐户,请参阅使用 Azure 门户创建 Batch 帐户

以下示例说明如何使用 attach_configuration 将 Azure Batch 计算帐户附加到工作区。


   batch_compute_name = 'mybatchcompute' # Name to associate with new compute in workspace

   # Batch account details needed to attach as compute to workspace
   batch_account_name = "<batch_account_name>" # Name of the Batch account
   batch_resource_group = "<batch_resource_group>" # Name of the resource group which contains this account

   try:
       # check if already attached
       batch_compute = BatchCompute(ws, batch_compute_name)
   except ComputeTargetException:
       print('Attaching Batch compute...')
       provisioning_config = BatchCompute.attach_configuration(resource_group=batch_resource_group,
                                                               account_name=batch_account_name)
       batch_compute = ComputeTarget.attach(ws, batch_compute_name, provisioning_config)
       batch_compute.wait_for_completion()
       print("Provisioning state:{}".format(batch_compute.provisioning_state))
       print("Provisioning errors:{}".format(batch_compute.provisioning_errors))

   print("Using Batch compute:{}".format(batch_compute.cluster_resource_id))

完整示例可从 https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-how-to-use-azurebatch-to-run-a-windows-executable.ipynb 获取

方法

attach_configuration

创建用于附加 Batch 计算目标的配置对象。

delete

BatchCompute 对象不支持删除操作。 请改用 detach

deserialize

将 JSON 对象转换为 BatchCompute 对象。

detach

将 Batch 对象与其关联的工作区分离。

不会删除基础云对象,只会删除其关联。

refresh_state

执行对象属性的就地更新。

此方法根据相应云对象的当前状态更新属性。 这主要手动轮询计算状态。

serialize

将此 BatchCompute 对象转换为 JSON 序列化字典。

attach_configuration

创建用于附加 Batch 计算目标的配置对象。

static attach_configuration(resource_group=None, account_name=None, resource_id=None)

参数

resource_group
str
默认值: None

Batch 帐户所在的资源组的名称。

account_name
str
默认值: None

Batch 帐户名称。

resource_id
str
默认值: None

要附加的计算资源的 Azure 资源 ID。

返回

要在附加计算对象时使用的配置对象。

返回类型

delete

BatchCompute 对象不支持删除操作。 请改用 detach

delete()

例外

deserialize

将 JSON 对象转换为 BatchCompute 对象。

static deserialize(workspace, object_dict)

参数

workspace
Workspace
必需

BatchCompute 对象关联的工作区对象。

object_dict
dict
必需

要转换为 BatchCompute 对象的 JSON 对象。

返回

所提供的 JSON 对象的 BatchCompute 表示形式。

返回类型

例外

注解

如果提供的工作区不是与计算关联的工作区,则引发 ComputeTargetException

detach

将 Batch 对象与其关联的工作区分离。

不会删除基础云对象,只会删除其关联。

detach()

例外

refresh_state

执行对象属性的就地更新。

此方法根据相应云对象的当前状态更新属性。 这主要手动轮询计算状态。

refresh_state()

serialize

将此 BatchCompute 对象转换为 JSON 序列化字典。

serialize()

返回

此 BatchCompute 对象的 JSON 表示形式。

返回类型