This section describes how to provision and connect to NVIDIA LLM, AI and ML optimized VM on Azure.
It will take you to the Product details page. Click on Create
Select a Resource group for your virtual machine
Select a Region where you want to launch the VM(such as East US)
Optionally change the number of cores and amount of memory.
Note: Make sure to select NVIDIA based GPU instance for the deployment.
GPU availability is limited to certain region and zones
NOTE: While deploying the instance on GPU, if you encounter the quota exhaust error or you are unable to deploy the instance on GPU VM then please refer to our Request Quota on Azure Cloud Platform
Select the Authentication type as Password and enter Username as ubuntu and Password of your choice. Click on Next.
Optionally change the OS disk type. Click on Next.
Optionally change the network and subnetwork names. Be sure that whichever network you specify has ports 22 (for ssh), 3389 (for RDP) and 80 (for HTTP) exposed.
The VM comes with the preconfigured NSG rules. You can check them by clicking on Create New option available under the security group option.
Optionally go to the Management, Advanced and Tags tabs for any advance settings you want for the VM.
Click on Review + create and then click on Create when you are done.
Virtual Machine will begin deploying.
sudo echo ubuntu:yourpassword | chpasswd
Now the password for ubuntu user is set, you can SSH to the VM. To do so, first note the public IP address of the VM from VM details page as highlighted below
Open putty, paste the IP address and click on Open.
login as ubuntu and provide the password for ‘ubuntu’ user.
You can also connect to the VM’s desktop environment from any local windows machine using RDP protocol or local linux machine using Remmina.
To connect using RDP via Windows Machine, note the public IP of the VM.
Then From you local windows machine, goto “start” menu, in the search box type and select “Remote desktop connection”.
In the “Remote Desktop connection” wizard, copy the public IP address and click connect
Note: If you don’t have Remmina installed on your Linux machine, firstInstall Remmina as per your linux distribution.
The Notebook is available on the same public IP you used for remote desktop and accessible via any browser. Just open the browser and type the public IP address and you will get below screen for login.
The Jupyter Notebook is configured with the ubuntu as an admin user. Login with ubuntu as username and ubuntu user password.
Note: Make sure you use “http” and not “https” in the url
Select the Input Type.
For more details on how to use Chat UI , please refer The chat interface Documentations.
%load_ext jupyter_ai_magics
To use these magic commands, open Jupyter Notebook. Run %ai help for help with syntax.
%ai help
%env OPENAI_API_KEY=Your API Key
%%ai <provider-id>:<local-model-id>
%reload_ext jupyter_ai_magics
%%ai model
Your prompt here
%ai list
Please refer The %ai and %%ai magic commands Documentations for more details.
e.g
First Install the required packages to execute the below code in jupyter notebook using.
!sudo pip3 install torch torchvision matplotlib
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
# Check if CUDA is available
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Define a simple neural network
class SimpleNN(nn.Module):
def __init__(self):
super(SimpleNN, self).__init__()
self.fc1 = nn.Linear(784, 128)
self.relu = nn.ReLU()
self.fc2 = nn.Linear(128, 10)
def forward(self, x):
x = torch.flatten(x, 1)
x = self.fc1(x)
x = self.relu(x)
x = self.fc2(x)
return x
# Load MNIST dataset
transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5,), (0.5,))])
trainset = torchvision.datasets.MNIST(root='./data', train=True, download=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=64, shuffle=True)
# Initialize the network
net = SimpleNN().to(device)
# Define loss function and optimizer
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(net.parameters(), lr=0.001)
# Training loop
for epoch in range(5): # loop over the dataset multiple times
running_loss = 0.0
for i, data in enumerate(trainloader, 0):
inputs, labels = data[0].to(device), data[1].to(device)
# zero the parameter gradients
optimizer.zero_grad()
# forward + backward + optimize
outputs = net(inputs)
loss = criterion(outputs, labels)
loss.backward()
optimizer.step()
# print statistics
running_loss += loss.item()
if i % 100 == 99: # print every 100 mini-batches
print('[%d, %5d] loss: %.3f' % (epoch + 1, i + 1, running_loss / 100))
running_loss = 0.0
print('Finished Training')
Additional resources: