BatchCompute 類別

管理 Azure Machine Learning 中的 Batch 計算目標。

Azure Batch 可用來在雲端有效率地執行大規模的平行和高效能運算 (HPC) 應用程式。 BatchCompute 用於 Azure Machine Learning 管線,以使用 AzureBatchStep 將作業提交至機器Azure Batch集區。 如需詳細資訊,請參閱 什麼是 Azure Machine Learning 中的計算目標?

類別 ComputeTarget 建構函式。

擷取與所提供工作區相關聯的 Compute 物件的雲端標記法。 傳回對應至所擷取之 Compute 物件之特定類型的子類別實例。

繼承
BatchCompute

建構函式

BatchCompute(workspace, name)

參數

workspace
Workspace
必要

包含要擷取之 BatchCompute 物件的工作區物件。

name
str
必要

要擷取的 BatchCompute 物件名稱。

workspace
Workspace
必要

包含要擷取之 Compute 物件的工作區物件。

name
str
必要

要擷取之 Compute 物件的 名稱。

備註

在使用帳戶之前,請先建立Azure Batch帳戶。 若要建立一個帳戶,請參閱使用 Azure 入口網站建立 Batch 帳戶

下列範例示範如何使用 將Azure Batch計算帳戶附加至工作區 attach_configuration


   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 物件不支援 Delete。 請改用 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 資源識別碼。

傳回

附加 Compute 物件時要使用的組態物件。

傳回類型

delete

BatchCompute 物件不支援 Delete。 請改用 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 表示。

傳回類型