Skip to content

Commit d9b417b

Browse files
authored
Merge pull request #211888 from sdgilley/sdg-cluster-v2
compute cluster update to v2
2 parents 4f99367 + 971b89b commit d9b417b

File tree

3 files changed

+130
-78
lines changed

3 files changed

+130
-78
lines changed

articles/machine-learning/how-to-create-attach-compute-cluster.md

Lines changed: 14 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@ ms.custom: devx-track-azurecli, cliv2, sdkv1, event-tier1-build-2022
1010
ms.author: sgilley
1111
author: sdgilley
1212
ms.reviewer: sgilley
13-
ms.date: 08/05/2022
13+
ms.date: 09/20/2022
1414
---
1515

1616
# Create an Azure Machine Learning compute cluster
1717

18-
[!INCLUDE [sdk v1](../../includes/machine-learning-sdk-v1.md)]
19-
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
18+
[!INCLUDE [dev v2](../../includes/machine-learning-dev-v2.md)]
2019

21-
> [!div class="op_single_selector" title1="Select the Azure Machine Learning CLI version you are using:"]
22-
> * [CLI v1](v1/how-to-create-attach-compute-cluster.md)
23-
> * [CLI v2 (current version)](how-to-create-attach-compute-cluster.md)
20+
> [!div class="op_single_selector" title1="Select the Azure Machine Learning CLI or SDK version you are using:"]
21+
> * [v1](v1/how-to-create-attach-compute-cluster.md)
22+
> * [v2 (current version)](how-to-create-attach-compute-cluster.md)
2423
2524
Learn how to create and manage a [compute cluster](concept-compute-target.md#azure-machine-learning-compute-managed) in your Azure Machine Learning workspace.
2625

@@ -40,13 +39,8 @@ In this article, learn how to:
4039

4140
* If using the Python SDK, [set up your development environment with a workspace](how-to-configure-environment.md). Once your environment is set up, attach to the workspace in your Python script:
4241

43-
[!INCLUDE [sdk v1](../../includes/machine-learning-sdk-v1.md)]
42+
[!INCLUDE [connect ws v2](../../includes/machine-learning-connect-ws-v2.md)]
4443

45-
```python
46-
from azureml.core import Workspace
47-
48-
ws = Workspace.from_config()
49-
```
5044

5145
## What is a compute cluster?
5246

@@ -86,14 +80,14 @@ The compute autoscales down to zero nodes when it isn't used. Dedicated VMs ar
8680

8781
# [Python SDK](#tab/python)
8882

89-
To create a persistent Azure Machine Learning Compute resource in Python, specify the **vm_size** and **max_nodes** properties. Azure Machine Learning then uses smart defaults for the other properties.
83+
To create a persistent Azure Machine Learning Compute resource in Python, specify the **size** and **max_instances** properties. Azure Machine Learning then uses smart defaults for the other properties.
9084

91-
* **vm_size**: The VM family of the nodes created by Azure Machine Learning Compute.
92-
* **max_nodes**: The max number of nodes to autoscale up to when you run a job on Azure Machine Learning Compute.
85+
* *size**: The VM family of the nodes created by Azure Machine Learning Compute.
86+
* **max_instances*: The max number of nodes to autoscale up to when you run a job on Azure Machine Learning Compute.
9387

94-
[!INCLUDE [sdk v1](../../includes/machine-learning-sdk-v1.md)]
88+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
9589

96-
[!code-python[](~/aml-sdk-samples/ignore/doc-qa/how-to-set-up-training-targets/amlcompute2.py?name=cpu_cluster)]
90+
[!notebook-python[](~/azureml-examples-main/sdk/resources/compute/compute.ipynb?name=cluster_basic)]
9791

9892
You can also configure several advanced properties when you create Azure Machine Learning Compute. The properties allow you to create a persistent cluster of fixed size, or within an existing Azure Virtual Network in your subscription. See the [AmlCompute class](/python/api/azureml-core/azureml.core.compute.amlcompute.amlcompute) for details.
9993

@@ -177,13 +171,9 @@ Use any of these ways to specify a low-priority VM:
177171

178172
# [Python SDK](#tab/python)
179173

180-
[!INCLUDE [sdk v1](../../includes/machine-learning-sdk-v1.md)]
174+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v1.md)]
181175

182-
```python
183-
compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D2_V2',
184-
vm_priority='lowpriority',
185-
max_nodes=4)
186-
```
176+
[!notebook-python[](~/azureml-examples-main/sdk/resources/compute/compute.ipynb?name=cluster_low_pri)]
187177

188178
# [Azure CLI](#tab/azure-cli)
189179

@@ -211,50 +201,6 @@ In the studio, choose **Low Priority** when you create a VM.
211201

212202
# [Python SDK](#tab/python)
213203

214-
[!INCLUDE [sdk v1](../../includes/machine-learning-sdk-v1.md)]
215-
216-
* Configure managed identity in your provisioning configuration:
217-
218-
* System assigned managed identity created in a workspace named `ws`
219-
```python
220-
# configure cluster with a system-assigned managed identity
221-
compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D2_V2',
222-
max_nodes=5,
223-
identity_type="SystemAssigned",
224-
)
225-
cpu_cluster_name = "cpu-cluster"
226-
cpu_cluster = ComputeTarget.create(ws, cpu_cluster_name, compute_config)
227-
```
228-
229-
* User-assigned managed identity created in a workspace named `ws`
230-
231-
```python
232-
# configure cluster with a user-assigned managed identity
233-
compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D2_V2',
234-
max_nodes=5,
235-
identity_type="UserAssigned",
236-
identity_id=['/subscriptions/<subcription_id>/resourcegroups/<resource_group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<user_assigned_identity>'])
237-
238-
cpu_cluster_name = "cpu-cluster"
239-
cpu_cluster = ComputeTarget.create(ws, cpu_cluster_name, compute_config)
240-
```
241-
242-
* Add managed identity to an existing compute cluster named `cpu_cluster`
243-
244-
* System-assigned managed identity:
245-
246-
```python
247-
# add a system-assigned managed identity
248-
cpu_cluster.add_identity(identity_type="SystemAssigned")
249-
````
250-
251-
* User-assigned managed identity:
252-
253-
```python
254-
# add a user-assigned managed identity
255-
cpu_cluster.add_identity(identity_type="UserAssigned",
256-
identity_id=['/subscriptions/<subcription_id>/resourcegroups/<resource_group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<user_assigned_identity>'])
257-
```
258204

259205
# [Azure CLI](#tab/azure-cli)
260206

@@ -318,5 +264,5 @@ If your Azure Machine Learning compute cluster appears stuck at resizing (0 -> 0
318264

319265
Use your compute cluster to:
320266

321-
* [Submit a training run](v1/how-to-set-up-training-targets.md)
267+
* [Submit a training run](./how-to-train-sdk.md)
322268
* [Run batch inference](./tutorial-pipeline-batch-scoring-classification.md).

articles/machine-learning/v1/how-to-create-attach-compute-cluster.md

Lines changed: 91 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ ms.date: 05/02/2022
1515

1616
# Create an Azure Machine Learning compute cluster with CLI v1
1717

18-
[!INCLUDE [cli v1](../../../includes/machine-learning-cli-v1.md)]
18+
[!INCLUDE [dev v1](../../../includes/machine-learning-dev-v1.md)]
1919

20-
> [!div class="op_single_selector" title1="Select the Azure Machine Learning CLI version you are using:"]
21-
> * [CLI v1](how-to-create-attach-compute-cluster.md)
22-
> * [CLI v2 (current version)](../how-to-create-attach-compute-cluster.md)
20+
> [!div class="op_single_selector" title1="Select the Azure Machine Learning SDK or CLI version you are using:"]
21+
> * [v1](how-to-create-attach-compute-cluster.md)
22+
> * [v2 (current version)](../how-to-create-attach-compute-cluster.md)
2323
2424
Learn how to create and manage a [compute cluster](../concept-compute-target.md#azure-machine-learning-compute-managed) in your Azure Machine Learning workspace.
2525

@@ -31,10 +31,6 @@ In this article, learn how to:
3131
* Lower your compute cluster cost
3232
* Set up a [managed identity](../../active-directory/managed-identities-azure-resources/overview.md) for the cluster
3333

34-
This article covers only the CLI v1 way to accomplish these tasks. To see how to use the SDK, CLI v2, or studio, see [Create an Azure Machine Learning compute cluster (CLI v2)](../how-to-create-attach-compute-cluster.md)
35-
36-
> [!NOTE]
37-
> This article covers only how to do these tasks using CLI v1. For more recent ways to manage a compute instance, see [Create an Azure Machine Learning compute cluster](../how-to-create-attach-compute-cluster.md).
3834

3935
## Prerequisites
4036

@@ -44,6 +40,15 @@ This article covers only the CLI v1 way to accomplish these tasks. To see how t
4440

4541
[!INCLUDE [cli v1 deprecation](../../../includes/machine-learning-cli-v1-deprecation.md)]
4642

43+
* If using the Python SDK, [set up your development environment with a workspace](../how-to-configure-environment.md). Once your environment is set up, attach to the workspace in your Python script:
44+
45+
[!INCLUDE [sdk v1](../../../includes/machine-learning-sdk-v1.md)]
46+
47+
```python
48+
from azureml.core import Workspace
49+
50+
ws = Workspace.from_config()
51+
```
4752

4853
## What is a compute cluster?
4954

@@ -81,6 +86,23 @@ The dedicated cores per region per VM family quota and total regional quota, whi
8186

8287
The compute autoscales down to zero nodes when it isn't used. Dedicated VMs are created to run your jobs as needed.
8388

89+
# [Python SDK](#tab/python)
90+
91+
To create a persistent Azure Machine Learning Compute resource in Python, specify the **vm_size** and **max_nodes** properties. Azure Machine Learning then uses smart defaults for the other properties.
92+
93+
* **vm_size**: The VM family of the nodes created by Azure Machine Learning Compute.
94+
* **max_nodes**: The max number of nodes to autoscale up to when you run a job on Azure Machine Learning Compute.
95+
96+
[!INCLUDE [sdk v1](../../../includes/machine-learning-sdk-v1.md)]
97+
98+
[!code-python[](~/aml-sdk-samples/ignore/doc-qa/how-to-set-up-training-targets/amlcompute2.py?name=cpu_cluster)]
99+
100+
You can also configure several advanced properties when you create Azure Machine Learning Compute. The properties allow you to create a persistent cluster of fixed size, or within an existing Azure Virtual Network in your subscription. See the [AmlCompute class](/python/api/azureml-core/azureml.core.compute.amlcompute.amlcompute) for details.
101+
102+
> [!WARNING]
103+
> When setting the `location` parameter, if it is a different region than your workspace or datastores you may see increased network latency and data transfer costs. The latency and costs can occur when creating the cluster, and when running jobs on it.
104+
105+
# [Azure CLI](#tab/azure-cli)
84106

85107
[!INCLUDE [cli v1](../../../includes/machine-learning-cli-v1.md)]
86108

@@ -93,12 +115,23 @@ az ml computetarget create amlcompute -n cpu --min-nodes 1 --max-nodes 1 -s STAN
93115

94116
For more information, see Az PowerShell module [az ml computetarget create amlcompute](/cli/azure/ml(v1)/computetarget/create#az-ml-computetarget-create-amlcompute).
95117

96-
118+
---
97119

98120
## Lower your compute cluster cost
99121

100122
You may also choose to use [low-priority VMs](../how-to-manage-optimize-cost.md#low-pri-vm) to run some or all of your workloads. These VMs do not have guaranteed availability and may be preempted while in use. You will have to restart a preempted job.
101123

124+
# [Python SDK](#tab/python)
125+
126+
[!INCLUDE [sdk v1](../../../includes/machine-learning-sdk-v1.md)]
127+
128+
```python
129+
compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D2_V2',
130+
vm_priority='lowpriority',
131+
max_nodes=4)
132+
```
133+
134+
# [Azure CLI](#tab/azure-cli)
102135

103136
[!INCLUDE [cli v1](../../../includes/machine-learning-cli-v1.md)]
104137

@@ -107,12 +140,60 @@ Set the `vm-priority`:
107140
```azurecli-interactive
108141
az ml computetarget create amlcompute --name lowpriocluster --vm-size Standard_NC6 --max-nodes 5 --vm-priority lowpriority
109142
```
110-
143+
---
111144

112145
## Set up managed identity
113146

114147
[!INCLUDE [aml-clone-in-azure-notebook](../../../includes/aml-managed-identity-intro.md)]
115148

149+
# [Python SDK](#tab/python)
150+
151+
[!INCLUDE [sdk v1](../../../includes/machine-learning-sdk-v1.md)]
152+
153+
* Configure managed identity in your provisioning configuration:
154+
155+
* System assigned managed identity created in a workspace named `ws`
156+
```python
157+
# configure cluster with a system-assigned managed identity
158+
compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D2_V2',
159+
max_nodes=5,
160+
identity_type="SystemAssigned",
161+
)
162+
cpu_cluster_name = "cpu-cluster"
163+
cpu_cluster = ComputeTarget.create(ws, cpu_cluster_name, compute_config)
164+
```
165+
166+
* User-assigned managed identity created in a workspace named `ws`
167+
168+
```python
169+
# configure cluster with a user-assigned managed identity
170+
compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D2_V2',
171+
max_nodes=5,
172+
identity_type="UserAssigned",
173+
identity_id=['/subscriptions/<subcription_id>/resourcegroups/<resource_group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<user_assigned_identity>'])
174+
175+
cpu_cluster_name = "cpu-cluster"
176+
cpu_cluster = ComputeTarget.create(ws, cpu_cluster_name, compute_config)
177+
```
178+
179+
* Add managed identity to an existing compute cluster named `cpu_cluster`
180+
181+
* System-assigned managed identity:
182+
183+
```python
184+
# add a system-assigned managed identity
185+
cpu_cluster.add_identity(identity_type="SystemAssigned")
186+
````
187+
188+
* User-assigned managed identity:
189+
190+
```python
191+
# add a user-assigned managed identity
192+
cpu_cluster.add_identity(identity_type="UserAssigned",
193+
identity_id=['/subscriptions/<subcription_id>/resourcegroups/<resource_group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<user_assigned_identity>'])
194+
```
195+
196+
# [Azure CLI](#tab/azure-cli)
116197

117198
[!INCLUDE [cli v1](../../../includes/machine-learning-cli-v1.md)]
118199

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
author: sdgilley
3+
ms.service: machine-learning
4+
ms.topic: include
5+
ms.date: 09/20/2022
6+
ms.author: sgilley
7+
---
8+
9+
[!INCLUDE [sdk v2](./machine-learning-sdk-v2.md)]
10+
11+
Run this code to connect to your Azure ML workspace.
12+
13+
Replace your Subscription ID, Resource Group name and Workspace name in the code below. To find these values:
14+
15+
1. Sign in to [Azure Machine Learning studio](https://ml.azure.com).
16+
1. Open the workspace you wish to use.
17+
1. In the upper right Azure Machine Learning studio toolbar, select your workspace name.
18+
1. Copy the value for workspace, resource group and subscription ID into the code.
19+
1. If you're using a notebook inside studio, you'll need to copy one value, close the area and paste, then come back for the next one.
20+
21+
[!notebook-python[](~/azureml-examples-main/sdk/resources/compute/compute.ipynb?name=subscription_id)]
22+
23+
[!notebook-python[](~/azureml-examples-main/sdk/resources/compute/compute.ipynb?name=ml_client)]
24+
25+
`ml_client` is a handler to the workspace that you'll use to manage other resources and jobs.

0 commit comments

Comments
 (0)