# Lab 1 - Environment Setup

## Create a Azure Machine Learning Workspace

To get started we need to setup a few resources in Azure. For this we are going to use the Azure CLI. If you don’t have the [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/?WT.mc_id=aiapril-blog-heboelma\&view=gaic-github-latest) installed on your machine you can follow the [tutorial on MS Docs](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?WT.mc_id=gaic-github-heboelma\&view=azure-cli-latest) here.

### Install the Azure Machine Learning CLI extension

To install the machine learning extension, use the following command:

```
az extension add -n azure-cli-ml
```

### Create a resource group

The Azure Machine Learning workspace must be created inside a resource group. You can use an existing resource group or create a new one. To create a new resource group, use the following command. Replace  with the name to use for this resource group. Replace  with the Azure region to use for this resource group:

**Example name and location:**&#x20;

* resource group name: pytorchworkshop
* location: WestEurope

```
az group create --name <resource-group-name> --location <location>
```

### Create the workspace

To create a new workspace where the services are automatically created, use the following command:

```
az ml workspace create -w <workspace-name> -g <resource-group-name>
```

> You can now view your workspace by visiting <https://ml.azure.com>

![Azure Machine Learning studio](https://475228360-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MF0ro-V-CjhNEKidSUU%2Fsync%2F73f6fb6e259d619e7f5abcb858215210f4a96fdf.png?generation=1597759372555732\&alt=media)

### Create a Compute Cluster

To train our model we need an Azure Machine Learning Compute cluster. To create a new compute cluster, use the following command.

This command will create an Azure Machine Learning Compute cluster with 1 node that is always on and is using STANDARD\_NC6 virtual Machines.

*To speed up the training process you can use a GPU enabled NC6 machine*

```
az ml computetarget create amlcompute -n gpu-cluster --min-nodes 1 --max-nodes 1 --vm-size STANDARD_NC6 -w <workspace-name> -g <resource-group-name>
```

> View your created Azure Machine Learning Compute cluster on <https://ml.azure.com>
>
> *Creating compute can take a few minutes to complete*

![Create Azure Machine Learning Compute](https://475228360-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MF0ro-V-CjhNEKidSUU%2Fsync%2F4f026a8a3d50afbd06e215add1bf68830b0daa2b.png?generation=1597759372809521\&alt=media)

### Create a Compute instance

To train our model we are going to use a notebook. To run a notebook in Azure Machine Learning studio we need to create a Compute Instance.

*Choose a unique name*

```
az ml computetarget create computeinstance -n <name> --vm-size Standard_D2_V2 -w <workspace-name> -g <resource-group-name>
```

> View your created Azure Machine Learning Compute cluster on <https://ml.azure.com>
>
> *Creating compute can take a few minutes to complete*

![Create Azure Machine Learning Compute Instance](https://475228360-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MF0ro-V-CjhNEKidSUU%2Fsync%2F01797e1d3b38c4f97754f8ed5e77058da7d47a6d.png?generation=1597759373131966\&alt=media)

### Create a Notebook

* Navigate to the Notebook section in Azure Machine Learning Workspace.&#x20;
* Create a new file with name 'simpsons' and File type 'notebook'

![Create new folder](https://475228360-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MF0ro-V-CjhNEKidSUU%2Fsync%2F90321df9948ad93cc2b341dd5e906ec0b969dec8.png?generation=1597759372658288\&alt=media)

### Setup completed

If everything went correctly you should be looking at a screen that looks like the one below and see that your notebook is running on your created Compute Instance.

![Create new folder](https://475228360-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MF0ro-V-CjhNEKidSUU%2Fsync%2Fd2b7a02ddbfae2aea040ed4819300aed226aef70.png?generation=1597759372720246\&alt=media)

[**Continue with lab 2 >**](https://workshops.henkboelman.com/developers-guide-to-azure-ai/azure-machine-learning/lab-2)
