Ksama Arora

When which compute used?:

Create Compute Targets*

1) Using Python SDK:

Create Compute Instance:

A compute instance can be assigned to one user, as it can’t handle parallel workloads. Can schedule to start/stop compute instance or configure to automatically shut down when been idle for set amount of time

IMP:

from azure.ai.ml.entities import ComputeInstance

# Compute Instances need to have a unique name across the region.
ci_basic_name = "basic-ci-12345"
ci_basic = ComputeInstance(
    name=ci_basic_name, 
    size="STANDARD_DS3_v2"
)

ml_client.begin_create_or_update(ci_basic).result()

Create a Compute Cluster:

3 main parameters to be defined:

NOTE: Increase the idle time before scale down to keep the compute cluster active between pipeline runs, minimizing start-up time for rapid experimentation.

3 scenarios to use compute cluster

from azure.ai.ml.entities import AmlCompute

cluster_basic = AmlCompute(
    name="cpu-cluster",
    type="amlcompute",
    size="STANDARD_DS3_v2",
    location="westus",
    min_instances=0,
    max_instances=2,
    idle_time_before_scale_down=120,
    tier="low_priority",
)
ml_client.begin_create_or_update(cluster_basic).result()
from azure.ai.ml import command

# configure job
job = command(
    code="./src",
    command="python diabetes-training.py",
    environment="AzureML-sklearn-0.24-ubuntu18.04-py37-cpu@latest",
    compute="cpu-cluster",
    display_name="train-with-cluster",
    experiment_name="diabetes-training"
    )

# submit job
returned_job = ml_client.create_or_update(job)
aml_url = returned_job.studio_url
print("Monitor your job at", aml_url)

2) Using Azure CLI:*

Create Compute Instance

az ml compute create --name "ci1572" --size STANDARD_DS11_V2 --type ComputeInstance -w mlw-dp100-labs -g rg-dp100-labs

Create Compute Cluster

az ml compute create --name "aml-cluster" --size STANDARD_DS11_V2 --max-instances 2 --type AmlCompute -w mlw-dp100-labs -g rg-dp100-labs

Create compute target (NOTE IMP)