RemoteCompute クラス

Azure Machine Learning で使用するリモート コンピューティング先を管理します。

Azure Machine Learning は、ワークスペースへのリモート コンピューティング リソースのアタッチの使用をサポートしています。 リモート リソースは、そのリソースから Azure Machine Learning にアクセスできる限り、Azure VM、組織内のリモート サーバー、またはオンプレミスにすることができます。 詳細については、「Azure Machine Learning でのコンピューティング先とは」を参照してください。

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

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

継承
RemoteCompute

コンストラクター

RemoteCompute(workspace, name)

パラメーター

workspace
Workspace
必須

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

name
str
必須

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

workspace
Workspace
必須

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

name
str
必須

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

注釈

次の Azure リージョンは、仮想マシンまたは HDInsight クラスターのパブリック IP アドレスを使用したコンピューティング先のアタッチをサポートしていません。

  • 米国東部

  • 米国西部 2

  • 米国中南部

代わりに、VM または HDInsight クラスターの Azure Resource Manager ID を使用してください。 VM のリソース ID は、/subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.Compute/virtualMachines/<vm_name> という文字列形式でサブスクリプション ID、リソース グループ名、および VM 名を使用して作成できます。

次の例は、Data Science Virtual Machine (DSVM) を作成し、コンピューティング先としてアタッチする方法を示しています。


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

   username = os.getenv('AZUREML_DSVM_USERNAME', default='<my_username>')
   address = os.getenv('AZUREML_DSVM_ADDRESS', default='<ip_address_or_fqdn>')

   compute_target_name = 'cpudsvm'
   # if you want to connect using SSH key instead of username/password you can provide parameters private_key_file and private_key_passphrase
   try:
       attached_dsvm_compute = RemoteCompute(workspace=ws, name=compute_target_name)
       print('found existing:', attached_dsvm_compute.name)
   except ComputeTargetException:
       attach_config = RemoteCompute.attach_configuration(address=address,
                                                          ssh_port=22,
                                                          username=username,
                                                          private_key_file='./.ssh/id_rsa')


   # Attaching a virtual machine using the public IP address of the VM is no longer supported.
   # Instead, use resourceId of the VM.
   # The resourceId of the VM can be constructed using the following string format:
   # /subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.Compute/virtualMachines/<vm_name>.
   # You can also use subscription_id, resource_group and vm_name without constructing resourceId.
       attach_config = RemoteCompute.attach_configuration(resource_id='<resource_id>',
                                                          ssh_port=22,
                                                          username='username',
                                                          private_key_file='./.ssh/id_rsa')

       attached_dsvm_compute = ComputeTarget.attach(ws, compute_target_name, attach_config)

       attached_dsvm_compute.wait_for_completion(show_output=True)

完全なサンプルは、https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/training/train-on-remote-vm/train-on-remote-vm.ipynb から入手できます

メソッド

attach

非推奨。 代わりに、attach_configuration メソッドを使用してください。

既存のリモート コンピューティング リソースを、指定されたワークスペースに関連付けます。

attach_configuration

リモート コンピューティング先をアタッチするための構成オブジェクトを作成します。

VM のパブリック IP アドレスを使用した仮想マシンのアタッチはサポートされなくなりました。 代わりに、VM の resourceId を使用してください。 VM の resourceId は、"/subscriptions/<subscription_id>/resourceGroups/<resource_group>/ providers/Microsoft.Compute/virtualMachines/<vm_name>" という文字列形式を使用して作成できます。

また、resourceId を作成せずに subscription_id、resource_group、および vm_name を使用することもできます。 詳細については、「https://aka.ms/azureml-compute-vm」を参照してください。

delete

削除は、RemoteCompute オブジェクトに対してサポートされていません。 代わりに detach を使用してください

deserialize

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

detach

関連付けられたワークスペースから RemoteCompute オブジェクトをデタッチします。

基になるクラウド オブジェクトは削除されません。関連付けのみが削除されます。

get_credentials

RemoteCompute ターゲットの資格情報を取得します。

refresh_state

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

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

serialize

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

attach

非推奨。 代わりに、attach_configuration メソッドを使用してください。

既存のリモート コンピューティング リソースを、指定されたワークスペースに関連付けます。

static attach(workspace, name, username, address, ssh_port=22, password='', private_key_file='', private_key_passphrase='')

パラメーター

workspace
Workspace
必須

コンピューティング リソースを関連付けるワークスペース オブジェクト。

name
str
必須

指定されたワークスペース内のコンピューティング リソースに関連付ける名前。 アタッチされるコンピューティング リソースの名前と一致する必要はありません。

username
str
必須

リソースにアクセスするために必要なユーザー名。

address
str
必須

アタッチするリソースのアドレス。

ssh_port
int
既定値: 22

リソースに対して公開されているポート。 既定値は 22 です。

password
str
必須

リソースにアクセスするために必要なパスワード。

private_key_file
str
必須

リソースの秘密キーを含むファイルへのパス。

private_key_passphrase
str
必須

リソースにアクセスするために必要な秘密キー フレーズ。

戻り値

コンピューティング オブジェクトの RemoteCompute オブジェクト表現。

の戻り値の型 :

例外

attach_configuration

リモート コンピューティング先をアタッチするための構成オブジェクトを作成します。

VM のパブリック IP アドレスを使用した仮想マシンのアタッチはサポートされなくなりました。 代わりに、VM の resourceId を使用してください。 VM の resourceId は、"/subscriptions/<subscription_id>/resourceGroups/<resource_group>/ providers/Microsoft.Compute/virtualMachines/<vm_name>" という文字列形式を使用して作成できます。

また、resourceId を作成せずに subscription_id、resource_group、および vm_name を使用することもできます。 詳細については、「https://aka.ms/azureml-compute-vm」を参照してください。

static attach_configuration(username, subscription_id=None, resource_group=None, vm_name=None, resource_id=None, address=None, ssh_port=22, password='', private_key_file='', private_key_passphrase='')

パラメーター

username
str
必須

リソースにアクセスするために必要なユーザー名。

subscription_id
str
既定値: None

仮想マシンが配置された Azure サブスクリプション ID。

resource_group
str
既定値: None

仮想マシンが配置されたリソース グループの名前。

vm_name
str
既定値: None

仮想マシン名。

resource_id
str
既定値: None

既存のリソースの Azure Resource Manager (ARM) リソース ID。

address
str
既定値: None

既存のリソースのアドレス。

ssh_port
int
既定値: 22

リソースに対して公開されているポート。 既定値は 22 です。

password
str
必須

リソースにアクセスするために必要なパスワード。

private_key_file
str
必須

リソースの秘密キーを含むファイルへのパス。

private_key_passphrase
str
必須

リソースにアクセスするために必要な秘密キー フレーズ。

戻り値

コンピューティング オブジェクトをアタッチするときに使用される構成オブジェクト。

の戻り値の型 :

例外

delete

削除は、RemoteCompute オブジェクトに対してサポートされていません。 代わりに detach を使用してください

delete()

例外

deserialize

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

static deserialize(workspace, object_dict)

パラメーター

workspace
Workspace
必須

RemoteCompute オブジェクトが関連付けられたワークスペース オブジェクト。

object_dict
dict
必須

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

戻り値

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

の戻り値の型 :

例外

注釈

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

detach

関連付けられたワークスペースから RemoteCompute オブジェクトをデタッチします。

基になるクラウド オブジェクトは削除されません。関連付けのみが削除されます。

detach()

例外

get_credentials

RemoteCompute ターゲットの資格情報を取得します。

get_credentials()

戻り値

RemoteCompute ターゲットの資格情報。

の戻り値の型 :

例外

refresh_state

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

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

refresh_state()

例外

serialize

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

serialize()

戻り値

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

の戻り値の型 :

例外