ComputeTarget クラス

Azure Machine Learning によって管理されるすべてのコンピューティング先の抽象親クラス。

コンピューティング ターゲットとは、トレーニング スクリプトを実行したり、サービスのデプロイをホストしたりする、指定されたコンピューティング リソース/環境のことです。 この場所は、ローカル コンピューターでも、クラウドベースのコンピューティング リソースでもかまいません。 詳細については、Azure Machine Learning でのコンピューティング先 に関する記事をご覧ください。

ComputeTarget クラスコンストラクター。

指定されたワークスペースに関連付けられている Compute オブジェクトのクラウド表現を取得します。 取得した Compute オブジェクトの特定の型に対応する子クラスのインスタンスを返します。

継承
ComputeTarget

コンストラクター

ComputeTarget(workspace, name)

パラメーター

workspace
Workspace
必須

取得する Compute オブジェクトを含むワークスペース オブジェクト。

name
str
必須

取得する Compute オブジェクトの名前。

workspace
Workspace
必須

取得する Compute オブジェクトを含むワークスペース オブジェクト。

name
str
必須

取得する Compute オブジェクトの 名前。

注釈

指定したワークスペースに関連付けられている Compute オブジェクトのクラウド表現を取得するには、ComputeTarget コンストラクターを使用します。 このコンストラクターは、取得した Compute オブジェクトの特定の型に対応する子クラスのインスタンスを返します。 Compute オブジェクトが見つからない場合は、ComputeTargetException が発生します。

メソッド

attach

指定された名前と構成情報を使用して、Compute オブジェクトをワークスペースにアタッチします。

create

コンピューティングの種類と関連する構成を指定して、Compute オブジェクトをプロビジョニングします。

このメソッドは、既存のコンピューティング ターゲットをアタッチするのではなく、新しいコンピューティング ターゲットを作成します。

delete

Compute オブジェクトをその関連付けられているワークスペースから削除します。

この抽象メソッドは、ComputeTarget の子クラスによって実装されます。

deserialize

JSON オブジェクトを Compute オブジェクトに変換します。

detach

Compute オブジェクトをその関連付けられているワークスペースからデタッチします。

この抽象メソッドは、ComputeTarget の子クラスによって実装されます。 基になるクラウド オブジェクトは削除されません。関連付けのみが削除されます。

get_status

Compute オブジェクトの現在のプロビジョニング状態を取得します。

list

ワークスペース内のすべての ComputeTarget オブジェクトをリストします。

Compute の特定の型に対応するインスタンス化された子オブジェクトのリストを返します。 オブジェクトは ComputeTarget の子です。

refresh_state

オブジェクトのプロパティのインプレース更新を実行します。

対応するクラウド オブジェクトの現在の状態に基づいてプロパティを更新します。 これは、コンピューティング状態を手動でポーリングする場合に便利です。

この抽象メソッドは、ComputeTarget の子クラスによって実装されます。

serialize

この Compute オブジェクトを JSON のシリアル化された辞書に変換します。

wait_for_completion

クラスターでの現在のプロビジョニング操作が完了するまで待ちます。

Compute オブジェクトのポーリングに問題がある場合、このメソッドは ComputeTargetException を返します。

attach

指定された名前と構成情報を使用して、Compute オブジェクトをワークスペースにアタッチします。

static attach(workspace, name, attach_configuration)

パラメーター

workspace
Workspace
必須

Compute オブジェクトをアタッチする先のワークスペース オブジェクト。

name
str
必須

Compute オブジェクトに関連付ける名前。

attach_configuration
ComputeTargetAttachConfiguration
必須

アタッチする Compute オブジェクトの型とその構成方法を決定するために使用される ComputeTargetAttachConfiguration オブジェクト。

戻り値

アタッチされたオブジェクトの型に対応する ComputeTarget の子のインスタンス。

の戻り値の型 :

例外

注釈

パラメーター attach_configuration に渡すオブジェクトの型は、ComputeTarget の任意の子クラスで attach_configuration 関数を使用して作成された ComputeTargetAttachConfiguration オブジェクトです。

次の例は、AdlaCompute の attach_configuration メソッドを使用して、ADLA アカウントをワークスペースにアタッチする方法を示しています。


   adla_compute_name = 'testadl' # Name to associate with new compute in workspace

   # ADLA account details needed to attach as compute to workspace
   adla_account_name = "<adla_account_name>" # Name of the Azure Data Lake Analytics account
   adla_resource_group = "<adla_resource_group>" # Name of the resource group which contains this account

   try:
       # check if already attached
       adla_compute = AdlaCompute(ws, adla_compute_name)
   except ComputeTargetException:
       print('attaching adla compute...')
       attach_config = AdlaCompute.attach_configuration(resource_group=adla_resource_group, account_name=adla_account_name)
       adla_compute = ComputeTarget.attach(ws, adla_compute_name, attach_config)
       adla_compute.wait_for_completion()

   print("Using ADLA compute:{}".format(adla_compute.cluster_resource_id))
   print("Provisioning state:{}".format(adla_compute.provisioning_state))
   print("Provisioning errors:{}".format(adla_compute.provisioning_errors))

完全なサンプルは、https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-use-adla-as-compute-target.ipynb から入手できます

create

コンピューティングの種類と関連する構成を指定して、Compute オブジェクトをプロビジョニングします。

このメソッドは、既存のコンピューティング ターゲットをアタッチするのではなく、新しいコンピューティング ターゲットを作成します。

static create(workspace, name, provisioning_configuration)

パラメーター

workspace
Workspace
必須

Compute オブジェクトを作成するワークスペース オブジェクト。

name
str
必須

Compute オブジェクトに関連付ける名前。

provisioning_configuration
ComputeTargetProvisioningConfiguration
必須

プロビジョニングする Compute オブジェクトの型とその構成方法を決定するために使用される ComputeTargetProvisioningConfiguration オブジェクト。

戻り値

プロビジョニングされたオブジェクトの型に対応する ComputeTarget の子のインスタンス。

の戻り値の型 :

例外

注釈

プロビジョニングされるオブジェクトの型は、指定されたプロビジョニング構成によって決まります。

次の例では、AmlCompute によってプロビジョニングされる永続的なコンピューティング ターゲットが作成されます。 この例の provisioning_configuration パラメーターは AmlComputeProvisioningConfiguration 型です。


   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 から入手できます

delete

Compute オブジェクトをその関連付けられているワークスペースから削除します。

この抽象メソッドは、ComputeTarget の子クラスによって実装されます。

abstract delete()

例外

注釈

このオブジェクトが Azure Machine Learning によって作成された場合は、対応するクラウド ベースのオブジェクトも削除されます。 このオブジェクトが外部で作成され、ワークスペースにのみアタッチされる場合は、このメソッドによって例外が発生し、何も変更されません。

deserialize

JSON オブジェクトを Compute オブジェクトに変換します。

abstract static deserialize(workspace, object_dict)

パラメーター

workspace
Workspace
必須

Compute オブジェクトが関連付けられているワークスペース オブジェクト。

object_dict
dict
必須

Compute オブジェクトに変換する JSON オブジェクト。

戻り値

指定された JSON オブジェクトの Compute 表現。

の戻り値の型 :

例外

注釈

指定されたワークスペースが、Compute が関連付けられているワークスペースでない場合、ComputeTargetException を発生させます。

detach

Compute オブジェクトをその関連付けられているワークスペースからデタッチします。

この抽象メソッドは、ComputeTarget の子クラスによって実装されます。 基になるクラウド オブジェクトは削除されません。関連付けのみが削除されます。

abstract detach()

例外

get_status

Compute オブジェクトの現在のプロビジョニング状態を取得します。

get_status()

戻り値

現在の provisioning_state です。

の戻り値の型 :

str

例外

注釈

返される値は、ProvisioningState の Azure REST API リファレンスに記載されています。

list

ワークスペース内のすべての ComputeTarget オブジェクトをリストします。

Compute の特定の型に対応するインスタンス化された子オブジェクトのリストを返します。 オブジェクトは ComputeTarget の子です。

static list(workspace)

パラメーター

workspace
Workspace
必須

リストするオブジェクトを含むワークスペース オブジェクト。

戻り値

ワークスペース内のコンピューティング ターゲットのリスト。

の戻り値の型 :

例外

refresh_state

オブジェクトのプロパティのインプレース更新を実行します。

対応するクラウド オブジェクトの現在の状態に基づいてプロパティを更新します。 これは、コンピューティング状態を手動でポーリングする場合に便利です。

この抽象メソッドは、ComputeTarget の子クラスによって実装されます。

abstract refresh_state()

例外

serialize

この Compute オブジェクトを JSON のシリアル化された辞書に変換します。

abstract serialize()

戻り値

この Compute オブジェクトの JSON 表現。

の戻り値の型 :

例外

wait_for_completion

クラスターでの現在のプロビジョニング操作が完了するまで待ちます。

Compute オブジェクトのポーリングに問題がある場合、このメソッドは ComputeTargetException を返します。

wait_for_completion(show_output=False, is_delete_operation=False)

パラメーター

show_output
bool
既定値: False

より詳細な出力を提供するかどうかを示します。

is_delete_operation
bool
既定値: False

操作が削除を目的としたものであるかどうかを示します。

例外