[ Web Proxy ]
URL:
Viewing: https://cloud.google.com/compute/docs/gpus/gpudirect [Back]  [Original]

Create an A3 Mega, A3 High, or A3 Edge instance with GPUDirect enabled  |  Compute Engine  |  Google Cloud Documentation Skip to main content
Google Cloud Documentation [Google Cloud Documentation]
Send feedback

Create an A3 Mega, A3 High, or A3 Edge instance with GPUDirect enabled Stay organized with collections Save and categorize content based on your preferences.

This document describes the setup for A3 Mega, A3 High, or A3 Edge virtual machine (VM) instances that have eight NVIDIA H100 GPUs attached and use either of the following GPUDirect technologies: GPUDirect-TCPX or GPUDirect-TCPXO. To create an A3 High instance with less than 8 GPUs, see Create an A3 High or A2 instance.

The GPUDirect technology that you use depends on the A3 machine type that you select.

The A3 accelerator-optimized machine series has 208 vCPUs, and up to 1872GB of memory. The a3-megagpu-8g, a3-highgpu-8g, and a3-edgegpu-8g machine types offer 80 GB GPU memory per GPU. These machine types can get up to 1,800 Gbps of network bandwidth, which makes them ideal for large transformer-based language models, databases, and high performance computing (HPC).

Both GPUDirect-TCPX and GPUDirect-TCPXO use NVIDIA GPUDirect technology to increase performance and reduce latency for your A3 VMs. They achieve this by allowing data packet payloads to transfer directly from GPU memory to the network interface, bypassing the CPU and system memory. This is a form of remote direct memory access (RDMA). When combined with Google Virtual NIC (gVNIC), A3 VMs can deliver the highest throughput between VMs in a cluster when compared to the previous generation A2 or G2 accelerator-optimized machine types.

This document describes how to create an A3 Mega, A3 High, or A3 Edge VM and enable either GPUDirect-TCPX or GPUDirect-TCPXO to test the improved GPU network performance.

Before you begin

Required roles

To get the permissions that you need to create VMs, ask your administrator to grant you the Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on the project. For more information about granting roles, see Manage access to projects, folders, and organizations.

This predefined role contains the permissions required to create VMs. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

The following permissions are required to create VMs:

You might also be able to get these permissions with custom roles or other predefined roles.

Overview

To test network performance with GPUDirect, complete the following steps:

  1. Set up one or more Virtual Private Cloud (VPC) networks that have a large MTU configured.
  2. Create your GPU instance.

Set up VPC networks

To enable efficient communication for your GPU VMs, you need to create a management network and one or more data networks. The management network is used for external access, for example SSH, and for most general network communication. The data networks are used for high-performance communication between the GPUs on different VMs, for example, for Remote Direct Memory Access (RDMA) traffic.

For these VPC networks, we recommend setting the maximum transmission unit (MTU) to a larger value. Higher MTU values increase the packet size and reduce the packet-header overhead, which increases payload data throughput. For more information about how to create VPC networks, see Create and verify a jumbo frame MTU network.

Create management network, subnet, and firewall rule

Complete the following steps to set up the management network:

  1. Create the management network by using the networks create command:

    gcloud compute networks create NETWORK_NAME_PREFIX-mgmt-net \
        --project=PROJECT_ID \
        --subnet-mode=custom \
        --mtu=8244
    
  2. Create the management subnet by using the networks subnets create command:

    gcloud compute networks subnets create NETWORK_NAME_PREFIX-mgmt-sub \
        --project=PROJECT_ID \
        --network=NETWORK_NAME_PREFIX-mgmt-net \
        --region=REGION \
        --range=192.168.0.0/24
    
  3. Create firewall rules by using the firewall-rules create command.

    1. Create a firewall rule for the management network.

      gcloud compute firewall-rules create NETWORK_NAME_PREFIX-mgmt-internal \
          --project=PROJECT_ID \
          --network=NETWORK_NAME_PREFIX-mgmt-net \
          --action=ALLOW \
          --rules=tcp:0-65535,udp:0-65535,icmp \
          --source-ranges=192.168.0.0/16
      
    2. Create the tcp:22 firewall rule to limit which source IP addresses can connect to your VM by using SSH.

      gcloud compute firewall-rules create NETWORK_NAME_PREFIX-mgmt-external-ssh \
          --project=PROJECT_ID \
          --network=NETWORK_NAME_PREFIX-mgmt-net \
          --action=ALLOW \
          --rules=tcp:22 \
          --source-ranges=SSH_SOURCE_IP_RANGE
      
    3. Create the icmp firewall rule that can be used to check for data transmission issues in the network.

      gcloud compute firewall-rules create NETWORK_NAME_PREFIX-mgmt-external-ping \
          --project=PROJECT_ID \
          --network=NETWORK_NAME_PREFIX-mgmt-net \
          --action=ALLOW \
          --rules=icmp \
          --source-ranges=0.0.0.0/0
      

Replace the following:

Create data networks, subnets, and firewall rule

The number of data networks varies depending on the type of GPU machine you are creating.

A3 Mega

A3 Mega requires eight data networks. To create eight data networks, each with subnets and firewall rules, use the following command.

for N in $(seq 1 8); do
gcloud compute networks create NETWORK_NAME_PREFIX-data-net-$N \
    --project=PROJECT_ID \
    --subnet-mode=custom \
    --mtu=8244

gcloud compute networks subnets create NETWORK_NAME_PREFIX-data-sub-$N \
    --project=PROJECT_ID \
    --network=NETWORK_NAME_PREFIX-data-net-$N \
    --region=REGION \
    --range=192.168.$N.0/24

gcloud compute firewall-rules create NETWORK_NAME_PREFIX-data-internal-$N \
    --project=PROJECT_ID \
    --network=NETWORK_NAME_PREFIX-data-net-$N \
    --action=ALLOW \
    --rules=tcp:0-65535,udp:0-65535,icmp \
    --source-ranges=192.168.0.0/16
done

A3 High and A3 Edge

A3 High and A3 Edge require four data networks. Use the following command to create four data networks, each with subnets and firewall rules.

for N in $(seq 1 4); do
gcloud compute networks create NETWORK_NAME_PREFIX-data-net-$N \
    --project=PROJECT_ID \
    --subnet-mode=custom \
    --mtu=8244

gcloud compute networks subnets create NETWORK_NAME_PREFIX-data-sub-$N \
    --project=PROJECT_ID \
    --network=NETWORK_NAME_PREFIX-data-net-$N \
    --region=REGION \
    --range=192.168.$N.0/24

gcloud compute firewall-rules create NETWORK_NAME_PREFIX-data-internal-$N \
    --project=PROJECT_ID \
    --network=NETWORK_NAME_PREFIX-data-net-$N \
    --action=ALLOW \
    --rules=tcp:0-65535,udp:0-65535,icmp \
    --source-ranges=192.168.0.0/16
done

Create A3 Mega instances (GPUDirect-TCPXO)

Create your A3 Mega instances by using the cos-121-lts or later Container-Optimized OS image or the rocky-linux-8-optimized-gcp-nvidia-580 Rocky Linux image.

COS

To test network performance with GPUDirect-TCPXO, create at least two A3 Mega VM instances. Create each VM by using the cos-121-lts or later Container-Optimized OS image and specifying the VPC networks that you created in the previous step.

A3 Mega VMs require nine Google Virtual NIC (gVNIC) network interfaces, one for the management network and eight for the data networks.

Based on the provisioning model that you want to use to create your VM, select one of the following options:

Standard

gcloud compute instances create VM_NAME \
    --project=PROJECT_ID \
    --zone=ZONE \
    --machine-type=a3-megagpu-8g \
    --maintenance-policy=TERMINATE \
    --restart-on-failure \
    --image-family=cos-121-lts \
    --image-project=cos-cloud \
    --boot-disk-size=BOOT_DISK_SIZE \
    --metadata=cos-update-strategy=update_disabled \
    --scopes=https://www.googleapis.com/auth/cloud-platform \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-mgmt-net,subnet=NETWORK_NAME_PREFIX-mgmt-sub \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-1,subnet=NETWORK_NAME_PREFIX-data-sub-1,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-2,subnet=NETWORK_NAME_PREFIX-data-sub-2,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-3,subnet=NETWORK_NAME_PREFIX-data-sub-3,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-4,subnet=NETWORK_NAME_PREFIX-data-sub-4,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-5,subnet=NETWORK_NAME_PREFIX-data-sub-5,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-6,subnet=NETWORK_NAME_PREFIX-data-sub-6,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-7,subnet=NETWORK_NAME_PREFIX-data-sub-7,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-8,subnet=NETWORK_NAME_PREFIX-data-sub-8,no-address

Replace the following:

If you want to apply a placement policy to your VM, then use the same command with the --resource-policies flag. You can only create your VM wihthin the same region as the placement policy.

Spot

gcloud compute instances create VM_NAME \
    --project=PROJECT_ID \
    --zone=ZONE \
    --machine-type=a3-megagpu-8g \
    --maintenance-policy=TERMINATE \
    --restart-on-failure \
    --image-family=cos-121-lts \
    --image-project=cos-cloud \
    --boot-disk-size=BOOT_DISK_SIZE \
    --metadata=cos-update-strategy=update_disabled \
    --scopes=https://www.googleapis.com/auth/cloud-platform \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-mgmt-net,subnet=NETWORK_NAME_PREFIX-mgmt-sub \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-1,subnet=NETWORK_NAME_PREFIX-data-sub-1,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-2,subnet=NETWORK_NAME_PREFIX-data-sub-2,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-3,subnet=NETWORK_NAME_PREFIX-data-sub-3,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-4,subnet=NETWORK_NAME_PREFIX-data-sub-4,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-5,subnet=NETWORK_NAME_PREFIX-data-sub-5,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-6,subnet=NETWORK_NAME_PREFIX-data-sub-6,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-7,subnet=NETWORK_NAME_PREFIX-data-sub-7,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-8,subnet=NETWORK_NAME_PREFIX-data-sub-8,no-address \
    --provisioning-model=SPOT \
    --instance-termination-action=TERMINATION_ACTION

Replace the following:

Flex-start

gcloud compute instances create VM_NAME \
    --project=PROJECT_ID \
    --zone=ZONE \
    --machine-type=a3-megagpu-8g \
    --maintenance-policy=TERMINATE \
    --restart-on-failure \
    --image-family=cos-121-lts \
    --image-project=cos-cloud \
    --boot-disk-size=BOOT_DISK_SIZE \
    --metadata=cos-update-strategy=update_disabled \
    --scopes=https://www.googleapis.com/auth/cloud-platform \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-mgmt-net,subnet=NETWORK_NAME_PREFIX-mgmt-sub \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-1,subnet=NETWORK_NAME_PREFIX-data-sub-1,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-2,subnet=NETWORK_NAME_PREFIX-data-sub-2,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-3,subnet=NETWORK_NAME_PREFIX-data-sub-3,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-4,subnet=NETWORK_NAME_PREFIX-data-sub-4,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-5,subnet=NETWORK_NAME_PREFIX-data-sub-5,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-6,subnet=NETWORK_NAME_PREFIX-data-sub-6,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-7,subnet=NETWORK_NAME_PREFIX-data-sub-7,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-8,subnet=NETWORK_NAME_PREFIX-data-sub-8,no-address \
    --provisioning-model=FLEX_START \
    --instance-termination-action=TERMINATION_ACTION \
    --max-run-duration=RUN_DURATION \
    --request-valid-for-duration=VALID_FOR_DURATION \
    --reservation-affinity=none

Replace the following:

If you want to apply a compact placement policy to your VM to reduce network latency across VMs, use the same command with the --resource-policies=RESOURCE_POLICY_NAME flag.

Reservation-bound

gcloud compute instances create VM_NAME \
    --project=PROJECT_ID \
    --zone=ZONE \
    --machine-type=a3-megagpu-8g \
    --maintenance-policy=TERMINATE \
    --restart-on-failure \
    --image-family=cos-121-lts \
    --image-project=cos-cloud \
    --boot-disk-size=BOOT_DISK_SIZE \
    --metadata=cos-update-strategy=update_disabled \
    --scopes=https://www.googleapis.com/auth/cloud-platform \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-mgmt-net,subnet=NETWORK_NAME_PREFIX-mgmt-sub \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-1,subnet=NETWORK_NAME_PREFIX-data-sub-1,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-2,subnet=NETWORK_NAME_PREFIX-data-sub-2,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-3,subnet=NETWORK_NAME_PREFIX-data-sub-3,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-4,subnet=NETWORK_NAME_PREFIX-data-sub-4,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-5,subnet=NETWORK_NAME_PREFIX-data-sub-5,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-6,subnet=NETWORK_NAME_PREFIX-data-sub-6,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-7,subnet=NETWORK_NAME_PREFIX-data-sub-7,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-8,subnet=NETWORK_NAME_PREFIX-data-sub-8,no-address \
    --provisioning-model=RESERVATION_BOUND \
    --instance-termination-action=TERMINATION_ACTION \
    --reservation-affinity=specific \
    --reservation=RESERVATION_URL

Replace the following:

Install GPU drivers

On each A3 Mega VM, install the GPU drivers.

  1. Install the NVIDIA GPU drivers.

    sudo cos-extensions install gpu -- --version=latest
    
  2. Remount the path.

    sudo mount --bind /var/lib/nvidia /var/lib/nvidia
    sudo mount -o remount,exec /var/lib/nvidia
    

Give the NICs access to the GPUs

On each A3 Mega VM, give the NICs access to the GPUs.

  1. Adjust the firewall settings to accept all incoming TCP connections and enable communication between the nodes in your cluster:
    sudo /sbin/iptables -I INPUT -p tcp -m tcp -j ACCEPT
  2. Configure the dmabuf module. Load the import-helper module, which is part of the dmabuf framework. This framework enables high-speed, zero-copy memory sharing between the GPU and the network interface card (NIC), a critical component for GPUDirect technology:
    sudo modprobe import-helper
  3. Configure Docker to authenticate requests to Artifact Registry.
    docker-credential-gcr configure-docker --registries us-docker.pkg.dev
  4. Launch RxDM in the container. RxDM is a management service that runs alongside the GPU application to manage GPU memory. This service pre-allocates and manages GPU memory for incoming network traffic, which is a key element of GPUDirect technology and essential for high-performance networking. Start a Docker container named rxdm:
    docker run --pull=always --rm --detach --name rxdm \
        --network=host  --cap-add=NET_ADMIN  \
        --privileged \
        --volume /var/lib/nvidia:/usr/local/nvidia \
        --device /dev/nvidia0:/dev/nvidia0 \
        --device /dev/nvidia1:/dev/nvidia1 \
        --device /dev/nvidia2:/dev/nvidia2 \
        --device /dev/nvidia3:/dev/nvidia3 \
        --device /dev/nvidia4:/dev/nvidia4 \
        --device /dev/nvidia5:/dev/nvidia5 \
        --device /dev/nvidia6:/dev/nvidia6 \
        --device /dev/nvidia7:/dev/nvidia7 \
        --device /dev/nvidia-uvm:/dev/nvidia-uvm \
        --device /dev/nvidiactl:/dev/nvidiactl \
        --device /dev/dmabuf_import_helper:/dev/dmabuf_import_helper \
        --env LD_LIBRARY_PATH=/usr/local/nvidia/lib64 \
        us-docker.pkg.dev/gce-ai-infra/gpudirect-tcpxo/tcpgpudmarxd-dev:v1.0.21 \
        --num_hops=2 --num_nics=8

    To verify that RxDM has successfully started, run the command. Wait for the message "Buffer manager initialization complete" to confirm successful RxDM initialization.

    docker container logs --follow  rxdm

    Alternatively, check the RxDM initialization completion log.

    docker container logs rxdm 2>&1 | grep "Buffer manager initialization complete"

Set up NCCL environment

On each A3 Mega VM, complete the following steps:

  1. Install the nccl-net library, a plugin for NCCL that enables GPUDirect communication over the network. The following command pulls the installer image and installs the necessary library files into /var/lib/tcpxo/lib64/.
    NCCL_NET_IMAGE="us-docker.pkg.dev/gce-ai-infra/gpudirect-tcpxo/nccl-plugin-gpudirecttcpx-dev:v1.0.15"
    
    docker run --pull=always --rm --privileged \
        --network=host --cap-add=NET_ADMIN \
        --volume /var/lib/nvidia:/usr/local/nvidia  \
        --volume /var/lib:/var/lib \
        --device /dev/nvidia0:/dev/nvidia0   \
        --device /dev/nvidia1:/dev/nvidia1  \
        --device /dev/nvidia2:/dev/nvidia2  \
        --device /dev/nvidia3:/dev/nvidia3  \
        --device /dev/nvidia4:/dev/nvidia4  \
        --device /dev/nvidia5:/dev/nvidia5  \
        --device /dev/nvidia6:/dev/nvidia6  \
        --device /dev/nvidia7:/dev/nvidia7  \
        --device /dev/nvidia-uvm:/dev/nvidia-uvm  \
        --device /dev/nvidiactl:/dev/nvidiactl  \
        --device /dev/dmabuf_import_helper:/dev/dmabuf_import_helper  \
        --env LD_LIBRARY_PATH=/usr/local/nvidia/lib64:/var/lib/tcpxo/lib64 \
        ${NCCL_NET_IMAGE} install  --install-nccl
    
    sudo mount --bind /var/lib/tcpxo /var/lib/tcpxo && sudo mount -o remount,exec /var/lib/tcpxo
    
  2. Launch a dedicated container nccl-tests for NCCL testing. This container comes pre-configured with the necessary tools and utility scripts, ensuring a clean and consistent environment for verifying GPUDirect setup performance.

    This command reuses the NCCL_NET_IMAGE variable that you set in the previous step.

    docker run --pull=always --rm --detach --name nccl \
        --network=host --cap-add=NET_ADMIN \
        --privileged \
        --volume /var/lib/nvidia:/usr/local/nvidia  \
        --volume /var/lib/tcpxo:/var/lib/tcpxo \
        --shm-size=8g \
        --device /dev/nvidia0:/dev/nvidia0 \
        --device /dev/nvidia1:/dev/nvidia1 \
        --device /dev/nvidia2:/dev/nvidia2 \
        --device /dev/nvidia3:/dev/nvidia3 \
        --device /dev/nvidia4:/dev/nvidia4 \
        --device /dev/nvidia5:/dev/nvidia5 \
        --device /dev/nvidia6:/dev/nvidia6 \
        --device /dev/nvidia7:/dev/nvidia7 \
        --device /dev/nvidia-uvm:/dev/nvidia-uvm \
        --device /dev/nvidiactl:/dev/nvidiactl \
        --device /dev/dmabuf_import_helper:/dev/dmabuf_import_helper \
        --env LD_LIBRARY_PATH=/usr/local/nvidia/lib64:/var/lib/tcpxo/lib64 \
        ${NCCL_NET_IMAGE} daemon

Run nccl-tests benchmark

To run the nccl-tests benchmark on a single A3 Mega VM, complete the following steps:

  1. Open an interactive bash shell inside the nccl-tests container.
    docker exec -it nccl bash

    From inside the nccl-tests container's bash shell, complete the following steps.

    1. Configure the environment for a multi-node run by setting up SSH and generating host files. Replace VM_NAME_1 and VM_NAME_2 with the names of each VM.
      /scripts/init_ssh.sh VM_NAME_1 VM_NAME_2
      /scripts/gen_hostfiles.sh VM_NAME_1 VM_NAME_2
        

      This creates a directory named /scripts/hostfiles2.

    2. Run the all_gather_perf benchmark to measure collective communication performance:
      /scripts/run-nccl-tcpxo.sh all_gather_perf "${LD_LIBRARY_PATH}" 8 eth1,eth2,eth3,eth4,eth5,eth6,eth7,eth8 1M 512M 3 2 10 8 2 10

Rocky

To test network performance with GPUDirect-TCPXO, create at least two A3 Mega VM instances. Create each VM by using the rocky-linux-8-optimized-gcp-nvidia-580 or later Rocky Linux image and specifying the VPC networks that you created in the previous step.

A3 Mega VMs require nine Google Virtual NIC (gVNIC) network interfaces, one for the management network and eight for the data networks.

Based on the provisioning model that you want to use to create your VM, select one of the following options:

Standard

gcloud compute instances create VM_NAME \
    --project=PROJECT_ID \
    --zone=ZONE \
    --machine-type=a3-megagpu-8g \
    --maintenance-policy=TERMINATE \
    --restart-on-failure \
    --image-family=rocky-linux-8-optimized-gcp-nvidia-580 \
    --image-project=rocky-linux-accelerator-cloud \
    --boot-disk-size=BOOT_DISK_SIZE \
    --metadata=cos-update-strategy=update_disabled \
    --scopes=https://www.googleapis.com/auth/cloud-platform \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-mgmt-net,subnet=NETWORK_NAME_PREFIX-mgmt-sub \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-1,subnet=NETWORK_NAME_PREFIX-data-sub-1,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-2,subnet=NETWORK_NAME_PREFIX-data-sub-2,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-3,subnet=NETWORK_NAME_PREFIX-data-sub-3,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-4,subnet=NETWORK_NAME_PREFIX-data-sub-4,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-5,subnet=NETWORK_NAME_PREFIX-data-sub-5,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-6,subnet=NETWORK_NAME_PREFIX-data-sub-6,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-7,subnet=NETWORK_NAME_PREFIX-data-sub-7,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-8,subnet=NETWORK_NAME_PREFIX-data-sub-8,no-address

Replace the following:

If you want to apply a placement policy to your VM, then use the same command with the --resource-policies flag. You can only create your VM wihthin the same region as the placement policy.

Spot

gcloud compute instances create VM_NAME \
    --project=PROJECT_ID \
    --zone=ZONE \
    --machine-type=a3-megagpu-8g \
    --maintenance-policy=TERMINATE \
    --restart-on-failure \
    --image-family=rocky-linux-8-optimized-gcp-nvidia-580 \
    --image-project=rocky-linux-accelerator-cloud \
    --boot-disk-size=BOOT_DISK_SIZE \
    --metadata=cos-update-strategy=update_disabled \
    --scopes=https://www.googleapis.com/auth/cloud-platform \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-mgmt-net,subnet=NETWORK_NAME_PREFIX-mgmt-sub \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-1,subnet=NETWORK_NAME_PREFIX-data-sub-1,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-2,subnet=NETWORK_NAME_PREFIX-data-sub-2,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-3,subnet=NETWORK_NAME_PREFIX-data-sub-3,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-4,subnet=NETWORK_NAME_PREFIX-data-sub-4,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-5,subnet=NETWORK_NAME_PREFIX-data-sub-5,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-6,subnet=NETWORK_NAME_PREFIX-data-sub-6,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-7,subnet=NETWORK_NAME_PREFIX-data-sub-7,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-8,subnet=NETWORK_NAME_PREFIX-data-sub-8,no-address \
    --provisioning-model=SPOT \
    --instance-termination-action=TERMINATION_ACTION

Replace the following:

Flex-start

gcloud compute instances create VM_NAME \
    --project=PROJECT_ID \
    --zone=ZONE \
    --machine-type=a3-megagpu-8g \
    --maintenance-policy=TERMINATE \
    --restart-on-failure \
    --image-family=rocky-linux-8-optimized-gcp-nvidia-580 \
    --image-project=rocky-linux-accelerator-cloud \
    --boot-disk-size=BOOT_DISK_SIZE \
    --metadata=cos-update-strategy=update_disabled \
    --scopes=https://www.googleapis.com/auth/cloud-platform \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-mgmt-net,subnet=NETWORK_NAME_PREFIX-mgmt-sub \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-1,subnet=NETWORK_NAME_PREFIX-data-sub-1,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-2,subnet=NETWORK_NAME_PREFIX-data-sub-2,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-3,subnet=NETWORK_NAME_PREFIX-data-sub-3,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-4,subnet=NETWORK_NAME_PREFIX-data-sub-4,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-5,subnet=NETWORK_NAME_PREFIX-data-sub-5,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-6,subnet=NETWORK_NAME_PREFIX-data-sub-6,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-7,subnet=NETWORK_NAME_PREFIX-data-sub-7,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-8,subnet=NETWORK_NAME_PREFIX-data-sub-8,no-address \
    --provisioning-model=FLEX_START \
    --instance-termination-action=TERMINATION_ACTION \
    --max-run-duration=RUN_DURATION \
    --request-valid-for-duration=VALID_FOR_DURATION \
    --reservation-affinity=none

Replace the following:

If you want to apply a compact placement policy to your VM to reduce network latency across VMs, use the same command with the --resource-policies=RESOURCE_POLICY_NAME flag.

Reservation-bound

gcloud compute instances create VM_NAME \
    --project=PROJECT_ID \
    --zone=ZONE \
    --machine-type=a3-megagpu-8g \
    --maintenance-policy=TERMINATE \
    --restart-on-failure \
    --image-family=rocky-linux-8-optimized-gcp-nvidia-580 \
    --image-project=rocky-linux-accelerator-cloud \
    --boot-disk-size=BOOT_DISK_SIZE \
    --metadata=cos-update-strategy=update_disabled \
    --scopes=https://www.googleapis.com/auth/cloud-platform \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-mgmt-net,subnet=NETWORK_NAME_PREFIX-mgmt-sub \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-1,subnet=NETWORK_NAME_PREFIX-data-sub-1,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-2,subnet=NETWORK_NAME_PREFIX-data-sub-2,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-3,subnet=NETWORK_NAME_PREFIX-data-sub-3,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-4,subnet=NETWORK_NAME_PREFIX-data-sub-4,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-5,subnet=NETWORK_NAME_PREFIX-data-sub-5,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-6,subnet=NETWORK_NAME_PREFIX-data-sub-6,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-7,subnet=NETWORK_NAME_PREFIX-data-sub-7,no-address \
    --network-interface=nic-type=GVNIC,network=NETWORK_NAME_PREFIX-data-net-8,subnet=NETWORK_NAME_PREFIX-data-sub-8,no-address \
    --provisioning-model=RESERVATION_BOUND \
    --instance-termination-action=TERMINATION_ACTION \
    --reservation-affinity=specific \
    --reservation=RESERVATION_URL

Replace the following:

Give the NICs access to the GPUs

On each A3 Mega VM, give the NICs access to the GPUs.

  1. Install the prerequisite packages for the dmabuf module:
    sudo dnf -y install epel-release kernel-devel-$(uname -r) git
    sudo dnf -y install dkms
      
  2. Install and load the import-helper module, which is part of the dmabuf framework. This framework enables high-speed, zero-copy memory sharing between the GPU and the network interface card (NIC), a critical component for GPUDirect technology:
    sudo git clone https://github.com/google/dmabuf_importer_helper.git /usr/src/import_helper-1.0
    sudo dkms install import_helper/1.0
    sudo modprobe import_helper
      
  3. Install and configure Docker to authenticate requests to Artifact Registry.
    sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
    sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    sudo systemctl --now enable docker
    sudo usermod -a -G docker $(whoami)
    curl -s -L https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo | \
      sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo
    export NVIDIA_CONTAINER_TOOLKIT_VERSION=1.17.8-1
    sudo dnf install -y \
          nvidia-container-toolkit-${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
          nvidia-container-toolkit-base-${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
          libnvidia-container-tools-${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
          libnvidia-container1-${NVIDIA_CONTAINER_TOOLKIT_VERSION}
    sudo nvidia-ctk runtime configure --runtime=docker
    sudo systemctl restart docker
    gcloud auth configure-docker us-docker.pkg.dev
      

    After you run the preceding commands, log out and log back in for the changes to take effect.

  4. Launch RxDM in the container. RxDM is a management service that runs alongside the GPU application to manage GPU memory. This service pre-allocates and manages GPU memory for incoming network traffic, which is a key element of GPUDirect technology and essential for high-performance networking. Start a Docker container named rxdm:
    docker run --pull=always --rm --detach --name rxdm \
        --network=host  --cap-add=NET_ADMIN  \
        --gpus all \
        --privileged \
        --device /dev/dmabuf_import_helper:/dev/dmabuf_import_helper \
        --env LD_LIBRARY_PATH=/usr/lib64  \
        us-docker.pkg.dev/gce-ai-infra/gpudirect-tcpxo/tcpgpudmarxd-dev:v1.0.21 \
        --num_hops=2 --nic_metric_directory=/tmp

    To verify that RxDM has successfully started, run the following command. Wait for the message "Buffer manager initialization complete" to confirm successful RxDM initialization.

    docker container logs --follow  rxdm

    Alternatively, check the RxDM initialization completion log.

    docker container logs rxdm 2>&1 | grep "Buffer manager initialization complete"

Set up NCCL environment

On each A3 Mega VM, complete the following steps:

  1. Install the nccl-net library, a plugin for NCCL that enables GPUDirect communication over the network. The following command pulls the installer image and installs the necessary library files into /var/lib/tcpxo/lib64/.
    NCCL_NET_IMAGE="us-docker.pkg.dev/gce-ai-infra/gpudirect-tcpxo/nccl-plugin-gpudirecttcpx-dev:v1.0.15"
    
    docker run --pull=always --rm --privileged \
        --network=host --cap-add=NET_ADMIN \
        --volume /var/lib:/var/lib \
        --env LD_LIBRARY_PATH=/usr/lib64:/var/lib/tcpxo/lib64 \
        ${NCCL_NET_IMAGE} install  --install-nccl
    
    sudo mount --bind /var/lib/tcpxo /var/lib/tcpxo && sudo mount -o remount,exec /var/lib/tcpxo
    
  2. Configure the aperture mount flags.
    aperture_mount_flags="";
    while IFS= read -r line; do
        BDF=$( echo "$line" | awk '{print $1}' );
        host_aperture_device="/sys/bus/pci/devices/$BDF"
        # replace '/sys/bus/pci/devices' with '/dev/aperture_devices'
        container_aperture_device="${host_aperture_device/\/sys\/bus\/pci\/devices/\/dev\/aperture_devices}";
        aperture_mount_flags+="--mount type=bind,src=${host_aperture_device},target=${container_aperture_device} ";
    done < 
    Web Proxy Viewer  |  New URL  |  Original Page