Getting Started with Compute: Create Your First Nebius AI Cloud VM 🚀
This guide provides a comprehensive walkthrough for creating virtual machines (VMs) in Nebius AI Cloud using the Command Line Interface (CLI). We’ll cover creating single-node VMs for common use cases and then an optional, advanced section on setting up a multi-node cluster for large-scale distributed workloads.
Before You Begin
Prepare your environment by installing the necessary tools and an SSH key.
-
Install the Nebius AI Cloud CLI:
Bash
curl -sSL https://storage.eu-north1.nebius.cloud/cli/install.sh | bash nebius profile createThe
nebius profile createcommand will prompt you to log in via your browser. -
Configure Your Project ID:
Get your project ID from the Nebius web console’s Project settings and configure the CLI.
Bash
nebius config set parent-id <project_ID> -
Install jq:
This tool is used to parse JSON output from the CLI.
Bash
# For macOS brew install jq # For Ubuntu/Debian sudo apt-get install jq -
Generate SSH Keys:
Create an SSH key pair to securely connect to your VM. Using a specific name for your key helps avoid overwriting existing keys.
Bash
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_nebius
Part 1: Single-Node VM Demos
These scripts create a single VM for various common use cases. You do not need a GPU cluster for any of these. The VMs will have a dynamic public IP address.
First, set your desired username and retrieve the subnet ID for your VM’s network interface. This will be used in all the scripts in this section.
Bash
# Set your preferred username (e.g., 'zhuoran-1')
export MY_USERNAME="zhuoran-1"
# Prepare user data with your custom username
export USER_DATA=$(jq -Rs '.' <<EOF
users:
- name: $MY_USERNAME
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
ssh_authorized_keys:
- $(cat ~/.ssh/id_ed25519_nebius.pub)
EOF
)
# Get the subnet ID
export SUBNET_ID=$(nebius vpc subnet list --format json | jq -r ".items[0].metadata.id")
Create a Pure CPU VM
This is a basic VM with no GPU, suitable for general computing tasks or CPU-based data processing.
Bash
# Create a boot disk (50 GiB is sufficient)
export BOOT_DISK_ID=$(nebius compute disk create \
--name cpu-vm-boot-disk \
--size-gibibytes 50 \
--type network_ssd \
--source-image-family-image-family ubuntu22.04 \
--format json | jq -r ".metadata.id")
# Create the VM instance
nebius compute instance create \
--name "my-cpu-vm" \
--resources-platform "intel-ice-lake" \
--resources-preset "4vcpu-16gb" \
--boot-disk-existing-disk-id "$BOOT_DISK_ID" \
--network-interfaces '[{"name": "eth0", "subnet_id": "$SUBNET_ID", "public_ip_address": {}}]' \
--cloud-init-user-data "$USER_DATA"
Create a 1-GPU VM
This VM is ideal for model inference or smaller-scale training jobs.
Bash
# Create a boot disk (200 GiB is suitable)
export BOOT_DISK_ID=$(nebius compute disk create \
--name 1gpu-vm-boot-disk \
--size-gibibytes 200 \
--type network_ssd \
--source-image-family-image-family ubuntu22.04-cuda12 \
--format json | jq -r ".metadata.id")
# Create the VM instance
nebius compute instance create \
--name "my-1gpu-vm" \
--resources-platform "gpu-h100-sxm" \
--resources-preset "1gpu-16vcpu-200gb" \
--boot-disk-existing-disk-id "$BOOT_DISK_ID" \
--network-interfaces '[{"name": "eth0", "subnet_id": "$SUBNET_ID", "public_ip_address": {}}]' \
--cloud-init-user-data "$USER_DATA"
Create a Single 8-GPU VM
This powerful VM is a single machine with 8 GPUs, suitable for large training workloads that can run on one host. It uses a single large boot disk for both the OS and data, making a separate shared filesystem optional.
Bash
# Create a large boot disk (2 TiB)
export BOOT_DISK_ID=$(nebius compute disk create \
--name 8gpu-vm-boot-disk \
--size-gibibytes 2048 \
--type network_ssd \
--source-image-family-image-family ubuntu22.04-cuda12 \
--block-size-bytes 4096 \
--format json | jq -r ".metadata.id")
# Create the VM instance
nebius compute instance create \
--name "my-8gpu-vm" \
--resources-platform "gpu-h100-sxm" \
--resources-preset "8gpu-128vcpu-1600gb" \
--boot-disk-existing-disk-id "$BOOT_DISK_ID" \
--network-interfaces '[{"name": "eth0", "subnet_id": "$SUBNET_ID", "public_ip_address": {}}]' \
--cloud-init-user-data "$USER_DATA"
Part 2: Connect to Your VM
Once your VM is created, you can get its public IP and connect using SSH. The default username is not used; instead, you’ll use the custom username you defined.
Bash
# To get the public IP for the 8-GPU VM:
export PUBLIC_IP=$(nebius compute instance get-by-name \
--name "my-8gpu-vm" \
--format json \
| jq -r '.status.network_interfaces[0].public_ip_address.address')
# Connect to the VM
ssh $MY_USERNAME@$PUBLIC_IP
Part 3: Optional or Advanced: Multi-Node Setup with a GPU Cluster
This section explains how to set up a multi-node training environment. A GPU cluster with InfiniBand fabric is necessary for high-speed, low-latency communication between multiple VMs. Each VM in the cluster must also be configured with 8 GPUs. This is the setup for massive distributed training workloads.
Step 1: Create a GPU Cluster
This cluster acts as a high-speed network for your VMs.
Bash
export GPU_CLUSTER_ID=$(nebius compute gpu-cluster create \
--name my-gpu-cluster \
--infiniband-fabric fabric-3 \
--format json | jq -r ".metadata.id")
Step 2: Create Multiple 8-GPU VMs and Add them to the Cluster
You’ll need to run this command for each VM you want to add to the cluster.
Bash
# Assuming BOOT_DISK_ID, FILESYSTEM_ID, SUBNET_ID, and USER_DATA are already set.
nebius compute instance create \
--name "training-instance-node-1" \
--resources-platform "gpu-h100-sxm" \
--resources-preset "8gpu-128vcpu-1600gb" \
--boot-disk-existing-disk-id "$BOOT_DISK_ID" \
--filesystems '[{"attach_mode": "READ_WRITE", "mount_tag": "my-data-fs", "existing_filesystem": {"id": "$FILESYSTEM_ID"}}]' \
--network-interfaces '[{"name": "eth0", "subnet_id": "$SUBNET_ID", "public_ip_address": {}}]' \
--gpu-cluster-id "$GPU_CLUSTER_ID" \
--cloud-init-user-data "$USER_DATA"
To add more nodes, simply run this command again with a new --name (e.g., "training-instance-node-2"). Each new VM will be added to the same GPU cluster, enabling high-speed distributed communication.