ComputeTarget 클래스

Azure Machine Learning에서 관리되는 모든 컴퓨팅 대상의 추상 부모 클래스입니다.

컴퓨팅 대상은 학습 스크립트를 실행하거나 서비스 배포를 호스트하는 지정된 컴퓨팅 리소스/환경입니다. 이 위치는 로컬 컴퓨터 또는 클라우드 기반 컴퓨팅 리소스일 수 있습니다. 자세한 내용은 What are compute targets in Azure Machine Learning?(Azure Machine Learning에서 컴퓨팅 대상이란?)을 참조하세요.

클래스 ComputeTarget 생성자입니다.

제공된 작업 영역과 연결된 Compute 개체의 클라우드 표현을 검색합니다. 검색된 Compute 개체의 특정 형식에 해당하는 자식 클래스의 instance 반환합니다.

상속
ComputeTarget

생성자

ComputeTarget(workspace, name)

매개 변수

workspace
Workspace
필수

검색할 Compute 개체를 포함하는 작업 영역 개체입니다.

name
str
필수

검색할 Compute 개체의 이름입니다.

workspace
Workspace
필수

검색할 Compute 개체를 포함하는 작업 영역 개체입니다.

name
str
필수

검색할 Compute 개체의 이름입니다.

설명

ComputeTarget 생성자를 사용하여 제공된 작업 영역과 연결된 Compute 개체의 클라우드 표현을 검색합니다. 이 생성자는 검색된 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

작업을 삭제할 예정인지 여부를 나타냅니다.

예외