Azure Virtual Machine#
Create Virtual Machine#
Create a new Azure Virtual Machine with GPUs, the NVIDIA Driver and the NVIDIA Container Runtime.
NVIDIA maintains a Virtual Machine Image (VMI) that pre-installs NVIDIA drivers and container runtimes, we recommend using this image as the starting point.
Select the latest NVIDIA GPU-Optimized VMI version from the drop down list, then select Get It Now.
If already logged in on Azure, select continue clicking Create.
In Create a virtual machine interface, fill in required information for the vm. Select a GPU enabled VM size.
Note that not all regions support availability zones with GPU VMs.
When the GPU VM size is not selectable with notice: The size is not available in zone x. No zones are supported. It means the GPU VM does not support availability zone. Try other availability options.
Click Review+Create to start the virtual machine.
Prepare the following environment variables.
Name |
Description |
Example |
---|---|---|
|
Name for VM |
|
|
Resource group of VM |
|
|
Region of VM |
|
|
URN of image |
|
|
VM Size |
|
|
User name of VM |
|
|
public ssh key |
|
az vm create \
--name ${AZ_VMNAME} \
--resource-group ${AZ_RESOURCEGROUP} \
--image ${AZ_IMAGE} \
--location ${AZ_LOCATION} \
--size ${AZ_SIZE} \
--admin-username ${AZ_USERNAME} \
--ssh-key-value ${AZ_SSH_KEY}
Note
Use az vm image list --publisher Nvidia --all --output table
to inspect URNs of official
NVIDIA images on Azure.
Note
See this link for supported ssh keys on Azure.
Create Network Security Group#
Next we need to allow network traffic to the VM so we can access Jupyter and Dask.
After creating VM, select Go to resource to access VM.
Select Networking -> Networking Settings in the left panel.
Select +Create port rule -> Add inbound port rule.
Set Destination port ranges to
8888,8787
. Keep rest unchanged. Select Add.
Name |
Description |
Example |
---|---|---|
|
NSG name for the VM |
|
|
Name for NSG rule |
|
az network nsg rule create \
-g ${AZ_RESOURCEGROUP} \
--nsg-name ${AZ_NSGNAME} \
-n ${AZ_NSGRULENAME} \
--priority 1050 \
--destination-port-ranges 8888 8787
Install RAPIDS#
Next, we can SSH into our VM to install RAPIDS. SSH instructions can be found by selecting Connect in the left panel.
There are a selection of methods you can use to install RAPIDS which you can see via the RAPIDS release selector.
For this example we are going to run the RAPIDS Docker container so we need to know the name of the most recent container. On the release selector choose Docker in the Method column.
Then copy the commands shown:
docker pull nvcr.io/nvidia/rapidsai/notebooks:24.10-cuda12.5-py3.12 docker run --gpus all --rm -it \ --shm-size=1g --ulimit memlock=-1 \ -p 8888:8888 -p 8787:8787 -p 8786:8786 \ nvcr.io/nvidia/rapidsai/notebooks:24.10-cuda12.5-py3.12
Note
If you see a “docker socket permission denied” error while running these commands try closing and reconnecting your
SSH window. This happens because your user was added to the docker
group only after you signed in.
Test RAPIDS#
To access Jupyter, navigate to <VM ip>:8888
in the browser.
In a Python notebook, check that you can import and use RAPIDS libraries like cudf
.
In [1]: import cudf
In [2]: df = cudf.datasets.timeseries()
In [3]: df.head()
Out[3]:
id name x y
timestamp
2000-01-01 00:00:00 1020 Kevin 0.091536 0.664482
2000-01-01 00:00:01 974 Frank 0.683788 -0.467281
2000-01-01 00:00:02 1000 Charlie 0.419740 -0.796866
2000-01-01 00:00:03 1019 Edith 0.488411 0.731661
2000-01-01 00:00:04 998 Quinn 0.651381 -0.525398
Open cudf/10min.ipynb
and execute the cells to explore more of how cudf
works.
When running a Dask cluster you can also visit <VM ip>:8787
to monitor the Dask cluster status.