BatchCompute 類別
在 Azure Machine Learning 中管理 Batch 計算目標。
Azure Batch 可用來在雲端有效率地執行大規模的平行和高效能運算 (HPC) 應用程式。 BatchCompute 用於 Azure Machine Learning 管線,以使用 AzureBatchStep將作業提交至 Azure Batch 集區的電腦。 如需詳細資訊,請參閱 什麼是 Azure Machine Learning 中的計算目標?
類別 ComputeTarget 建構函式。
擷取與所提供工作區相關聯的 Compute 物件的雲端表示法。 傳回對應至所擷取之 Compute 物件特定型別之子類別的實例。
建構函式
BatchCompute(workspace, name)
參數
| 名稱 | Description |
|---|---|
|
workspace
必要
|
包含要擷取之 BatchCompute 物件的工作區物件。 |
|
name
必要
|
要擷取的 BatchCompute 物件名稱。 |
|
workspace
必要
|
包含要擷取之 Compute 物件的工作區物件。 |
|
name
必要
|
要擷取之 Compute 對象的 名稱。 |
備註
使用 Azure Batch 帳戶之前,請先建立 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))
方法
| 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)
參數
| 名稱 | Description |
|---|---|
|
resource_group
|
Batch 帳戶所在的資源組名。 預設值: None
|
|
account_name
|
Batch 帳戶名稱。 預設值: None
|
|
resource_id
|
所連結計算資源的 Azure 資源識別碼。 預設值: None
|
傳回
| 類型 | Description |
|---|---|
|
附加 Compute 物件時要使用的組態物件。 |
delete
deserialize
將 JSON 物件轉換成 BatchCompute 物件。
static deserialize(workspace, object_dict)
參數
| 名稱 | Description |
|---|---|
|
workspace
必要
|
BatchCompute 對象相關聯的工作區物件。 |
|
object_dict
必要
|
要轉換成 BatchCompute 物件的 JSON 物件。 |
傳回
| 類型 | Description |
|---|---|
|
所提供 JSON 物件的 BatchCompute 表示法。 |
例外狀況
| 類型 | Description |
|---|---|
備註
ComputeTargetException如果提供的工作區不是計算相關聯的工作區,則引發 。
detach
refresh_state
執行物件的屬性就地更新。
此方法會根據對應雲端物件的目前狀態來更新屬性。 這主要用於手動輪詢計算狀態。
refresh_state()