ComputeTarget 클래스
Azure Machine Learning에서 관리하는 모든 컴퓨팅 대상에 대한 추상 부모 클래스입니다.
컴퓨팅 대상은 학습 스크립트를 실행하거나 서비스 배포를 호스트하는 지정된 컴퓨팅 리소스/환경입니다. 이 위치는 로컬 컴퓨터 또는 클라우드 기반 컴퓨팅 리소스일 수 있습니다. 자세한 내용은 Azure Machine Learning의 컴퓨팅 대상을 참조하세요.
클래스 ComputeTarget 생성자입니다.
제공된 작업 영역과 연결된 Compute 개체의 클라우드 표현을 검색합니다. 검색된 Compute 개체의 특정 형식에 해당하는 자식 클래스의 인스턴스를 반환합니다.
생성자
ComputeTarget(workspace, name)
매개 변수
설명
ComputeTarget 생성자를 사용하여 제공된 작업 영역과 연결된 Compute 개체의 클라우드 표현을 검색합니다. 생성자는 검색된 Compute 개체의 특정 형식에 해당하는 자식 클래스의 인스턴스를 반환합니다. Compute 개체를 찾을 수 없으면 발생 ComputeTargetException 합니다.
attach |
지정된 이름 및 구성 정보를 사용하여 Compute 개체를 작업 영역에 연결합니다. |
create |
컴퓨팅 유형 및 관련 구성을 지정하여 Compute 개체를 프로비전합니다. 이 메서드는 기존 컴퓨팅 대상을 연결하는 대신 새 컴퓨팅 대상을 만듭니다. |
delete |
연결된 작업 영역에서 Compute 개체를 제거합니다. 이 추상 메서드는 의 ComputeTarget자식 클래스에 의해 구현 됩니다. |
deserialize |
JSON 개체를 Compute 개체로 변환합니다. |
detach |
연결된 작업 영역에서 Compute 개체를 분리합니다. 이 추상 메서드는 의 ComputeTarget자식 클래스에 의해 구현 됩니다. 기본 클라우드 개체는 삭제되지 않고 해당 연결만 제거됩니다. |
get_status |
Compute 개체의 현재 프로비전 상태를 검색합니다. |
list |
작업 영역 내의 모든 ComputeTarget 개체를 나열합니다. 컴퓨팅의 특정 형식에 해당하는 인스턴스화된 자식 개체 목록을 반환합니다. 개체는 .의 ComputeTarget자식입니다. |
refresh_state |
개체의 속성에 대한 현재 위치 업데이트를 수행합니다. 해당 클라우드 개체의 현재 상태에 따라 속성을 업데이트합니다. 컴퓨팅 상태의 수동 폴링에 유용합니다. 이 추상 메서드는 의 ComputeTarget자식 클래스에 의해 구현 됩니다. |
serialize |
이 Compute 개체를 JSON 직렬화된 사전으로 변환합니다. |
wait_for_completion |
클러스터에서 현재 프로비전 작업이 완료되기를 기다립니다. 이 메서드는 ComputeTargetException 컴퓨팅 개체를 폴링하는 데 문제가 있는 경우를 반환합니다. |
attach
지정된 이름 및 구성 정보를 사용하여 Compute 개체를 작업 영역에 연결합니다.
static attach(workspace, name, attach_configuration)
매개 변수
Name | Description |
---|---|
workspace
필수
|
Compute 개체를 연결할 작업 영역 개체입니다. |
name
필수
|
Compute 개체와 연결할 이름입니다. |
attach_configuration
필수
|
연결할 Compute 개체의 형식과 구성 방법을 결정하는 데 사용되는 ComputeTargetAttachConfiguration 개체입니다. |
반환
형식 | Description |
---|---|
연결된 개체의 형식에 해당하는 ComputeTarget 자식의 인스턴스입니다. |
예외
형식 | Description |
---|---|
설명
매개 변수 attach_configuration
에 전달할 개체의 형식은 ComputeTargetAttachConfiguration 모든 자식 클래스의 함수를 사용하여 attach_configuration
빌드된 개체입니다 ComputeTarget.
다음 예제에서는 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)
매개 변수
Name | Description |
---|---|
workspace
필수
|
Compute 개체를 만들 작업 영역 개체입니다. |
name
필수
|
Compute 개체와 연결할 이름입니다. |
provisioning_configuration
필수
|
프로비전할 Compute 개체의 형식과 구성 방법을 결정하는 데 사용되는 ComputeTargetProvisioningConfiguration 개체입니다. |
반환
형식 | Description |
---|---|
프로비전된 개체의 형식에 해당하는 ComputeTarget 자식의 인스턴스입니다. |
예외
형식 | Description |
---|---|
설명
프로비전된 개체의 형식은 제공된 프로비전 구성에 따라 결정됩니다.
다음 예제에서는 프로비전된 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)
매개 변수
Name | Description |
---|---|
workspace
필수
|
Compute 개체가 연결된 작업 영역 개체입니다. |
object_dict
필수
|
Compute 개체로 변환할 JSON 개체입니다. |
반환
형식 | Description |
---|---|
제공된 JSON 개체의 Compute 표현입니다. |
설명
ComputeTargetException 제공된 작업 영역이 Compute와 연결된 작업 영역이 아닌 경우 발생합니다.
detach
연결된 작업 영역에서 Compute 개체를 분리합니다.
이 추상 메서드는 의 ComputeTarget자식 클래스에 의해 구현 됩니다. 기본 클라우드 개체는 삭제되지 않고 해당 연결만 제거됩니다.
abstract detach()
get_status
Compute 개체의 현재 프로비전 상태를 검색합니다.
get_status()
반환
형식 | Description |
---|---|
현재 |
설명
반환되는 값은 ProvisioningState에 대한 Azure REST API 참조에 나열됩니다.
list
작업 영역 내의 모든 ComputeTarget 개체를 나열합니다.
컴퓨팅의 특정 형식에 해당하는 인스턴스화된 자식 개체 목록을 반환합니다. 개체는 .의 ComputeTarget자식입니다.
static list(workspace)
매개 변수
Name | Description |
---|---|
workspace
필수
|
나열할 개체를 포함하는 작업 영역 개체입니다. |
반환
형식 | Description |
---|---|
작업 영역 내의 컴퓨팅 대상 목록입니다. |
예외
형식 | Description |
---|---|
refresh_state
개체의 속성에 대한 현재 위치 업데이트를 수행합니다.
해당 클라우드 개체의 현재 상태에 따라 속성을 업데이트합니다. 컴퓨팅 상태의 수동 폴링에 유용합니다.
이 추상 메서드는 의 ComputeTarget자식 클래스에 의해 구현 됩니다.
abstract refresh_state()
serialize
이 Compute 개체를 JSON 직렬화된 사전으로 변환합니다.
abstract serialize()
반환
형식 | Description |
---|---|
이 Compute 개체의 JSON 표현입니다. |
wait_for_completion
클러스터에서 현재 프로비전 작업이 완료되기를 기다립니다.
이 메서드는 ComputeTargetException 컴퓨팅 개체를 폴링하는 데 문제가 있는 경우를 반환합니다.
wait_for_completion(show_output=False, is_delete_operation=False)
매개 변수
Name | Description |
---|---|
show_output
|
자세한 출력을 제공할지 여부를 나타냅니다. Default value: False
|
is_delete_operation
|
작업이 삭제를 위한 것인지 여부를 나타냅니다. Default value: False
|
예외
형식 | Description |
---|---|