Performance considerations for large scale deep learning training on Azure NDv4 (A100) series

Published Aug 28 2021 07:33 AM 1,514 Views
Microsoft

Background

The field of Artificial Intelligence is being applied to more and more application areas, such as self-driving cars, natural language processing, visual recognition, fraud detection and many more.

A subset of artificial intelligence is Deep learning (DL), which is used to develop some of the more sophisticated training model, using deep neural networks (DNN) trying to mimic the human brain. Today, some of the largest DL training models can be used to do very complex and creative tasks like write poetry, write code, and understand the context of text/speech.

 

 

CormacGarvey_0-1630093976365.pngCormacGarvey_1-1630094022720.png

 

These large DL models are possible because of advancements in DL algorithms (DeepSpeed )), which maximize the efficiency of GPU memory management. Traditionally, DL models were very parallel floating-point intensive and so performed well on GPU’s, the newer more memory efficient algorithms made it possible to run much larger DL models but at the expense of significantly more inter-node communication operations, specifically, allreduce and alltoall collective operations.

 

Modern DL training jobs require large Clusters of multi-GPUs with high floating-point performance connected with high bandwidth, low latency networks. The Azure NDv4 VM series is designed specifically for these types of workloads. ND96asr_v4 has 8 A100 GPU’s connected via NVlink3, each A100 has access to 200 Gbps HDR InfiniBand, a total of 1.6 Tbps internode communication is possible.

We will be focusing on HPC+AI Clusters built with the ND96asr_v4 virtual machine type and providing specific performance optimization recommendations to get the best performance.

 

CormacGarvey_0-1630094620374.png

 

 

 

 

 

 

 

 

 

 

 

Deep Learning hardware and software stack

The Deep learning hardware and software stack is much more complicated compared to traditional HPC. From the hardware perspective CPU and GPU performance is important, especially floating-point performance and the speed in which data is moved from CPU (host) to GPU (device) or GPU (device) to GPU (device). There are many popular Deep learning frameworks e.g. pytorch, tensorflow, Caffe and CNTK. NCCL is one of the popular collective communication library for Nvidia GPU’s and low-level mathematics operations is dependent on the CUDA tools and libraries. We will touch on many parts of this H/W and S/W stack in this post.

 

CormacGarvey_0-1630095555848.png

 

How to deploy an HPC+AI Cluster (using NDv4)

In this section we discuss some deployment options.

 

Which image to use

It’s recommended that you start with one of the Azure Marketplace images that support NDv4. The advantage of using one of these Marketplace images is the GPU driver, InfiniBand drivers, CUDA, NCCL and MPI libraries (including rdma_sharp_plugin) are pre-installed and should be fully functional after booting up the image.

  • ubuntu-hpc 18.04  (microsoft-dsvm:ubuntu-hpc:1804:latest)
    • Ubuntu is a popular DL linux OS and the most amount of testing on NDv4 was done with version 18.04.
  • Ubuntu-hpc 20.04 (microsoft-dsvm:ubuntu-hpc:2004:latest)
    • Popular image in DL community.
  • CentOS-HPC 7.9 (OpenLogic:CentOS-HPC:7_9-gen2:latest)
    • More popular in HPC, less popular in AI.
    • NOTE: By default the NDv4 GPU NUMA topology is not correct, you need to apply this patch.

Another option, especially if you want to customize your image is to build your own custom image. The best place to start is the azhpc-images GitHub repository, which contains all the scripts used to build the HPC marketplace images.

You can then use packer or Azure Image builder to build the image and Azure Shared image gallery to store, use, share and distribute images.

 

Deployment options

In this section we will explore some options to deploy an HPC+AI NDv4 cluster.

  • Nvidia Nephele
    • Nephele is an open source GitHub repository, primary developers are Nvidia. It’s based on terraform and ansible. It also deploys a SLURM scheduler with container support, using enroot and pyxis.
    • It’s a good and proven benchmark environment.
  • AzureML
    • Is the Azure preferred AI platform, it’s an Azure ML service. It can easily deploy as code a cluster using batch or AKS, upload your environment, create a container, and submit your job. You can monitor and review resulting using the Azure machine learning studio GUI.
    • Maybe less control with specific tuning optimizations.
  • Azure CycleCloud
    • Is an Azure dynamic provisioning and VM autoscaling service that supports many traditional HPC schedulers like PBS, SLURM, LSF etc.
    • By default, containers are not supported and if you would like to have SLURM supporting containers you would need to manually integrate enroot and pyxis with cycleCloud+SLURM.
    • Currently, does not support Ubuntu 20.04.
  • AzureHPC
    • Is an open source framework that can combine many different build blocks to create complex and customized deployments in Azure.
    • It’s designed as a flexible deployment environment for prototyping, testing, and benchmarking, it’s not designed for production.
    • Does not support ubuntu (only CentOS).
  • Azure HPC on-Demand Platform (az-hop)
    • Is designed to be a complete E2E HPC as a service environment, its deployed using terraform and ansible and uses CycleCloud for its dynamic provisioning and autoscaling capabilities. It also supports OnDemand to provide a web interface to the HPC environment.
    • Currently, only supports PBS and does not have any container support.
    • Currently, supports CentOS-HPC based images (no Ubuntu).

 

CormacGarvey_0-1630098217325.png

 

NDv4 tuning considerations

In this section we will look at a couple of areas that should be carefully considered to make sure your large DL training job is running optimally on NDv4.

 

GPU tuning

Here is the procedure to set the GPU’s to maximum clock rates and to then reset the GPU clock rate after your job is completed. The procedure for GPU id 0 is shown, need to do this procedure for all GPUs.

 

First get maximum graphics and memory clock frequencies

max_graphics_freq=$(nvidia-smi -i 0 --query-gpu=clocks.max.graphics --format=csv,noheader,nounits)
max_memory_freq=$( nvidia-smi -i 0 --query-gpu=clocks.max.mem --format=csv,noheader,nounits)
echo “max_graphics_freq=$max_graphics_freq MHz, max_memory_freq=$max_memory_freq MHz”
max_graphics_freq=1410 MHz, max_memory_freq=1215 MHz

 

Then set the GPUs to the maximum and memory clock frequencies.

sudo nvidia-smi -I 0 -ac $max_memory_freq, $max_graphics_freq
Applications clocks set to "(MEM 1215, SM 1410)" for GPU 00000001:00:00.0
All done.

 

Finally, when job is finished, reset the graphics and memory clock frequencies.

sudo nvidia-smi -i 0 -rgc
All done.

 

NCCL tuning

  • It is recommended that you use NCCL version >= 2.9.9, especially at higher parallel scales.
    • export LD_LIBRARY_PATH==/path/to/libnccl.so (or if necessary LD_PRELOAD=/path/to/libnccl.so)
  • Use a specific topology file for ND96asr_v4 and set its location.
    • You can get the ND96asr_v4 topology file here.
    • export NCCL_TOPO_FILE=/path/to/topology.txt
  • Using relaxed ordering for PCI operations is a key mechanism to get maximum performance when targeting memory attached to AMD 2nd Gen EPYC CPUs.
    • export NCCL_IB_PCI_RELAXED_ORDERING=1
    • export UCX_IB_PCI_RELAXED_ORDERING=on
  • This is needed to make sure the correct topology is recognized.
    • export CUDA_DEVICE_ORDER=PCI_BUS_ID
  • Use eth0 (front-end network interface) to start up processes but use ib0 for processes to communicate.
    • export NCCL_SOCKET_IFNAME=eth0
    • export UCX_NET_DEVICES=eth0
  • It’s recommended to print NCCL debug information to verify that the correct environmental variables are set and correct plugins are used (e.g RDMA SHARP plugin).
    • For Initial testing and verification, to check that parameters, environmental variables, and plugins are set correctly.
      • export NCCL_DEBUG=INFO
    • Set to WARNING once you have confidence in your environment.
      • export NCCL_DEBUG=WARNING
  • Enable NCCL RDMA Sharp Plugin, has a big impact on performance and should always be enabled. There are a couple of ways to enable the plugin.
    • source hpcx-init.sh && hpcx_load
    • LD_LIBRARY_PATH=/path/to/plugin/{libnccl-net.so,libsharp*.so}:$LD_LIBRARY_PATH  (or LD_PRELOAD)\
    • Note: SHARP is currently not enabled on ND96asr_v4.
    • Check NCCL_DEBUG=INFO output to verify its loaded.
      • x8a100-0000:60522:60522 [5] NCCL INFO Plugin Path : /opt/hpcx/nccl_rdma_sharp_plugin/lib/libnccl-net.so
  • Lowering the message size threshold to determine if messages are broken up to use adaptive routing may improve the performance of smaller message sizes.
    • export NCCL_IB_AR_THRESHOLD=0
  • Also consider NCCL_TOPO=ring or tree (as experiment/debugging, but defaults are generally good)

 

MPI considerations

When MPI is used with NCCL, MPI is primarily used just to start-up the processes and NCCL is used for efficient collective communication.

You can start processes by explicitly executing mpirun or via a Scheduler MPI integration (e.g SLURM srun command.).

If you have flexibility on the choice of MPI library, then HPCX is the preferred MPI library due to its performance and features.

 

It is required to disable Mellanox hierarchical Collectives (HCOLL) when using MPI with NCCL.

mpirun –mca coll_hcoll_enable 0  or export OMPI_MCA_coll_hcoll_enable=0

 

Process pinning optimizations

The first step is to determine what is the correct CPU (NUMA) to GPU topology. To see where the GPU’s are located, you can use

ltopo or nvidia-smi topo -m

to get this information or use the check application pinning tool (contained in the azurehpc Github repo (see experimental/check_app_pinning_tool)

 

./check_app_pinning.py
Virtual Machine (Standard_ND96asr_v4) Numa topology NumaNode id Core ids GPU ids ============ ==================== ========== 0 ['0-23'] [2, 3] 1 ['24-47'] [0, 1] 2 ['48-71'] [6, 7] 3 ['72-95'] [4, 5]

 

We can see that 2 GPU’s are located in each NUMA domain and that the GPU id order is not 0,1,2,3,4,5,6,7, but 3,2,1,0,7,6,5,4. To make sure all GPU’s are used and running optimally we need to make sure that 2 processes are mapped correctly and running in each NUMA domain. There are several ways to force the correct gpu to cpu mapping. In SLURM we can map GPU ids 0,1 to NUMA 1,

GPU ids 2,3 to NUMA 0, GPU ids 4,5 to NUMA 3 and GPU ids 6,7 to NUMA 2 with the following explicit mapping using the SLURM srun command to launch processes.

 

srun --cpu-bind=mask_cpu:ffffff000000,ffffff000000,ffffff,ffffff,ffffff000000000000000000,ffffff000000000000000000,ffffff000000000000,ffffff000000000000

 

A similar gpu to cpu mapping is possible with HPCX MPI, setting the following environmental variable and mpirun arguments

export  CUDA_VISIBLE_DEVICES=2,3,0,1,6,7,4,5
--map-by ppr:2:numa                                      (Add :pe=N, if running hybrid parallel (threads in addition to processes)

Then you can use the AzureHPC check_app_pinning.py tool as your job runs to verify if processes/threads are pinned optimally.

 

I/O tuning

Two aspects of I/O need to be addressed.

  1. Scratch Storage
    1. This type of storage needs to be fast (high throughput and low latency); the training job needs to read data, process the data and use this storage location as scratch space as the job runs.
    2. In an ideal case you would use the local SSD on each VM directly. The NDv4 has a local SSD already mounted at /mnt (2.8 TB), it also has 8 NVMe SSD devices, which when configured and mounted (see below), have ~7 TB capacity.
    3. If you need a shared filesystem for scratch, combining all NVMe SSD’s and creating a PFS system may be great option from a cost and performance perspective assuming it has sufficient capacity one way to do this is with BeeOND, if not there are other storage options to explore (IaaS Lustre PFS, Azure ClusterStor and Azure Netapp files).
  2. Checkpoint Storage
    1. Large DL training jobs can run for Weeks depending on how many VM’s are used, just like any HPC cluster you can have failures (e.g. InfiniBand, memory DIM, ECC error GPU memory etc). It’s critical to have a checkpointing strategy, know the checkpoint interval (e.g. when data is checkpointed), each time how much data is transferred and have a storage solution in place that can satisfy that capacity and performance requirements. If Blob Storage can meet the storage performance, it’s a great option.

 

How to set-up and configure the NDv4 local NVMe SSD’s

ND96asr_v4 virtual machine contains 8 NVMe SSD devices. You can combine the 8 devices into a striped raid 0 device, that can then be used to create an XFS (or ext4) filesystem and mounted. The script below can be run on all NDv4 VM’s with a parallel shell (e.g pdsh) to create a ~7TB local scratch space (/mnt_nvme).

The resulting local scratch space has a read and write I/O throughput of ~8 GB/s.

 

 

#!/bin/bash 
mkdir /mnt/resource_nvme
mdadm --create /dev/md128 --level 0 --raid-devices 8 /dev/nvme0n1 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme3n1 /dev/nvme4n1 /dev/nvme5n1 /dev/nvme6n1 /dev/nvme7n1
mkfs.xfs /dev/md128
mount /dev/md128 /mnt/resource_nvme

 

 

CormacGarvey_0-1630103159493.png

 

CormacGarvey_1-1630103193234.png

Restricting data transfer to BLOB storage using the azcopy tool

The process described here is specific to azcopy, but the same principals can be applied to any of the language specific SDK (e.g BLOB API via python).

In this example, lets assume that we have as single BLOB storage account with an ingress limit of 20 Gbps. At each checkpoint, 8 files (corresponding to each GPU) need to be copied to the BLOB storage account, each file will be transferred with its own azcopy. We choose that each azcopy can transfer data at a maximum transfer speed of 2300 Mbps (2300 x 8 = 18400 < 20000 Gpbs) to avoid throttling. The ND96asr_v4 has 96 vcores and so we choose that each azcopy can use 10 cores, so each instance of azcopy gets enough cores and other processes have some additional vcores.

 

export AZCOPY_CONCURRENCY_VALUE=10
azcopy cp ./file “blob_storage_acc_container” –caps-mbps 2300

 

DeepSpeed and Onnx Runtime (ORT)

The performance of large scale  DL training models built with the pytorch framework can be significantly improved by utilizing DeepSpeed and/or Onnx runtime. It can be straight forward to enable DeepSpeed and Onnx runtime by importing a few extra modules and replacing a few lines of code with some wrapper functions. If using DeepSpeed and Onnx its best practice to apply Onnx first and then DeepSpeed.

 

HPC+AI NDv4 cluster health checks

Within Azure there is automated testing to help identify unhealthy VM’s. Our testing processes and procedures continue to improve, but still it is possible for an unhealthy VM to be not identified by our testing and to be deployed. Large DL training jobs typically require many VM’s collaborating and communicating with each other to complete the DL job. The more VM’s deployed the greater the change that one of them may be unhealthy, resulting in the DL job failing or underperforming. It is recommended that before starting a large scale DL training job to run some health checks on your cluster to verify it’s performing as expected.

 

Check GPU floating-point performance

Run high performance linpack (HPL) on each VM, its convenience to use the version contained in the Nvidia hpc-benchmarks container.

If you plan to use the Nvidia hpc-benchmarks-container with the SLURM enroot container integration, then you will need to add your ncvr container registry credentials to  this file~/.config/enroot/.credentials. The syntax should be

machine nvcr.io login $oauthtoken <API KEY>

(Note: This is a non-optimized version of HPL so the numbers reported are ~5-7% slower than the optimized container. It will give you good node to node variation numbers and identify a system that is having CPU, memory, or GPU issues).

 

 

#!/bin/bash
#SBATCH -t 00:20:00
#SBATCH --ntasks-per-node=8
#SBATCH -o logs/%x_%j.log

CONT='nvcr.io#nvidia/hpc-benchmarks:20.10-hpl'
MOUNT='/nfs2/hpl/dats/hpl-${SLURM_JOB_NUM_NODES}N.dat:/workspace/hpl-linux-x86_64/sample-dat/HPL-dgx-a100-${SLURM_JOB_NUM_NODES}N.dat'
echo "Running on hosts: $(echo $(scontrol show hostname))"

export NCCL_DEBUG=INFO
export OMPI_MCA_pml=ucx
export OMPI_MCA_btl=^openib,smcuda

CMD="hpl.sh --cpu-affinity 24-35:36-47:0-11:12-23:72-83:84-95:48-59:60-71 --cpu-cores-per-rank 8 --gpu-affinity 0:1:2:3:4:5:6:7 --mem-affinity 1:1:0:0:3:3:2:2  --ucx-affinity ibP257p0s0:ibP258p0s0:ibP259p0s0:ibP260p0s0:ibP261p0s0:ibP262p0s0:ibP263p0s0:ibP264p0s0 --dat /workspace/hpl-linux-x86_64/sample-dat/HPL-dgx-a100-${SLURM_JOB_NUM_NODES}N.dat"
srun --gpus-per-node=8 --container-image="${CONT}" --container-mounts="${MOUNT}" ${CMD}

 

You should see ~95 TFLOPs DP on ND96asr_v4 (which has 8 A100 GPU’s)

 

Check host to device and device to host transfer bandwidth

The CUDA bandwidthTest is a convenience way to verify that the host to gpu and gpu to host  data bandwidth speeds are good. Below is an example testing gpu id = 0, you would run a similar test for the other 7 gpu_ids, paying close attention to what NUMA domains they are contained in.

numactl --cpunodebind=1 --membind=1 ./bandwidthTest --dtoh --htod --device=0

[CUDA Bandwidth Test] - Starting...
Running on...

 Device 0: A100-SXM4-40GB
 Quick Mode

 Host to Device Bandwidth, 1 Device(s)
 PINNED Memory Transfers
   Transfer Size (Bytes)        Bandwidth(GB/s)
   32000000                     26.1

 Device to Host Bandwidth, 1 Device(s)
 PINNED Memory Transfers
   Transfer Size (Bytes)        Bandwidth(GB/s)
   32000000                     25.0

Result = PASS

The expected host to device and device to host transfer speed is > 20 GB/s.

This health check and many more detailed tests to diagnose unhealthy VMs can be found in the azhpc-diagnostics Github repository.

 

Check the InfiniBand network and NCCL performance

Running a NCCL allreduce and/or alltoall benchmark at the scale you plan on running your deep learning training job is a great way to identify problems with the InfiniBand inter-node network or with NCCL performance.

Here is a SLURM script to run a NCCL alltoall benchmark (Note: using SLURM container integration with enroot+pyxis to use the Nvidia pytorch container.)

 

 

#!/bin/bash
#SBATCH -t 00:20:00
#SBATCH --ntasks-per-node=8
#SBATCH --gpus-per-node=8
#SBATCH -o logs/%x_%j.log
export UCX_IB_PCI_RELAXED_ORDERING=on \
       UCX_TLS=tcp \
       NCCL_DEBUG=INFO \
       CUDA_DEVICE_ORDER=PCI_BUS_ID \
       NCCL_IB_PCI_RELAXED_ORDERING=1 \
       NCCL_SOCKET_IFNAME=eth0 \
       UCX_NET_DEVICES=eth0 \
       NCCL_TOPO_FILE=/workspace/nccl/nccl-topology.txt

CONT="nvcr.io#nvidia/pytorch:21.05-py3"
MOUNT="/nfs2/nccl:/workspace/nccl_284,/nfs2/hpcx-v2.8.1-gcc-MLNX_OFED_LINUX-5.1-0.6.6.0-ubuntu18.04-x86_64:/opt/hpcx,/nfs2/nccl_2.10.3-1/nccl:/workspace/nccl"

export OMPI_MCA_pml=ucx
export OMPI_MCA_btl=^openib
export OMPI_MCA_COLL_HCOLL_ENABLE=0

srun --ntasks=$SLURM_JOB_NUM_NODES --container-image "${CONT}" \
    --container-name=nccl \
    --container-mounts="${MOUNT}" \
    --ntasks-per-node=1 \
    bash -c "apt update && apt-get install -y infiniband-diags"

srun --gpus-per-node=8 \
    --ntasks-per-node=8 \
    --container-name=nccl \
    --container-mounts "${MOUNT}" \
    bash -c 'export LD_LIBRARY_PATH=/opt/hpcx/nccl_rdma_sharp_plugin/lib:/opt/hpcx/sharp/lib:/workspace/nccl/build/lib:$LD_LIBRARY_PATH && /workspace/nccl/nccl-tests/build/alltoall_perf -b8 -f2 -g1 -e 8G'

 

 

Then submit the above script on for example 4 ND96asr_v4 VM’s

sbatch -N 4 ./nccl.slrm

 Similarly, for allreduce, just change the executable to be all_reduce_perf.

The following plots show NCCL allreduce and alltoall expect performance on ND96asr_v4.

 

CormacGarvey_0-1630106993288.png

CormacGarvey_1-1630107011467.png

 

Summary

Large scale DL models are becoming very complex and sophisticated being applied to many application areas. The computational and network resources to train these large modern DL models can be quite substantial. The Azure NDv4 series is designed specifically for these large scale DL computational, network and I/O requirements.

Several key performance optimization tips and tricks are discussed to allow you to get the best possible performance running your large deep learning model on Azure NDv4 series.

 

Credits

To would like to acknowledge the significant contribution of my Colleagues at Microsoft to this post. Jithin Jose provided the NCCL scaling performance data and was the primary contributor to the NCCL, MPI an GPU tuning parameters, he also helped review this document. I would also like to thank Kanchan Mehrotra and Jon Shelley for reviewing this document and providing outstanding feedback.

%3CLINGO-SUB%20id%3D%22lingo-sub-2693834%22%20slang%3D%22en-US%22%3EPerformance%20considerations%20for%20large%20scale%20deep%20learning%20training%20on%20Azure%20NDv4%20(A100)%20series%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2693834%22%20slang%3D%22en-US%22%3E%3CH2%20id%3D%22toc-hId--377408101%22%20id%3D%22toc-hId--377354348%22%3EBackground%3C%2FH2%3E%0A%3CP%3EThe%20field%20of%20Artificial%20Intelligence%20is%20being%20applied%20to%20more%20and%20more%20application%20areas%2C%20such%20as%20self-driving%20cars%2C%20natural%20language%20processing%2C%20visual%20recognition%2C%20fraud%20detection%20and%20many%20more.%3C%2FP%3E%0A%3CP%3EA%20subset%20of%20artificial%20intelligence%20is%20Deep%20learning%20(DL)%2C%20which%20is%20used%20to%20develop%20some%20of%20the%20more%20sophisticated%20training%20model%2C%20using%20deep%20neural%20networks%20(DNN)%20trying%20to%20mimic%20the%20human%20brain.%20Today%2C%20some%20of%20the%20largest%20DL%20training%20models%20can%20be%20used%20to%20do%20very%20complex%20and%20creative%20tasks%20like%26nbsp%3Bwrite%20poetry%2C%26nbsp%3Bwrite%20code%2C%20and%20understand%20the%20context%20of%20text%2Fspeech.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22CormacGarvey_0-1630093976365.png%22%20style%3D%22width%3A%20278px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F306337iC3AFE13FB1D3D5C5%2Fimage-dimensions%2F278x254%3Fv%3Dv2%22%20width%3D%22278%22%20height%3D%22254%22%20role%3D%22button%22%20title%3D%22CormacGarvey_0-1630093976365.png%22%20alt%3D%22CormacGarvey_0-1630093976365.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22CormacGarvey_1-1630094022720.png%22%20style%3D%22width%3A%20380px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F306338i6139A73B92423DE2%2Fimage-dimensions%2F380x253%3Fv%3Dv2%22%20width%3D%22380%22%20height%3D%22253%22%20role%3D%22button%22%20title%3D%22CormacGarvey_1-1630094022720.png%22%20alt%3D%22CormacGarvey_1-1630094022720.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThese%20large%20DL%20models%20are%20possible%20because%20of%20advancements%20in%20DL%20algorithms%20(%3CA%20href%3D%22https%3A%2F%2Fwww.deepspeed.ai%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EDeepSpeed%3C%2FA%3E%26nbsp%3B))%2C%20which%20maximize%20the%20efficiency%20of%20GPU%20memory%20management.%20Traditionally%2C%20DL%20models%20were%20very%20parallel%20floating-point%20intensive%20and%20so%20performed%20well%20on%20GPU%E2%80%99s%2C%20the%20newer%20more%20memory%20efficient%20algorithms%20made%20it%20possible%20to%20run%20much%20larger%20DL%20models%20but%20at%20the%20expense%20of%20significantly%20more%20inter-node%20communication%20operations%2C%20specifically%2C%20allreduce%20and%20alltoall%20collective%20operations.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EModern%20DL%20training%20jobs%20require%20large%20Clusters%20of%20multi-GPUs%20with%20high%20floating-point%20performance%20connected%20with%20high%20bandwidth%2C%20low%20latency%20networks.%20The%20Azure%20NDv4%20VM%20series%20is%20designed%20specifically%20for%20these%20types%20of%20workloads.%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fblog%2Fazure-announces-general-availability-of-scaleup-scaleout-nvidia-a100-gpu-instances-claims-title-of-fastest-public-cloud-super%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3END96asr_v4%3C%2FA%3E%20has%208%20A100%20GPU%E2%80%99s%20connected%26nbsp%3Bvia%20NVlink3%2C%20each%20A100%20has%20access%20to%20200%20Gbps%20HDR%20InfiniBand%2C%20a%20total%20of%201.6%20Tbps%20internode%20communication%20is%20possible.%3C%2FP%3E%0A%3CP%3EWe%20will%20be%20focusing%20on%20HPC%2BAI%20Clusters%20built%20with%20the%20ND96asr_v4%20virtual%20machine%20type%20and%20providing%20specific%20performance%20optimization%20recommendations%20to%20get%20the%20best%20performance.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-left%22%20image-alt%3D%22CormacGarvey_0-1630094620374.png%22%20style%3D%22width%3A%20642px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F306342i32D029F232141012%2Fimage-dimensions%2F642x309%3Fv%3Dv2%22%20width%3D%22642%22%20height%3D%22309%22%20role%3D%22button%22%20title%3D%22CormacGarvey_0-1630094620374.png%22%20alt%3D%22CormacGarvey_0-1630094620374.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-2110104732%22%20id%3D%22toc-hId-2110158485%22%3EDeep%20Learning%20hardware%20and%20software%20stack%3C%2FH2%3E%0A%3CP%3EThe%20Deep%20learning%20hardware%20and%20software%20stack%20is%20much%20more%20complicated%20compared%20to%20traditional%20HPC.%20From%20the%20hardware%20perspective%20CPU%20and%20GPU%20performance%20is%20important%2C%20especially%20floating-point%20performance%20and%20the%20speed%20in%20which%20data%20is%20moved%20from%20CPU%20(host)%20to%20GPU%20(device)%20or%20GPU%20(device)%20to%20GPU%20(device).%20There%20are%20many%20popular%20Deep%20learning%20frameworks%20e.g.%20pytorch%2C%20tensorflow%2C%20Caffe%20and%20CNTK.%20NCCL%20is%20one%20of%20the%20popular%20collective%20communication%20library%20for%20Nvidia%20GPU%E2%80%99s%20and%20low-level%20mathematics%20operations%20is%20dependent%20on%20the%20CUDA%20tools%20and%20libraries.%20We%20will%20touch%20on%20many%20parts%20of%20this%20H%2FW%20and%20S%2FW%20stack%20in%20this%20post.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22CormacGarvey_0-1630095555848.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F306356iD09B23694F69FA6A%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22CormacGarvey_0-1630095555848.png%22%20alt%3D%22CormacGarvey_0-1630095555848.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-302650269%22%20id%3D%22toc-hId-302704022%22%3EHow%20to%20deploy%20an%20HPC%2BAI%20Cluster%20(using%20NDv4)%3C%2FH2%3E%0A%3CP%3EIn%20this%20section%20we%20discuss%20some%20deployment%20options.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-993211743%22%20id%3D%22toc-hId-993265496%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId--814242720%22%20id%3D%22toc-hId--814188967%22%3EWhich%20image%20to%20use%3C%2FH3%3E%0A%3CP%3EIt%E2%80%99s%20recommended%20that%20you%20start%20with%20one%20of%20the%20Azure%20Marketplace%20images%20that%20support%20NDv4.%20The%20advantage%20of%20using%20one%20of%20these%20Marketplace%20images%20is%20the%20GPU%20driver%2C%20InfiniBand%20drivers%2C%20CUDA%2C%20NCCL%20and%20MPI%20libraries%20(including%20rdma_sharp_plugin)%20are%20pre-installed%20and%20should%20be%20fully%20functional%20after%20booting%20up%20the%20image.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Eubuntu-hpc%2018.04%26nbsp%3B%20(microsoft-dsvm%3Aubuntu-hpc%3A1804%3Alatest)%3CUL%3E%0A%3CLI%3EUbuntu%20is%20a%20popular%20DL%20linux%20OS%20and%20the%20most%20amount%20of%20testing%20on%20NDv4%20was%20done%20with%20version%2018.04.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EUbuntu-hpc%2020.04%20(microsoft-dsvm%3Aubuntu-hpc%3A2004%3Alatest)%3CUL%3E%0A%3CLI%3EPopular%20image%20in%20DL%20community.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3ECentOS-HPC%207.9%20(OpenLogic%3ACentOS-HPC%3A7_9-gen2%3Alatest)%3CUL%3E%0A%3CLI%3EMore%20popular%20in%20HPC%2C%20less%20popular%20in%20AI.%3C%2FLI%3E%0A%3CLI%3ENOTE%3A%20By%20default%20the%20NDv4%20GPU%20NUMA%20topology%20is%20not%20correct%2C%20you%20need%20to%20apply%20this%20%3CA%20href%3D%22https%3A%2F%2Fnam06.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fgit.kernel.org%252Fpub%252Fscm%252Flinux%252Fkernel%252Fgit%252Ftorvalds%252Flinux.git%252Fcommit%252Fdrivers%252Fpci%252Fcontroller%252Fpci-hyperv.c%253Fh%253Dv5.14-rc1%2526id%253D999dd956d8389f3a512808f36fac97e1c8e87c7f%26amp%3Bdata%3D04%257C01%257CCormac.Garvey%2540microsoft.com%257C05b22bbc661943d70bee08d9513aed15%257C72f988bf86f141af91ab2d7cd011db47%257C1%257C0%257C637630135801847267%257CUnknown%257CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%253D%257C1000%26amp%3Bsdata%3Dt5JhBuFy%252BFsSscyJe%252Fl7gr%252B5DOH3sPWbBUHzeMErHbw%253D%26amp%3Breserved%3D0%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Epatch%3C%2FA%3E.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EAnother%20option%2C%20especially%20if%20you%20want%20to%20customize%20your%20image%20is%20to%20build%20your%20own%20custom%20image.%20The%20best%20place%20to%20start%20is%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazhpc-images%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Eazhpc-images%3C%2FA%3E%20GitHub%20repository%2C%20which%20contains%20all%20the%20scripts%20used%20to%20build%20the%20HPC%20marketplace%20images.%3C%2FP%3E%0A%3CP%3EYou%20can%20then%20use%20packer%20or%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-machines%2Fimage-builder-overview%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Image%20builder%3C%2FA%3E%20to%20build%20the%20image%20and%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-machines%2Fshared-image-galleries%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Shared%20image%20gallery%3C%2FA%3E%20to%20store%2C%20use%2C%20share%20and%20distribute%20images.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1673270113%22%20id%3D%22toc-hId-1673323866%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId--134184350%22%20id%3D%22toc-hId--134130597%22%3EDeployment%20options%3C%2FH3%3E%0A%3CP%3EIn%20this%20section%20we%20will%20explore%20some%20options%20to%20deploy%20an%20HPC%2BAI%20NDv4%20cluster.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ENvidia%20Nephele%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FNVIDIA%2Fnephele%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3ENephele%3C%2FA%3E%20is%20an%20open%20source%20GitHub%20repository%2C%20primary%20developers%20are%20Nvidia.%20It%E2%80%99s%20based%20on%20%3CA%20href%3D%22https%3A%2F%2Fwww.terraform.io%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Eterraform%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Fwww.ansible.com%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Eansible%3C%2FA%3E.%20It%20also%20deploys%20a%20SLURM%20scheduler%20with%20container%20support%2C%20using%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FNVIDIA%2Fenroot%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Eenroot%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FNVIDIA%2Fpyxis%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Epyxis%3C%2FA%3E.%3C%2FLI%3E%0A%3CLI%3EIt%E2%80%99s%20a%20good%20and%20proven%20benchmark%20environment.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fservices%2Fmachine-learning%2F%23product-overview%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzureML%3C%2FA%3E%3CUL%3E%0A%3CLI%3EIs%20the%20Azure%20preferred%20AI%20platform%2C%20it%E2%80%99s%20an%20Azure%20ML%20service.%20It%20can%20easily%20deploy%20as%20code%20a%20cluster%20using%20batch%20or%20AKS%2C%20upload%20your%20environment%2C%20create%20a%20container%2C%20and%20submit%20your%20job.%20You%20can%20monitor%20and%20review%20resulting%20using%20the%20Azure%20machine%20learning%20studio%20GUI.%3C%2FLI%3E%0A%3CLI%3EMaybe%20less%20control%20with%20specific%20tuning%20optimizations.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fcyclecloud%2Foverview%3Fview%3Dcyclecloud-8%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20CycleCloud%3C%2FA%3E%3CUL%3E%0A%3CLI%3EIs%20an%20Azure%20dynamic%20provisioning%20and%20VM%20autoscaling%20service%20that%20supports%20many%20traditional%20HPC%20schedulers%20like%20PBS%2C%20SLURM%2C%20LSF%20etc.%3C%2FLI%3E%0A%3CLI%3EBy%20default%2C%20containers%20are%20not%20supported%20and%20if%20you%20would%20like%20to%20have%20SLURM%20supporting%20containers%20you%20would%20need%20to%20manually%20integrate%20enroot%20and%20pyxis%20with%20cycleCloud%2BSLURM.%3C%2FLI%3E%0A%3CLI%3ECurrently%2C%20does%20not%20support%20Ubuntu%2020.04.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazurehpc%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzureHPC%3C%2FA%3E%3CUL%3E%0A%3CLI%3EIs%20an%20open%20source%20framework%20that%20can%20combine%20many%20different%20build%20blocks%20to%20create%20complex%20and%20customized%20deployments%20in%20Azure.%3C%2FLI%3E%0A%3CLI%3EIt%E2%80%99s%20designed%20as%20a%20flexible%20deployment%20environment%20for%20prototyping%2C%20testing%2C%20and%20benchmarking%2C%20it%E2%80%99s%20not%20designed%20for%20production.%3C%2FLI%3E%0A%3CLI%3EDoes%20not%20support%20ubuntu%20(only%20CentOS).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Faz-hop%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20HPC%20on-Demand%20Platform%20(az-hop)%3C%2FA%3E%3CUL%3E%0A%3CLI%3EIs%20designed%20to%20be%20a%20complete%20E2E%20HPC%20as%20a%20service%20environment%2C%20its%20deployed%20using%20terraform%20and%20ansible%20and%20uses%20CycleCloud%20for%20its%20dynamic%20provisioning%20and%20autoscaling%20capabilities.%20It%20also%20supports%20OnDemand%20to%20provide%20a%20web%20interface%20to%20the%20HPC%20environment.%3C%2FLI%3E%0A%3CLI%3ECurrently%2C%20only%20supports%20PBS%20and%20does%20not%20have%20any%20container%20support.%3C%2FLI%3E%0A%3CLI%3ECurrently%2C%20supports%20CentOS-HPC%20based%20images%20(no%20Ubuntu).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22CormacGarvey_0-1630098217325.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F306369i706A7058B59D0D1D%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22CormacGarvey_0-1630098217325.png%22%20alt%3D%22CormacGarvey_0-1630098217325.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--144687454%22%20id%3D%22toc-hId--144633701%22%3ENDv4%20tuning%20considerations%3C%2FH2%3E%0A%3CP%3EIn%20this%20section%20we%20will%20look%20at%20a%20couple%20of%20areas%20that%20should%20be%20carefully%20considered%20to%20make%20sure%20your%20large%20DL%20training%20job%20is%20running%20optimally%20on%20NDv4.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-545874020%22%20id%3D%22toc-hId-545927773%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId--1261580443%22%20id%3D%22toc-hId--1261526690%22%3EGPU%20tuning%3C%2FH3%3E%0A%3CP%3EHere%20is%20the%20procedure%20to%20set%20the%20GPU%E2%80%99s%20to%20maximum%20clock%20rates%20and%20to%20then%20reset%20the%20GPU%20clock%20rate%20after%20your%20job%20is%20completed.%20The%20procedure%20for%20GPU%20id%200%20is%20shown%2C%20need%20to%20do%20this%20procedure%20for%20all%20GPUs.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%20get%20maximum%20graphics%20and%20memory%20clock%20frequencies%3C%2FP%3E%0A%3CPRE%3Emax_graphics_freq%3D%24(nvidia-smi%20-i%200%20--query-gpu%3Dclocks.max.graphics%20--format%3Dcsv%2Cnoheader%2Cnounits)%0Amax_memory_freq%3D%24(%20nvidia-smi%20-i%200%20--query-gpu%3Dclocks.max.mem%20--format%3Dcsv%2Cnoheader%2Cnounits)%0Aecho%20%E2%80%9Cmax_graphics_freq%3D%24max_graphics_freq%20MHz%2C%20max_memory_freq%3D%24max_memory_freq%20MHz%E2%80%9D%0Amax_graphics_freq%3D1410%20MHz%2C%20max_memory_freq%3D1215%20MHz%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%20set%20the%20GPUs%20to%20the%20maximum%20and%20memory%20clock%20frequencies.%3C%2FP%3E%0A%3CPRE%3Esudo%20nvidia-smi%20-I%200%20-ac%20%24max_memory_freq%2C%20%24max_graphics_freq%0AApplications%20clocks%20set%20to%20%22(MEM%201215%2C%20SM%201410)%22%20for%20GPU%2000000001%3A00%3A00.0%0AAll%20done.%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFinally%2C%20when%20job%20is%20finished%2C%20reset%20the%20graphics%20and%20memory%20clock%20frequencies.%3C%2FP%3E%0A%3CPRE%3Esudo%20nvidia-smi%20-i%200%20-rgc%0AAll%20done.%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-530768911%22%20id%3D%22toc-hId-530822664%22%3ENCCL%20tuning%3C%2FH3%3E%0A%3CUL%3E%0A%3CLI%3EIt%20is%20recommended%20that%20you%20use%20NCCL%20version%20%26gt%3B%3D%202.9.9%2C%20especially%20at%20higher%20parallel%20scales.%3CUL%3E%0A%3CLI%3Eexport%20LD_LIBRARY_PATH%3D%3D%2Fpath%2Fto%2Flibnccl.so%20(or%20if%20necessary%20LD_PRELOAD%3D%2Fpath%2Fto%2Flibnccl.so)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EUse%20a%20specific%20topology%20file%20for%20ND96asr_v4%20and%20set%20its%20location.%3CUL%3E%0A%3CLI%3EYou%20can%20get%20the%20ND96asr_v4%20topology%20file%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazhpc-images%2Fblob%2Fd3b3489fef9c41062c041952a6b8b44ced829147%2Fcommon%2Fnetwork-tuning.sh%23L7%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FLI%3E%0A%3CLI%3Eexport%20NCCL_TOPO_FILE%3D%2Fpath%2Fto%2Ftopology.txt%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EUsing%20relaxed%20ordering%20for%20PCI%20operations%20is%20a%20key%20mechanism%20to%20get%20maximum%20performance%20when%20targeting%20memory%20attached%20to%20AMD%202nd%20Gen%20EPYC%20CPUs.%3CUL%3E%0A%3CLI%3Eexport%20NCCL_IB_PCI_RELAXED_ORDERING%3D1%3C%2FLI%3E%0A%3CLI%3Eexport%20UCX_IB_PCI_RELAXED_ORDERING%3Don%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EThis%20is%20needed%20to%20make%20sure%20the%20correct%20topology%20is%20recognized.%3CUL%3E%0A%3CLI%3Eexport%20CUDA_DEVICE_ORDER%3DPCI_BUS_ID%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EUse%20eth0%20(front-end%20network%20interface)%20to%20start%20up%20processes%20but%20use%20ib0%20for%20processes%20to%20communicate.%3CUL%3E%0A%3CLI%3Eexport%26nbsp%3BNCCL_SOCKET_IFNAME%3Deth0%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EIt%E2%80%99s%20recommended%20to%20print%20NCCL%20debug%20information%20to%20verify%20that%20the%20correct%20environmental%20variables%20are%20set%20and%20correct%20plugins%20are%20used%20(e.g%20RDMA%20SHARP%20plugin).%3CUL%3E%0A%3CLI%3EFor%20Initial%20testing%20and%20verification%2C%20to%20check%20that%20parameters%2C%20environmental%20variables%2C%20and%20plugins%20are%20set%20correctly.%3CUL%3E%0A%3CLI%3Eexport%20NCCL_DEBUG%3DINFO%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3ESet%20to%20WARNING%20once%20you%20have%20confidence%20in%20your%20environment.%3CUL%3E%0A%3CLI%3Eexport%20NCCL_DEBUG%3DWARNING%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EEnable%20NCCL%20RDMA%20Sharp%20Plugin%2C%20has%20a%20big%20impact%20on%20performance%20and%20should%20always%20be%20enabled.%20There%20are%20a%20couple%20of%20ways%20to%20enable%20the%20plugin.%3CUL%3E%0A%3CLI%3Esource%20hpcx-init.sh%20%26amp%3B%26amp%3B%20hpcx_load%3C%2FLI%3E%0A%3CLI%3ELD_LIBRARY_PATH%3D%2Fpath%2Fto%2Fplugin%2F%7Blibnccl-net.so%2Clibsharp*.so%7D%3A%24LD_LIBRARY_PATH%26nbsp%3B%20(or%20LD_PRELOAD)%5C%3C%2FLI%3E%0A%3CLI%3ENote%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.mellanox.com%2Fdisplay%2Fsharpv214%2FIntroduction%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3ESHARP%3C%2FA%3E%20is%20currently%20not%20enabled%20on%20ND96asr_v4.%3C%2FLI%3E%0A%3CLI%3ECheck%20NCCL_DEBUG%3DINFO%20output%20to%20verify%20its%20loaded.%3CUL%3E%0A%3CLI%3Ex8a100-0000%3A60522%3A60522%20%5B5%5D%20NCCL%20INFO%20Plugin%20Path%20%3A%20%2Fopt%2Fhpcx%2Fnccl_rdma_sharp_plugin%2Flib%2Flibnccl-net.so%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3ELowering%20the%20message%20size%20threshold%20to%20determine%20if%20messages%20are%20broken%20up%20to%20use%20adaptive%20routing%20may%20improve%20the%20performance%20of%20smaller%20message%20sizes.%3CUL%3E%0A%3CLI%3Eexport%20NCCL_IB_AR_THRESHOLD%3D0%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EAlso%20consider%20NCCL_TOPO%3Dring%20or%20tree%20(as%20experiment%2Fdebugging%2C%20but%20defaults%20are%20generally%20good)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH3%20id%3D%22toc-hId--1276685552%22%20id%3D%22toc-hId--1276631799%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-1210827281%22%20id%3D%22toc-hId-1210881034%22%3EMPI%20considerations%3C%2FH3%3E%0A%3CP%3EWhen%20MPI%20is%20used%20with%20NCCL%2C%20MPI%20is%20primarily%20used%20just%20to%20start-up%20the%20processes%20and%20NCCL%20is%20used%20for%20efficient%20collective%20communication.%3C%2FP%3E%0A%3CP%3EYou%20can%20start%20processes%20by%20explicitly%20executing%20mpirun%20or%20via%20a%20Scheduler%20MPI%20integration%20(e.g%20SLURM%20srun%20command.).%3C%2FP%3E%0A%3CP%3EIf%20you%20have%20flexibility%20on%20the%20choice%20of%20MPI%20library%2C%20then%20HPCX%20is%20the%20preferred%20MPI%20library%20due%20to%20its%20performance%20and%20features.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%20is%20required%20to%20disable%20Mellanox%20hierarchical%20Collectives%20(HCOLL)%20when%20using%20MPI%20with%20NCCL.%3C%2FP%3E%0A%3CPRE%3Empirun%20%E2%80%93mca%20coll_hcoll_enable%200%26nbsp%3B%20or%20export%20OMPI_MCA_COLL_HCOLL_ENABLE%3D0%3C%2FPRE%3E%0A%3CH3%20id%3D%22toc-hId--596627182%22%20id%3D%22toc-hId--596573429%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-1890885651%22%20id%3D%22toc-hId-1890939404%22%3EProcess%20pinning%20optimizations%3C%2FH3%3E%0A%3CP%3EThe%20first%20step%20is%20to%20determine%20what%20is%20the%20correct%20CPU%20(NUMA)%20to%20GPU%20topology.%20To%20see%20where%20the%20GPU%E2%80%99s%20are%20located%2C%20you%20can%20use%3C%2FP%3E%0A%3CPRE%3Eltopo%20or%20nvidia-smi%20topo%20-m%3C%2FPRE%3E%0A%3CP%3Eto%20get%20this%20information%20or%20use%20the%20check%20application%20pinning%20tool%20(contained%20in%20the%20azurehpc%20Github%20repo%20(see%20experimental%2Fcheck_app_pinning_tool)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E.%2Fcheck_app_pinning.py%3CBR%20%2F%3E%0AVirtual%20Machine%20(Standard_ND96asr_v4)%20Numa%20topology%0A%0ANumaNode%20id%20%20%20%20%20%20%20%20Core%20ids%20%20%20%20%20%20%20%20%20%20%20%20GPU%20ids%0A%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20%20%20%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B'0-23'%5D%20%20%20%20%20%20%20%20%20%20%20%20%5B2%2C%203%5D%0A1%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B'24-47'%5D%20%20%20%20%20%20%20%20%20%20%20%5B0%2C%201%5D%0A2%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B'48-71'%5D%20%20%20%20%20%20%20%20%20%20%20%5B6%2C%207%5D%0A3%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B'72-95'%5D%20%20%20%20%20%20%20%20%20%20%20%5B4%2C%205%5D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20see%20that%202%20GPU%E2%80%99s%20are%20located%20in%20each%20NUMA%20domain%20and%20that%20the%20GPU%20id%20order%20is%20not%200%2C1%2C2%2C3%2C4%2C5%2C6%2C7%2C%20but%203%2C2%2C1%2C0%2C7%2C6%2C5%2C4.%20To%20make%20sure%20all%20GPU%E2%80%99s%20are%20used%20and%20running%20optimally%20we%20need%20to%20make%20sure%20that%202%20processes%20are%20mapped%20correctly%20and%20running%20in%20each%20NUMA%20domain.%20There%20are%20several%20ways%20to%20force%20the%20correct%20gpu%20to%20cpu%20mapping.%20In%20SLURM%20we%20can%20map%20GPU%20ids%200%2C1%20to%20NUMA%201%2C%3C%2FP%3E%0A%3CP%3EGPU%20ids%202%2C3%20to%20NUMA%200%2C%20GPU%20ids%204%2C5%20to%20NUMA%203%20and%20GPU%20ids%206%2C7%20to%20NUMA%202%20with%20the%20following%20explicit%20mapping%20using%20the%20SLURM%20srun%20command%20to%20launch%20processes.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3Esrun%20--cpu-bind%3Dmask_cpu%3Affffff000000%2Cffffff000000%2Cffffff%2Cffffff%2Cffffff000000000000000000%2Cffffff000000000000000000%2Cffffff000000000000%2Cffffff00000000000%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20similar%20gpu%20to%20cpu%20mapping%20is%20possible%20with%20HPCX%20MPI%2C%20setting%20the%20following%20environmental%20variable%20and%20mpirun%20arguments%3C%2FP%3E%0A%3CPRE%3Eexport%26nbsp%3B%20CUDA_VISIBLE_DEVICES%3D2%2C3%2C0%2C1%2C6%2C7%2C4%2C5%0A--map-by%20ppr%3A2%3Anuma%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20(Add%20%3Ape%3DN%2C%20if%20running%20hybrid%20parallel%20(threads%20in%20addition%20to%20processes)%0A%3C%2FPRE%3E%0A%3CP%3EThen%20you%20can%20use%20the%20AzureHPC%20check_app_pinning.py%20tool%20as%20your%20job%20runs%20to%20verify%20if%20processes%2Fthreads%20are%20pinned%20optimally.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-83431188%22%20id%3D%22toc-hId-83484941%22%3EI%2FO%20tuning%3C%2FH3%3E%0A%3CP%3ETwo%20aspects%20of%20I%2FO%20need%20to%20be%20addressed.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EScratch%20Storage%3COL%3E%0A%3CLI%3EThis%20type%20of%20storage%20needs%20to%20be%20fast%20(high%20throughput%20and%20low%20latency)%3B%20the%20training%20job%20needs%20to%20read%20data%2C%20process%20the%20data%20and%20use%20this%20storage%20location%20as%20scratch%20space%20as%20the%20job%20runs.%3C%2FLI%3E%0A%3CLI%3EIn%20an%20ideal%20case%20you%20would%20use%20the%20local%20SSD%20on%20each%20VM%20directly.%20The%20NDv4%20has%20a%20local%20SSD%20already%20mounted%20at%20%2Fmnt%20(2.8%20TB)%2C%20it%20also%20has%208%20NVMe%20SSD%20devices%2C%20which%20when%20configured%20and%20mounted%20(see%20below)%2C%20have%20~7%20TB%20capacity.%3C%2FLI%3E%0A%3CLI%3EIf%20you%20need%20a%20shared%20filesystem%20for%20scratch%2C%20combining%20all%20NVMe%20SSD%E2%80%99s%20and%20creating%20a%20PFS%20system%20may%20be%20great%20option%20from%20a%20cost%20and%20performance%20perspective%20assuming%20it%20has%20sufficient%20capacity%20one%20way%20to%20do%20this%20is%20with%20%3CA%20href%3D%22https%3A%2F%2Fdoc.beegfs.io%2Flatest%2Fadvanced_topics%2Fbeeond.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EBeeOND%3C%2FA%3E%2C%20if%20not%20there%20are%20other%20storage%20options%20to%20explore%20(%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-global%2Flustre-on-azure%2Fba-p%2F1052536%22%20target%3D%22_self%22%3EIaaS%20Lustre%20PFS%2C%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fblog%2Fsupercomputing-in-the-cloud-announcing-three-new-cray-in-azure-offers%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20ClusterStor%3C%2FA%3E%26nbsp%3Band%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fservices%2Fnetapp%2F%23overview%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Netapp%20files%3C%2FA%3E).%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3CLI%3ECheckpoint%20Storage%3COL%3E%0A%3CLI%3ELarge%20DL%20training%20jobs%20can%20run%20for%20Weeks%20depending%20on%20how%20many%20VM%E2%80%99s%20are%20used%2C%20just%20like%20any%20HPC%20cluster%20you%20can%20have%20failures%20(e.g.%20InfiniBand%2C%20memory%20DIM%2C%20ECC%20error%20GPU%20memory%20etc).%20It%E2%80%99s%20critical%20to%20have%20a%20checkpointing%20strategy%2C%20know%20the%20checkpoint%20interval%20(e.g.%20when%20data%20is%20checkpointed)%2C%20each%20time%20how%20much%20data%20is%20transferred%20and%20have%20a%20storage%20solution%20in%20place%20that%20can%20satisfy%20that%20capacity%20and%20performance%20requirements.%20If%20Blob%20Storage%20can%20meet%20the%20storage%20performance%2C%20it%E2%80%99s%20a%20great%20option.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH4%20id%3D%22toc-hId--1594940556%22%20id%3D%22toc-hId--1594886803%22%3E%26nbsp%3B%3C%2FH4%3E%0A%3CH4%20id%3D%22toc-hId-892572277%22%20id%3D%22toc-hId-892626030%22%3EHow%20to%20set-up%20and%20configure%20the%20NDv4%20local%20NVMe%20SSD%E2%80%99s%3C%2FH4%3E%0A%3CP%3END96asr_v4%20virtual%20machine%20contains%208%20NVMe%20SSD%20devices.%20You%20can%20combine%20the%208%20devices%20into%20a%20striped%20raid%200%20device%2C%20that%20can%20then%20be%20used%20to%20create%20an%20XFS%20(or%20ext4)%20filesystem%20and%20mounted.%20The%20script%20below%20can%20be%20run%20on%20all%20NDv4%20VM%E2%80%99s%20with%20a%20parallel%20shell%20(e.g%20pdsh)%20to%20create%20a%20~7TB%20local%20scratch%20space%20(%2Fmnt_nvme).%3C%2FP%3E%0A%3CP%3EThe%20resulting%20local%20scratch%20space%20has%20a%20read%20and%20write%20I%2FO%20throughput%20of%20~8%20GB%2Fs.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%23!%2Fbin%2Fbash%20%0Amkdir%20%2Fmnt%2Fresource_nvme%0Amdadm%20--create%20%2Fdev%2Fmd128%20--level%200%20--raid-devices%208%20%2Fdev%2Fnvme0n1%20%2Fdev%2Fnvme1n1%20%2Fdev%2Fnvme2n1%20%2Fdev%2Fnvme3n1%20%2Fdev%2Fnvme4n1%20%2Fdev%2Fnvme5n1%20%2Fdev%2Fnvme6n1%20%2Fdev%2Fnvme7n1%0Amkfs.xfs%20%2Fdev%2Fmd128%0Amount%20%2Fdev%2Fmd128%20%2Fmnt%2Fresource_nvme%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22CormacGarvey_0-1630103159493.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F306388i25A62CF8771C87AD%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22CormacGarvey_0-1630103159493.png%22%20alt%3D%22CormacGarvey_0-1630103159493.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22CormacGarvey_1-1630103193234.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F306389iE148BC921367964F%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22CormacGarvey_1-1630103193234.png%22%20alt%3D%22CormacGarvey_1-1630103193234.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--914882186%22%20id%3D%22toc-hId--914828433%22%3ERestricting%20data%20transfer%20to%20BLOB%20storage%20using%20the%20azcopy%20tool%3C%2FH4%3E%0A%3CP%3EThe%20process%20described%20here%20is%20specific%20to%20azcopy%2C%20but%20the%20same%20principals%20can%20be%20applied%20to%20any%20of%20the%20language%20specific%20SDK%20(e.g%20BLOB%20API%20via%20python).%3C%2FP%3E%0A%3CP%3EIn%20this%20example%2C%20lets%20assume%20that%20we%20have%20as%20single%20BLOB%20storage%20account%20with%20an%20ingress%20limit%20of%2020%20Gbps.%20At%20each%20checkpoint%2C%208%20files%20(corresponding%20to%20each%20GPU)%20need%20to%20be%20copied%20to%20the%20BLOB%20storage%20account%2C%20each%20file%20will%20be%20transferred%20with%20its%20own%20azcopy.%20We%20choose%20that%20each%20azcopy%20can%20transfer%20data%20at%20a%20maximum%20transfer%20speed%20of%202300%20Mbps%20(2300%20x%208%20%3D%2018400%20%26lt%3B%2020000%20Gpbs)%20to%20avoid%20throttling.%20The%20ND96asr_v4%20has%2096%20vcores%20and%20so%20we%20choose%20that%20each%20azcopy%20can%20use%2010%20cores%2C%20so%20each%20instance%20of%20azcopy%20gets%20enough%20cores%20and%20other%20processes%20have%20some%20additional%20vcores.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3Eexport%20AZCOPY_CONCURRENCY_VALUE%3D10%0Aazcopy%20cp%20.%2Ffile%20%E2%80%9Cblob_storage_acc_container%E2%80%9D%20%E2%80%93caps-mbps%202300%0A%3C%2FPRE%3E%0A%3CH3%20id%3D%22toc-hId-1443547928%22%20id%3D%22toc-hId-1443601681%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-334255406%22%20id%3D%22toc-hId-334309159%22%3EDeepSpeed%20and%20Onnx%20Runtime%20(ORT)%3C%2FH3%3E%0A%3CP%3EThe%20performance%20of%20large%20scale%20%26nbsp%3BDL%20training%20models%20built%20with%20the%20pytorch%20framework%20can%20be%20significantly%20improved%20by%20utilizing%20%3CA%20href%3D%22https%3A%2F%2Fwww.deepspeed.ai%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EDeepSpeed%3C%2FA%3E%20and%2For%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fblog%2Fonnx-runtime-is-now-open-source%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EOnnx%20runtime%3C%2FA%3E.%20It%20can%20be%20straight%20forward%20to%20enable%20DeepSpeed%20and%20Onnx%20runtime%20by%20importing%20a%20few%20extra%20modules%20and%20replacing%20a%20few%20lines%20of%20code%20with%20some%20wrapper%20functions.%20If%20using%20DeepSpeed%20and%20Onnx%20its%20best%20practice%20to%20apply%20Onnx%20first%20and%20then%20DeepSpeed.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1602281776%22%20id%3D%22toc-hId--1602228023%22%3EHPC%2BAI%20NDv4%20cluster%20health%20checks%3C%2FH2%3E%0A%3CP%3EWithin%20Azure%20there%20is%20automated%20testing%20to%20help%20identify%20unhealthy%20VM%E2%80%99s.%20Our%20testing%20processes%20and%20procedures%20continue%20to%20improve%2C%20but%20still%20it%20is%20possible%20for%20an%20unhealthy%20VM%20to%20be%20not%20identified%20by%20our%20testing%20and%20to%20be%20deployed.%20Large%20DL%20training%20jobs%20typically%20require%20many%20VM%E2%80%99s%20collaborating%20and%20communicating%20with%20each%20other%20to%20complete%20the%20DL%20job.%20The%20more%20VM%E2%80%99s%20deployed%20the%20greater%20the%20change%20that%20one%20of%20them%20may%20be%20unhealthy%2C%20resulting%20in%20the%20DL%20job%20failing%20or%20underperforming.%20It%20is%20recommended%20that%20before%20starting%20a%20large%20scale%20DL%20training%20job%20to%20run%20some%20health%20checks%20on%20your%20cluster%20to%20verify%20it%E2%80%99s%20performing%20as%20expected.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1014313776%22%20id%3D%22toc-hId-1014367529%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId--793140687%22%20id%3D%22toc-hId--793086934%22%3ECheck%20GPU%26nbsp%3Bfloating-point%20performance%3C%2FH3%3E%0A%3CP%3ERun%20%3CA%20href%3D%22http%3A%2F%2Fwww.netlib.org%2Fbenchmark%2Fhpl%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehigh%20performance%20linpack%20(HPL)%3C%2FA%3E%20on%20each%20VM%2C%20its%20convenience%20to%20use%20the%20version%20contained%20in%20the%20Nvidia%20hpc-benchmarks%20container.%20(Note%3A%20This%20is%20a%20non-optimized%20version%20of%20HPL%20so%20the%20numbers%20reported%20are%20~5-7%25%20slower%20than%20the%20optimized%20container.%20It%20will%20give%20you%20good%20node%20to%20node%20variation%20numbers%20and%20identify%20a%20system%20that%20is%20having%20CPU%2C%20memory%2C%20or%20GPU%20issues).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%23!%2Fbin%2Fbash%0A%23SBATCH%20-t%2000%3A20%3A00%0A%23SBATCH%20--ntasks-per-node%3D8%0A%23SBATCH%20-o%20logs%2F%25x_%25j.log%0A%0ACONT%3D'nvcr.io%23nvidia%2Fhpc-benchmarks%3A20.10-hpl'%0AMOUNT%3D'%2Fnfs2%2Fhpl%2Fdats%2Fhpl-%24%7BSLURM_JOB_NUM_NODES%7DN.dat%3A%2Fworkspace%2Fhpl-linux-x86_64%2Fsample-dat%2FHPL-dgx-a100-%24%7BSLURM_JOB_NUM_NODES%7DN.dat'%0Aecho%20%22Running%20on%20hosts%3A%20%24(echo%20%24(scontrol%20show%20hostname))%22%0A%0Aexport%20NCCL_DEBUG%3DINFO%0Aexport%20OMPI_MCA_pml%3Ducx%0Aexport%20OMPI_MCA_btl%3D%5Eopenib%2Csmcuda%0A%0ACMD%3D%22hpl.sh%20--cpu-affinity%2024-35%3A36-47%3A0-11%3A12-23%3A72-83%3A84-95%3A48-59%3A60-71%20--cpu-cores-per-rank%208%20--gpu-affinity%200%3A1%3A2%3A3%3A4%3A5%3A6%3A7%20--mem-affinity%201%3A1%3A0%3A0%3A3%3A3%3A2%3A2%20%20--ucx-affinity%20ibP257p0s0%3AibP258p0s0%3AibP259p0s0%3AibP260p0s0%3AibP261p0s0%3AibP262p0s0%3AibP263p0s0%3AibP264p0s0%20--dat%20%2Fworkspace%2Fhpl-linux-x86_64%2Fsample-dat%2FHPL-dgx-a100-%24%7BSLURM_JOB_NUM_NODES%7DN.dat%22%0Asrun%20--gpus-per-node%3D8%20--container-image%3D%22%24%7BCONT%7D%22%20--container-mounts%3D%22%24%7BMOUNT%7D%22%20%24%7BCMD%7D%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20should%20see%20~95%20TFLOPs%20DP%20on%20ND96asr_v4%20(which%20has%208%20A100%20GPU%E2%80%99s)%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1694372146%22%20id%3D%22toc-hId-1694425899%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId--113082317%22%20id%3D%22toc-hId--113028564%22%3ECheck%20host%20to%20device%20and%20device%20to%20host%20transfer%20bandwidth%3C%2FH3%3E%0A%3CP%3EThe%20CUDA%20%3CA%20href%3D%22https%3A%2F%2Fdocs.nvidia.com%2Fcuda%2Fdemo-suite%2Findex.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EbandwidthTest%3C%2FA%3E%20is%20a%20convenience%20way%20to%20verify%20that%20the%20host%20to%20gpu%20and%20gpu%20to%20host%20%26nbsp%3Bdata%20bandwidth%20speeds%20are%20good.%20Below%20is%20an%20example%20testing%20gpu%20id%20%3D%200%2C%20you%20would%20run%20a%20similar%20test%20for%20the%20other%207%20gpu_ids%2C%20paying%20close%20attention%20to%20what%20NUMA%20domains%20they%20are%20contained%20in.%3C%2FP%3E%0A%3CPRE%3Enumactl%20--cpunodebind%3D1%20--membind%3D1%20.%2FbandwidthTest%20--dtoh%20--htod%20--device%3D0%0A%0A%5BCUDA%20Bandwidth%20Test%5D%20-%20Starting...%0ARunning%20on...%0A%0A%20Device%200%3A%20A100-SXM4-40GB%0A%20Quick%20Mode%0A%0A%20Host%20to%20Device%20Bandwidth%2C%201%20Device(s)%0A%20PINNED%20Memory%20Transfers%0A%20%20%20Transfer%20Size%20(Bytes)%20%20%20%20%20%20%20%20Bandwidth(GB%2Fs)%0A%20%20%2032000000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2026.1%0A%0A%20Device%20to%20Host%20Bandwidth%2C%201%20Device(s)%0A%20PINNED%20Memory%20Transfers%0A%20%20%20Transfer%20Size%20(Bytes)%20%20%20%20%20%20%20%20Bandwidth(GB%2Fs)%0A%20%20%2032000000%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2025.0%0A%0AResult%20%3D%20PASS%0A%3C%2FPRE%3E%0A%3CP%3EThe%20expected%20host%20to%20device%20and%20device%20to%20host%20transfer%20speed%20is%20%26gt%3B%2020%20GB%2Fs.%3C%2FP%3E%0A%3CP%3EThis%20health%20check%20and%20many%20more%20detailed%20tests%20to%20diagnose%20unhealthy%20VMs%20can%20be%20found%20in%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazhpc-diagnostics%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Eazhpc-diagnostics%3C%2FA%3E%20Github%20repository.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1920536780%22%20id%3D%22toc-hId--1920483027%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-566976053%22%20id%3D%22toc-hId-567029806%22%3ECheck%20the%20InfiniBand%20network%26nbsp%3Band%20NCCL%20performance%3C%2FH3%3E%0A%3CP%3ERunning%20a%20NCCL%20allreduce%20and%2For%20alltoall%20benchmark%20at%20the%20scale%20you%20plan%20on%20running%20your%20deep%20learning%20training%20job%20is%20a%20great%20way%20to%20identify%20problems%20with%20the%20InfiniBand%20inter-node%20network%20or%20with%20NCCL%20performance.%3C%2FP%3E%0A%3CP%3EHere%20is%20a%20SLURM%20script%20to%20run%20a%20NCCL%20alltoall%20benchmark%20(Note%3A%20using%20SLURM%20container%20integration%20with%20enroot%2Bpyxis%20to%20use%20the%20Nvidia%20pytorch%20container.)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%23!%2Fbin%2Fbash%0A%23SBATCH%20-t%2000%3A20%3A00%0A%23SBATCH%20--ntasks-per-node%3D8%0A%23SBATCH%20--gpus-per-node%3D8%0A%23SBATCH%20-o%20logs%2F%25x_%25j.log%0Aexport%20UCX_IB_PCI_RELAXED_ORDERING%3Don%20%5C%0A%20%20%20%20%20%20%20UCX_TLS%3Drc%20%5C%0A%20%20%20%20%20%20%20NCCL_DEBUG%3DINFO%20%5C%0A%20%20%20%20%20%20%20CUDA_DEVICE_ORDER%3DPCI_BUS_ID%20%5C%0A%20%20%20%20%20%20%20NCCL_IB_PCI_RELAXED_ORDERING%3D1%20%5C%0A%20%20%20%20%20%20%20NCCL_TOPO_FILE%3D%2Fworkspace%2Fnccl%2Fnccl-topology.txt%0A%0ACONT%3D%22nvcr.io%23nvidia%2Fpytorch%3A21.05-py3%22%0AMOUNT%3D%22%2Fnfs2%2Fnccl%3A%2Fworkspace%2Fnccl_284%2C%2Fnfs2%2Fhpcx-v2.8.1-gcc-MLNX_OFED_LINUX-5.1-0.6.6.0-ubuntu18.04-x86_64%3A%2Fopt%2Fhpcx%2C%2Fnfs2%2Fnccl_2.10.3-1%2Fnccl%3A%2Fworkspace%2Fnccl%22%0A%0Aexport%20OMPI_MCA_pml%3Ducx%0Aexport%20OMPI_MCA_btl%3D%5Eopenib%0Aexport%20OMPI_MCA_COLL_HCOLL_ENABLE%3D0%0A%0Asrun%20--ntasks%3D%24SLURM_JOB_NUM_NODES%20--container-image%20%22%24%7BCONT%7D%22%20%5C%0A%20%20%20%20--container-name%3Dnccl%20%5C%0A%20%20%20%20--container-mounts%3D%22%24%7BMOUNT%7D%22%20%5C%0A%20%20%20%20--ntasks-per-node%3D1%20%5C%0A%20%20%20%20bash%20-c%20%22apt%20update%20%26amp%3B%26amp%3B%20apt-get%20install%20-y%20infiniband-diags%22%0A%0Asrun%20--gpus-per-node%3D8%20%5C%0A%20%20%20%20--ntasks-per-node%3D8%20%5C%0A%20%20%20%20--container-name%3Dnccl%20%5C%0A%20%20%20%20--container-mounts%20%22%24%7BMOUNT%7D%22%20%5C%0A%20%20%20%20bash%20-c%20'export%20LD_LIBRARY_PATH%3D%2Fopt%2Fhpcx%2Fnccl_rdma_sharp_plugin%2Flib%3A%2Fopt%2Fhpcx%2Fsharp%2Flib%3A%2Fworkspace%2Fnccl%2Fbuild%2Flib%3A%24LD_LIBRARY_PATH%20%26amp%3B%26amp%3B%20%2Fworkspace%2Fnccl%2Fnccl-tests%2Fbuild%2Falltoall_perf%20-b8%20-f%202%20-g%201%20-e%208G'%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%20submit%20the%20above%20script%20on%20for%20example%204%20ND96asr_v4%20VM%E2%80%99s%3C%2FP%3E%0A%3CPRE%3Esbatch%20-N%204%20.%2Fnccl.slrm%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3BSimilarly%2C%20for%20allreduce%2C%20just%20change%20the%20executable%20to%20be%20all_reduce_perf.%3C%2FP%3E%0A%3CP%3EThe%20following%20plots%20show%20NCCL%20allreduce%20and%20alltoall%20expect%20performance%20on%20ND96asr_v4.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22CormacGarvey_0-1630106993288.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F306394i37AF824DA89D9878%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22CormacGarvey_0-1630106993288.png%22%20alt%3D%22CormacGarvey_0-1630106993288.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22CormacGarvey_1-1630107011467.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F306395iBD90BD4252D96C0A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22CormacGarvey_1-1630107011467.png%22%20alt%3D%22CormacGarvey_1-1630107011467.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1369561129%22%20id%3D%22toc-hId--1369507376%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-1117951704%22%20id%3D%22toc-hId-1118005457%22%3ESummary%3C%2FH2%3E%0A%3CP%3ELarge%20scale%20DL%20models%20are%20becoming%20very%20complex%20and%20sophisticated%20being%20applied%20to%20many%20application%20areas.%20The%20computational%20and%20network%20resources%20to%20train%20these%20large%20modern%20DL%20models%20can%20be%20quite%20substantial.%20The%20Azure%20NDv4%20series%20is%20designed%20specifically%20for%20these%20large%20scale%20DL%20computational%2C%20network%20and%20I%2FO%20requirements.%3C%2FP%3E%0A%3CP%3ESeveral%20key%20performance%20optimization%20tips%20and%20tricks%20are%20discussed%20to%20allow%20you%20to%20get%20the%20best%20possible%20performance%20running%20your%20large%20deep%20learning%20model%20on%20Azure%20NDv4%20series.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-8659182%22%20id%3D%22toc-hId-8712935%22%3ECredits%3C%2FH2%3E%0A%3CP%3ETo%20would%20like%20to%20acknowledge%20the%20significant%20contribution%20of%20my%20Colleagues%20at%20Microsoft%20to%20this%20post.%20Jithin%20Jose%20provided%20the%20NCCL%20scaling%20performance%20data%20and%20was%20the%20primary%20contributor%20to%20the%20NCCL%2C%20MPI%20an%20GPU%20tuning%20parameters%2C%20he%20also%20helped%20review%20this%20document.%20I%20would%20also%20like%20to%20thank%20Kanchan%20Mehrotra%20and%20Jon%20Shelley%20for%20reviewing%20this%20document%20and%20providing%20outstanding%20feedback.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2693834%22%20slang%3D%22en-US%22%3E%3CP%3EModern%20DL%20training%20jobs%20require%20large%20Clusters%20of%20multi-GPUs%20with%20high%20floating-point%20performance%20connected%20with%20high%20bandwidth%2C%20low%20latency%20networks.%20The%20Azure%20NDv4%20VM%20series%20is%20designed%20specifically%20for%20these%20types%20of%20workloads.%3C%2FP%3E%0A%3CP%3EWe%20will%20be%20focusing%20on%20HPC%2BAI%20Clusters%20built%20with%20the%20ND96asr_v4%20virtual%20machine%20type%20and%20providing%20specific%20optimization%20recommendations%20to%20get%20the%20best%20performance.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2693834%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Eai%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeep%20learning%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EHPC%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ENDv4%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPerformance%20optimization%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Sep 14 2021 02:20 PM
Updated by: