共用方式為


AmlCompute 類別

管理 Azure Machine Learning 中的 Azure Machine Learning 計算。

Azure Machine Learning Compute (AmlCompute) 是受控計算基礎結構,可讓您輕鬆地建立單一或多節點計算。 計算會在工作區區域內建立,做為可以與其他使用者共用的資源。 如需詳細資訊,請參閱 什麼是 Azure Machine Learning 中的計算目標?

類別 ComputeTarget 建構函式。

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

繼承
AmlCompute

建構函式

AmlCompute(workspace, name)

參數

名稱 Description
workspace
必要

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

name
必要
str

要擷取的 AmlCompute 物件名稱。

workspace
必要

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

name
必要
str

要擷取之 Compute 物件的 名稱。

備註

在下列範例中,會建立 所 AmlCompute 布建的永續性計算目標。 provisioning_configuration此範例中的 參數的類型為 AmlComputeProvisioningConfiguration ,其為 的 ComputeTargetProvisioningConfiguration 子類別。


   from azureml.core.compute import ComputeTarget, AmlCompute
   from azureml.core.compute_target import ComputeTargetException

   # Choose a name for your CPU cluster
   cpu_cluster_name = "cpu-cluster"

   # Verify that cluster does not exist already
   try:
       cpu_cluster = ComputeTarget(workspace=ws, name=cpu_cluster_name)
       print('Found existing cluster, use it.')
   except ComputeTargetException:
       compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D2_V2',
                                                              max_nodes=4)
       cpu_cluster = ComputeTarget.create(ws, cpu_cluster_name, compute_config)

   cpu_cluster.wait_for_completion(show_output=True)

完整範例可從 https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/training/train-on-amlcompute/train-on-amlcompute.ipynb

方法

add_identity

為此 AmlCompute 目標新增識別類型和/或識別識別碼。

delete

從相關聯的工作區中移除 AmlCompute 物件。

deserialize

將 JSON 物件轉換成 AmlCompute 物件。

detach

AmlCompute 物件不支援卸離。 請改用 delete

get

傳回計算物件。

get_active_runs

傳回這個計算的執行產生器。

get_status

擷取 AmlCompute 叢集目前的詳細狀態。

list_nodes

取得 (的詳細資料,例如 IP 位址、埠等) 計算目標中的所有計算節點。

list_quotas

根據指定工作區和訂用帳戶的 VMFamily 取得目前指派的工作區配額。

list_usages

取得目前使用量資訊,以及指定工作區和訂用帳戶的 AML 資源限制。

provisioning_configuration

建立組態物件以布建 AmlCompute 目標。

refresh_state

執行 物件的屬性就地更新。

這個方法會根據對應雲端物件的目前狀態來更新屬性。 這主要用於手動輪詢計算狀態。

remove_identity

移除計算上的身分識別。

serialize

將此 AmlCompute 物件轉換成 JSON 序列化字典。

supported_vmsizes

列出區域中支援的 VM 大小。

update

ScaleSettings更新這個 AmlCompute 目標的 。

update_quotas

更新工作區中 VM 系列的配額。

wait_for_completion

等候 AmlCompute 叢集完成布建。

這可以設定為等候最少的節點數目,並在設定的時間之後逾時。

add_identity

為此 AmlCompute 目標新增識別類型和/或識別識別碼。

add_identity(identity_type, identity_id=None)

參數

名稱 Description
identity_type
必要

可能的值包括:

  • SystemAssigned - 系統指派的身分識別

  • UserAssigned - 使用者指派的身分識別。 需要設定身分識別識別碼。

identity_id

使用者指派身分識別的資源識別碼清單。 例如 ['/subscriptions//resourceGroups//providers/Microsoft.ManagedIdentity /userAssignedIdentities/']

預設值: None

備註

只有在identity_type == UserAssigned 時,才應該指定identity_id

delete

從相關聯的工作區中移除 AmlCompute 物件。

delete()

例外狀況

類型 Description

備註

如果此物件是透過 Azure Machine Learning 建立的,則也會刪除對應的雲端式物件。 如果這個物件是在外部建立,而且只附加至工作區,這個方法會 ComputeTargetException 引發 ,而且不會變更任何內容。

deserialize

將 JSON 物件轉換成 AmlCompute 物件。

static deserialize(workspace, object_dict)

參數

名稱 Description
workspace
必要

AmlCompute 物件的工作區物件與 相關聯。

object_dict
必要

要轉換成 AmlCompute 物件的 JSON 物件。

傳回

類型 Description

所提供 JSON 物件的 AmlCompute 標記法。

例外狀況

類型 Description

備註

ComputeTargetException如果提供的工作區不是計算相關聯的工作區,則引發 。

detach

AmlCompute 物件不支援卸離。 請改用 delete

detach()

例外狀況

類型 Description

get

傳回計算物件。

get()

get_active_runs

傳回這個計算的執行產生器。

get_active_runs(type=None, tags=None, properties=None, status=None)

參數

名稱 Description
type
str

依提供的型別篩選所傳回的執行產生器。 如需建立執行類型,請參閱 add_type_provider

預設值: None
tags
strdict

依 「tag」 或 {「tag」: 「value」} 篩選執行

預設值: None
properties
strdict

依 「property」 或 {「property」 篩選執行:「value」}

預設值: None
status
str

執行狀態 - 「執行中」或「已排入佇列」

預設值: None

傳回

類型 Description
<xref:builtin.generator>

~_restclient.models.RunDto 的產生器

get_status

擷取 AmlCompute 叢集目前的詳細狀態。

get_status()

傳回

類型 Description

叢集的詳細狀態物件

list_nodes

取得 (的詳細資料,例如 IP 位址、埠等) 計算目標中的所有計算節點。

list_nodes()

傳回

類型 Description

計算目標中所有計算節點的詳細資料。

list_quotas

根據指定工作區和訂用帳戶的 VMFamily 取得目前指派的工作區配額。

static list_quotas(workspace, location=None)

參數

名稱 Description
workspace
必要
location
str

配額的位置。 如果未指定,則會預設為工作區位置。

預設值: None

傳回

類型 Description

根據 VMFamily 目前指派的工作區配額清單

list_usages

取得目前使用量資訊,以及指定工作區和訂用帳戶的 AML 資源限制。

static list_usages(workspace, show_all=False, location=None)

參數

名稱 Description
workspace
必要
show_all

指定是否需要子資源的詳細使用方式。 預設為 False

預設值: False
location
str

資源的位置。 如果未指定,則會預設為工作區位置。

預設值: None

傳回

類型 Description

目前使用量資訊的清單以及 AML 資源的限制

provisioning_configuration

建立組態物件以布建 AmlCompute 目標。

static provisioning_configuration(vm_size='', vm_priority='dedicated', min_nodes=0, max_nodes=None, idle_seconds_before_scaledown=1800, admin_username=None, admin_user_password=None, admin_user_ssh_key=None, vnet_resourcegroup_name=None, vnet_name=None, subnet_name=None, tags=None, description=None, remote_login_port_public_access='NotSpecified', identity_type=None, identity_id=None, location=None, enable_node_public_ip=True)

參數

名稱 Description
vm_size
必要
str

代理程式 VM 的大小。 如需詳細資訊,請參閱: https://aka.ms/azureml-vm-details 。 請注意,並非所有大小都可在所有區域中使用,如上一個連結中所述。 如果未指定,預設為 Standard_NC6。

vm_priority
str

VM 優先順序、 專用低許可權

預設值: dedicated
min_nodes
int

要在叢集上使用的節點數目下限。 如果未指定,則預設為 0。

預設值: 0
max_nodes
int

要在叢集上使用的節點數目上限。 如果未指定,則預設為 4。

預設值: None
idle_seconds_before_scaledown
int

縮小叢集之前的節點閒置時間 (秒)。 如果未指定,則預設為 1800。

預設值: 1800
admin_username
str

可用來透過 SSH 連線到節點的系統管理員使用者帳戶名稱。

預設值: None
admin_user_password
str

管理員使用者帳戶的密碼。

預設值: None
admin_user_ssh_key
str

管理員使用者帳戶的 SSH 公開金鑰。

預設值: None
vnet_resourcegroup_name
str

虛擬網路所在的資源組名。

預設值: None
vnet_name
str

虛擬網路的名稱。

預設值: None
subnet_name
str

VNet 內子網的名稱。

預設值: None
tags

要提供給計算物件的索引鍵值標記字典。

預設值: None
description
str

要提供給計算物件的描述。

預設值: None
remote_login_port_public_access
str

公用 SSH 埠的狀態。 可能的值包括:

  • 已停用 - 指出叢集的所有節點上已關閉公用 SSH 埠。

  • 已啟用 - 指出叢集的所有節點上都已開啟公用 SSH 埠。

  • NotSpecified - 指出如果已定義 VNet,則叢集的所有節點上都會關閉公用 SSH 埠,否則會開啟所有公用節點。 它只能在叢集建立期間使用這個預設值。 建立之後,將會啟用或停用。

預設值: NotSpecified
identity_type

可能的值包括:

  • SystemAssigned - 系統指派的身分識別

  • UserAssigned - 使用者指派的身分識別。 需要設定身分識別識別碼。

預設值: None
identity_id

使用者指派身分識別的資源識別碼清單。 例如 ['/subscriptions//resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/']

預設值: None
location
str

要布建叢集的位置。

預設值: None
enable_node_public_ip

啟用節點公用 IP。 可能的值包括:

  • True - 啟用節點公用 IP。

  • False - 停用節點公用 IP。

  • NotSpecified - 啟用節點公用 IP。

預設值: True

傳回

類型 Description

建立 Compute 物件時要使用的組態物件。

例外狀況

類型 Description

refresh_state

執行 物件的屬性就地更新。

這個方法會根據對應雲端物件的目前狀態來更新屬性。 這主要用於手動輪詢計算狀態。

refresh_state()

remove_identity

移除計算上的身分識別。

remove_identity(identity_id=None)

參數

名稱 Description
identity_id

使用者指派的身分識別

預設值: None

備註

如果未指定identity_id,系統指派的身分識別會自動移除

serialize

將此 AmlCompute 物件轉換成 JSON 序列化字典。

serialize()

傳回

類型 Description

這個 AmlCompute 物件的 JSON 表示。

supported_vmsizes

列出區域中支援的 VM 大小。

static supported_vmsizes(workspace, location=None)

參數

名稱 Description
workspace
必要
location
str

叢集的位置。 如果未指定,則會預設為工作區位置。

預設值: None

傳回

類型 Description

區域中支援的 VM 大小清單,其中包含 VM、VCPU 和 RAM 的名稱。

update

ScaleSettings更新這個 AmlCompute 目標的 。

update(min_nodes=None, max_nodes=None, idle_seconds_before_scaledown=None)

參數

名稱 Description
min_nodes
int

要在叢集上使用的節點數目下限。

預設值: None
max_nodes
int

要在叢集上使用的節點數目上限。

預設值: None
idle_seconds_before_scaledown
int

相應減少叢集之前的節點閒置時間,以秒為單位。

預設值: None

update_quotas

更新工作區中 VM 系列的配額。

static update_quotas(workspace, vm_family, limit=None, location=None)

參數

名稱 Description
workspace
必要
vm_family
必要
str

VM 系列名稱

limit
int

資源允許的配額上限

預設值: None
location
str

配額的位置。 如果未指定,則會預設為工作區位置。

預設值: None

wait_for_completion

等候 AmlCompute 叢集完成布建。

這可以設定為等候最少的節點數目,並在設定的時間之後逾時。

wait_for_completion(show_output=False, min_node_count=None, timeout_in_minutes=25, is_delete_operation=False)

參數

名稱 Description
show_output

布林值以提供更詳細的輸出。

預設值: False
min_node_count
int

考慮布建完成之前,要等候的節點數目下限。 這不一定等於已使用布建計算的最小節點數目,但不應大於該數目。

預設值: None
timeout_in_minutes
int

在考慮布建失敗之前等待幾分鐘的持續時間。

預設值: 25
is_delete_operation

指出作業是否用於刪除。

預設值: False

例外狀況

類型 Description