This page describes how to install
[NCCL/gIB](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/overview.md.txt) with either Debian Software
Packages (`.deb`) or the Red Hat Package Manager (`.rpm`). This installation
lets you run NCCL workloads on A4X Max, A4X, A4, and A3 Ultra instances.

> [!NOTE]
> **Note:** Don't install older NCCL implementations like NCCL/FastSocket (A2), NCCL/TCPX (A3), NCCL/TCPXO (A3 Mega) or RxDM packages or their related environment variables on your A4X Max, A4X, A4, or A3 Ultra instances.

## (For A4X Max) Update userspace libraries

On A4X Max, you must install the latest userspace libraries before running your
NCCL workloads. If you're logged in as a root user, then omit `sudo` where it
occurs to run the commands directly.

### Debian 12+/Ubuntu 20.04+ (.deb package)

```bash
sudo apt update
sudo apt install curl

# Fetch DOCA OFED userspace and SDK libraries
export DOCA_URL="https://linux.mellanox.com/public/repo/doca/latest/ubuntu22.04/arm64-sbsa/"
export BASE_URL="https://linux.mellanox.com/public/repo/doca"
sudo mkdir -m 0755 -p /etc/apt/keyrings
sudo curl -fsSL "${BASE_URL}/public_keys/nvidia-doca-debian-gpg-public-key.gpg" -o /etc/apt/keyrings/nvidia-doca-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/nvidia-doca-keyring.gpg] ${DOCA_URL} ./" | sudo tee /etc/apt/sources.list.d/doca.list

# Prioritize DOCA packages over CUDA repo pins (such as mft)
printf 'Package: *\nPin: origin "linux.mellanox.com"\nPin-Priority: 700\n' | sudo tee /etc/apt/preferences.d/doca-pin-700

sudo apt update
sudo apt install doca-ofed-userspace libdoca-sdk-gpunetio-dev

# Upgrade to latest NCCL for best compatibility
sudo apt install --only-upgrade --allow-change-held-packages libnccl2 libnccl-dev
```

## Install NCCL/gIB

Depending on where you run your workloads, you install NCCL/gIB in either the
compute instance or the container image.

The `nccl-gib` package is bundled with an unmodified NVidia NCCL library
(`libnccl2.so`) and headers. All NCCL/gIB content is installed to the
`/usr/local/gib` directory, and the plugin libraries are also installed into
system folder (under `/usr/lib`). Some dependencies are also fetched through the
distribution's repositories.

### Debian 12+/Ubuntu 20.04+ (.deb package)

```bash
# If on an image not from Google, trust the Google Cloud signing key
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/cloud.google.gpg

# Add gpudirect-gib-apt repo
echo 'deb https://packages.cloud.google.com/apt gpudirect-gib-apt main' | sudo tee /etc/apt/sources.list.d/nccl-gib.list

sudo apt update
sudo apt install nccl-gib
```

### RockyLinux/CentOS/RHEL 9+ (.rpm package)

```bash
# Add gpudirect-gib-rpm repo
sudo tee -a /etc/yum.repos.d/nccl-gib.repo << EOL
[gpudirect-gib-rpm]
name=NCCL/gIB
baseurl=https://packages.cloud.google.com/yum/repos/gpudirect-gib-rpm
enabled=1
repo_gpgcheck=0
gpgcheck=0

sudo dnf makecache
sudo dnf install nccl-gib
```

## Install NCCL plugins

If you want to use your own custom version of NCCL Core instead of the NCCL
library bundled in `nccl-gib`, then install the `nccl-gib-plugins` package. This
package installs only Google's NCCL/gIB plugins and conflicts with `nccl-gib`,
so installing one package automatically removes the other. If you use the NCCL
version bundled with `nccl-gib`, then you don't need to install
`nccl-gib-plugins`.

> [!NOTE]
> **Note:** This section applies to Compute Engine VMs and self-managed clusters, such as Slurm. If you use GKE, then the GKE gIB installer DaemonSet manages plugin installation for you; see [Run NCCL on GKE clusters that use A4 or A3 Ultra](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/test-gke-custom.md.txt). If you use NVIDIA NGC containers from July 2026 or later, then Google's gIB plugins are already pre-installed in the container; see [Use gIB NCCL plugins in NVIDIA NGC containers](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/ngc-containers.md.txt).

To install only the gIB NCCL plugins, install the `nccl-gib-plugins` package:

### Debian 12+/Ubuntu 20.04+ (.deb package)

```bash
# If on an image not from Google, trust the Google Cloud signing key
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/cloud.google.gpg

# Add gpudirect-gib-apt repo
echo 'deb https://packages.cloud.google.com/apt gpudirect-gib-apt main' | sudo tee /etc/apt/sources.list.d/nccl-gib.list

sudo apt update
sudo apt install nccl-gib-plugins
```

### RockyLinux/CentOS/RHEL 9+ (.rpm package)

```bash
# Add gpudirect-gib-rpm repo
sudo tee -a /etc/yum.repos.d/nccl-gib.repo << EOL
[gpudirect-gib-rpm]
name=NCCL/gIB
baseurl=https://packages.cloud.google.com/yum/repos/gpudirect-gib-rpm
enabled=1
repo_gpgcheck=0
gpgcheck=0

sudo dnf makecache
sudo dnf install nccl-gib-plugins
```

> [!NOTE]
> **Note:** When you use `nccl-gib-plugins`, make sure that your separately installed NCCL Core version is in the supported version range. For more information, see the version compatibility tables in the [x86 release notes](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/release-notes-x86.md.txt#version-compatibility) and [ARM64 release notes](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/release-notes-arm64.md.txt#version-compatibility).

If you use standard OS images, then you must also install the latest
[NVIDIA DOCA-OFED driver](https://developer.nvidia.com/doca-downloads?deployment_platform=Host-Server&deployment_package=DOCA-Host&target_os=Linux&Architecture=x86_64&Profile=doca-ofed).
You don't need to install this driver if you use Google's accelerator-optimized
images, such as [Container-Optimized OS](https://docs.cloud.google.com/container-optimized-os/docs.md.txt) or
[accelerator-optimized Ubuntu or Rocky Linux OS images](https://docs.cloud.google.com/ai-hypercomputer/docs/images.md.txt#accelerator-os-images).

To prevent compute instances from running mismatched versions of the NCCL/gIB
package, update NCCL/gIB before you run your workloads and disable automatic
package updates, such as `unattended-upgrades` on Ubuntu or Debian.

## Upgrade NCCL Core on existing installations

If your VMs have an earlier `nccl-gib` package installed and you need a later
NCCL Core version to support CUDA 13 or a specific framework version, then
first check the
[x86 release notes](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/release-notes-x86.md.txt#version-compatibility)
or
[ARM64 release notes](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/release-notes-arm64.md.txt#version-compatibility)
to see if the latest `nccl-gib` package includes the NCCL version that you need.
If the latest `nccl-gib` package meets your requirements, then upgrade
`nccl-gib` directly across all nodes.

If your workload requires a specific NCCL Core version that isn't bundled in
`nccl-gib`, then perform the following steps on every node in your cluster so
that all nodes run the exact same NCCL version:

1. Install or upgrade your target NCCL Core packages from the NVIDIA CUDA
   repository and switch from `nccl-gib` to `nccl-gib-plugins` so that future
   package updates don't reinstall the bundled NCCL library. If your VM uses a
   standard OS image that doesn't include the NVIDIA CUDA repository, then add
   the repository first by following the
   [NVIDIA NCCL installation guide](https://docs.nvidia.com/deeplearning/nccl/install-guide/index.html).

   ### Debian 12+/Ubuntu 20.04+ (.deb package)

   ```bash
   sudo apt update
   sudo apt install -y nccl-gib-plugins libnccl2 libnccl-dev

   # If libnccl2 and libnccl-dev are held at an earlier version:
   sudo apt install --only-upgrade --allow-change-held-packages -y libnccl2 libnccl-dev
   ```

   ### RockyLinux/CentOS/RHEL 9+ (.rpm package)

   ```bash
   sudo dnf install --allowerasing -y nccl-gib-plugins libnccl libnccl-devel

   # If libnccl and libnccl-devel are already installed:
   sudo dnf upgrade -y libnccl libnccl-devel
   ```
2. If your environment still has bundled `libnccl.so*` files in
   `/usr/local/gib/lib64` or `/usr/local/gib/lib` from an earlier `nccl-gib`
   installation or container mount, then remove only those bundled
   `libnccl.so*` files so that they don't take priority over your upgraded NCCL
   Core library:

   ```bash
   sudo rm -f /usr/local/gib/lib*/libnccl.so*
   ```

   > [!CAUTION]
   > **Caution:** Don't remove the gIB plugin files, such as `libnccl-net.so`, `libnccl-tuner.so`, `libnccl-profiler.so`, or `libnccl-env-gcp.so`, from `/usr/local/gib`.

3. Verify your environment configuration and active NCCL version:

   - If `LD_LIBRARY_PATH` in your workload environment includes
     `/usr/local/gib/lib64` or `/usr/local/nvidia/lib64`, then verify that
     those directories don't contain an earlier `libnccl.so.2` file, or
     prepend your system library path, such as `/usr/lib/x86_64-linux-gnu` or
     `/usr/lib64`, to `LD_LIBRARY_PATH`.

   - If your custom NCCL Core version is earlier than 2.28.7, then source
     `/usr/local/gib/scripts/set_nccl_env.sh` before you run your workload,
     because the automatic environment plugin loads only on NCCL 2.28.7 or
     later.

   - [Check the logged NCCL and gIB versions](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/collect-and-understand.md.txt#check_version)
     to confirm that your upgraded NCCL Core library and the `NET/gIB` plugin
     initialize together.

## Enable NCCL/gIB

Starting from NCCL/gIB v1.1.2, if you installed `nccl-gib` or
`nccl-gib-plugins`, NCCL/gIB should be automatically enabled in your workloads.

In previous versions, to enable NCCL/gIB in your workloads, ensure the
following:

- `/usr/local/gib/scripts/set_nccl_env.sh` is sourced in your runtime environment. The source file includes all the necessary environment variables for NCCL/gIB and Google expects to update them in future NCCL/gIB releases.
- The `/usr/local/gib/lib64` directory is in your `LD_LIBRARY_PATH`.

To verify NCCL/gIB is enabled, check that the following NCCL INFO level log
entries are present:

```bash
# A sample log entry from NCCL core
vm-0:606:642 [6] NCCL INFO Using network gIB

# A sample log entry from the gIB network plugin
vm-0:606:642 [6] NCCL INFO NET/gIB : Initializing gIB v1.1.2
```

## What's next

- [Use gIB NCCL plugins in NVIDIA NGC containers](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/ngc-containers.md.txt).
- [Run NCCL on Compute Engine instances](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/test-vms.md.txt).
- [Collect and understand NCCL Logs for troubleshooting](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/collect-and-understand.md.txt).