RemoteCompute 類別
管理遠端計算目標,以用於 Azure Machine Learning。
Azure Machine Learning 支援使用將遠端計算資源附加至您的工作區。 只要 Azure Machine Learning 可存取資源,遠端資源可以是 Azure VM、組織中的遠端伺服器或內部部署。 如需詳細資訊,請參閱 什麼是 Azure Machine Learning 中的計算目標?
類別 ComputeTarget 建構函式。
擷取與所提供工作區相關聯之 Compute 物件的雲端標記法。 傳回對應至所擷取之 Compute 物件之特定型別之子類別的實例。
- 繼承
-
RemoteCompute
建構函式
RemoteCompute(workspace, name)
參數
備註
下列 Azure 區域不支援使用虛擬機器或 HDInsight 叢集的公用 IP 位址來連結計算目標。
美國東部
美國西部 2
美國中南部
請改用 VM 或 HDInsight 叢集的 Azure Resource Manager識別碼。 您可以使用訂用帳戶識別碼、資源組名和 VM 名稱,使用下列字串格式來建構 VM 的資源識別碼:/subscriptions/ < subscription_id > /resourceGroups/ < resource_group > /providers/Microsoft.Compute/virtualMachines/ < vm_name > 。
下列範例示範如何建立和附加資料科學虛擬機器 (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)
方法
attach |
已淘汰。 請改用 將現有的遠端計算資源與提供的工作區產生關聯。 |
attach_configuration |
建立用來附加遠端計算目標的組態物件。 不再支援使用 VM 的公用 IP 位址連結虛擬機器。 請改用 VM 的 resourceId。 VM 的 resourceId 可以使用下列字串格式來建構:「/subscriptions/ < subscription_id/resourceGroups/ < resource_group >> / providers/Microsoft.Compute/virtualMachines/ < vm_name > 」。 您也可以使用 subscription_id、resource_group 和 vm_name,而不需要建構 resourceId。 如需詳細資訊,請參閱 https://aka.ms/azureml-compute-vm 。 |
delete |
RemoteCompute 物件不支援 Delete。 請改用 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='')
參數
傳回
計算物件的 RemoteCompute 物件表示。
傳回類型
例外狀況
attach_configuration
建立用來附加遠端計算目標的組態物件。
不再支援使用 VM 的公用 IP 位址連結虛擬機器。 請改用 VM 的 resourceId。 VM 的 resourceId 可以使用下列字串格式來建構:「/subscriptions/ < subscription_id/resourceGroups/ < resource_group >> / providers/Microsoft.Compute/virtualMachines/ < vm_name > 」。
您也可以使用 subscription_id、resource_group 和 vm_name,而不需要建構 resourceId。 如需詳細資訊,請參閱 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='')
參數
傳回
附加 Compute 物件時要使用的組態物件。
傳回類型
例外狀況
delete
deserialize
將 JSON 物件轉換成 RemoteCompute 物件。
static deserialize(workspace, object_dict)
參數
傳回
所提供 JSON 物件的 RemoteCompute 表示。
傳回類型
例外狀況
備註
ComputeTargetException如果提供的工作區不是計算相關聯的工作區,則引發 。
detach
get_credentials
擷取 RemoteCompute 目標的認證。
get_credentials()
傳回
RemoteCompute 目標的認證。
傳回類型
例外狀況
refresh_state
serialize
將此 RemoteCompute 物件轉換成 JSON 序列化字典。
serialize()
傳回
這個 RemoteCompute 物件的 JSON 表示。
傳回類型
例外狀況
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應