Use to build NCCL, its repository examples, and optionally nccl-tests on a CUDA Linux host - guide environment detection, GPU architecture selection, Make builds, and safe execution.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Nccl Build?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nvidia-nccl-build)
---
name: nccl-build
description: Use to build NCCL, its repository examples, and optionally nccl-tests on a CUDA Linux host - guide environment detection, GPU architecture selection, Make builds, and safe execution.
license: Apache-2.0
metadata:
version: "0.1.1"
author: Jean-Baptiste BESNARD <jbesnard@nvidia.com>
tags:
- nccl
- build
- nccl-tests
---
# NCCL Build
## Purpose
Get [NCCL](https://github.com/NVIDIA/nccl), its examples, and optionally
[nccl-tests](https://github.com/NVIDIA/nccl-tests), built on Linux with CUDA.
## Prerequisites
- A CUDA-capable Linux build host. A visible GPU is optional for compilation
but required to run GPU examples or nccl-tests.
- CUDA Toolkit with `nvcc`, GNU Make, `g++`, and Python 3.
- An NCCL checkout containing `makefiles/version.mk`, or permission to clone
`https://github.com/NVIDIA/nccl.git`.
- Write access to the selected build directory and enough free disk space.
- Optional: NVIDIA driver and `nvidia-smi` for architecture detection; MPI
compiler and runtime when an example or nccl-tests build uses MPI.
Do not install missing prerequisites. Report them and let the user decide how
to provide them.
## Inputs
Resolve these inputs from the user's request and environment before proposing a
build:
### Required inputs
These values must be resolved, although they may be discovered rather than
provided explicitly:
- `checkout`: NCCL source directory; default to the current directory only when
it contains `makefiles/version.mk`.
- `CUDA_HOME`: user-supplied CUDA Toolkit root, otherwise derive it from
`nvcc` on `PATH`.
- `BUILDDIR`: output directory; use the repository default only when the user
has not requested another location.
- `N`: parallel Make job count; ask or choose a conservative host-appropriate
value and identify it as agent-derived.
- `NVCC_GENCODE`: target GPU architecture flags. Derive these from visible
GPUs, or ask when no GPU is visible or multiple architectures require a
choice.
- `action`: build NCCL, install it, build a repository example, or build/run
nccl-tests.
### Optional inputs
- Build flags for non-default configurations.
- Install prefix when installation is requested.
- Repository example selection.
- MPI enablement and MPI installation settings.
Never guess a CUDA path, unsupported GPU architecture, install prefix, or MPI
configuration.
## Human Approval Boundary
Do not execute any command that changes files, downloads source, compiles code,
installs artifacts, runs GPU workloads, or otherwise alters system state
without explicit user confirmation.
Before each such operation:
1. Show the exact command and affected paths.
2. Explain its purpose and expected changes.
3. Ask the user to approve, modify, or cancel it.
4. Wait for explicit approval immediately before execution.
Approval applies only to the displayed command. Obtain new approval if the
command changes. Never run cleanup, deletion, overwrite, package installation,
`sudo`, or system-wide installation commands without separate explicit
approval. Read-only environment and prerequisite checks may run without
confirmation.
## Instructions
1. Run these read-only prerequisite checks directly, combined in one shell
command; they are safe and need no consent. Do not follow up by searching
the filesystem for other CUDA installations or checkouts; report what is
missing and ask instead:
- `uname -sm`
- locate `nvcc` from `<CUDA_HOME>/bin/nvcc` when `CUDA_HOME` is given,
otherwise from `PATH`; run `nvcc --version` and `nvcc --list-gpu-code`
- `command -v make g++ python3`
- once the checkout and `BUILDDIR` are resolved, verify that the build
directory's parent is writable and inspect available disk space
- if `nvidia-smi` is available, run
`nvidia-smi --query-gpu=index,name,compute_cap --format=csv,noheader`
Report missing requirements instead of installing them. An unavailable,
failing, empty, or unparseable `nvidia-smi` result means no GPU
architecture was detected, not that compilation is impossible: ask for the
target arch. With several visible archs, ask whether
to build all or one. Confirm every target appears in
`nvcc --list-gpu-code`.
2. Work in an NCCL checkout (`makefiles/version.mk` present), or show:
`git clone https://github.com/NVIDIA/nccl.git`, identify the destination,
and wait for explicit approval before cloning.
3. Show the resolved build command:
```bash
env -u LD_PRELOAD -u LD_AUDIT -u LD_LIBRARY_PATH \
make -j<N> src.build CUDA_HOME=<cuda> BUILDDIR=<dir> NVCC_GENCODE="<targets>"
```
Before running a build, clone, install, or test command, give its one-line
goal and a `Parameter | Value | Meaning | Source` table, then ask: run as
shown, change, or cancel. On change, keep the other resolved values, apply
the requested edits, revalidate affected inputs, and present the revised
command for fresh approval. Read-only checks need no prompt. Never use
`sudo` or `/usr/local` unless requested.
When the user only asks to see the command, present it fully resolved from
the values they supplied even if prerequisites are missing; for example,
`sm_90` becomes `NVCC_GENCODE="-gencode=arch=compute_90,code=sm_90"`. Mark
values not yet validated in the `Source` column, list the missing
prerequisites, and do not run the command.
4. Verify `<dir>/include/nccl.h` and `<dir>/lib/libnccl.so*`; this directory
is `NCCL_HOME`. For static-only builds, see
`references/build_options.md`. For runtime:
`export LD_LIBRARY_PATH="<NCCL_HOME>/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"`.
5. Install only if asked. Reuse the verified build's `BUILDDIR`, `CUDA_HOME`,
`NVCC_GENCODE`, and every other build-affecting Make variable; if no build
directory was selected in this context, ask for it rather than defaulting
to `./build`. Present and obtain consent for:
```bash
env -u LD_PRELOAD -u LD_AUDIT -u LD_LIBRARY_PATH \
make src.install CUDA_HOME=<cuda> BUILDDIR=<build-dir> \
NVCC_GENCODE="<targets>" PREFIX=<install-prefix> [same-build-flags]
```
After installation, verify `<install-prefix>/include/nccl.h` and
`<install-prefix>/lib/libnccl.so*`.
For repository examples read `references/examples.md`; for CMake or
advanced flags read `references/build_options.md`; for nccl-tests read
`references/nccl_tests.md`.
## Validation and Error Handling
- Validate all requested targets against `nvcc --list-gpu-code` before Make.
Reject unsupported targets and do not start the build.
- Treat any nonzero clone, configure, build, install, or test exit status as a
failure. Preserve the relevant command and concise error output; never claim
success from partial artifacts.
- After a successful `src.build`, require both `<dir>/include/nccl.h` and at
least one `<dir>/lib/libnccl.so*`. After a static-only build, require
`<dir>/include/nccl.h` and `<dir>/lib/libnccl_static.a`.
- After an example or nccl-tests build, verify the requested executable exists
before offering to run it.
- If a command fails, diagnose the first actionable error, keep the source and
existing artifacts intact, and propose the smallest retry. Ask for consent
again before a changed build, install, or test command.
- If required input remains unresolved, stop before mutation and ask one
focused question.
## Troubleshooting
- `nvcc` missing: report that CUDA Toolkit is unavailable and ask for a valid
`CUDA_HOME`; do not install CUDA.
- `nvidia-smi` missing or no GPU visible: compilation can continue after the
user supplies a target architecture; do not guess one.
- Unsupported `NVCC_GENCODE`: show the codes from `nvcc --list-gpu-code` and
ask for a supported target.
- `makefiles/version.mk` missing: the directory is not an NCCL checkout. Offer
the official clone command and wait for consent.
- Compiler or linker failure: report the first relevant error and the resolved
CUDA, compiler, target, and build-directory values.
- Runtime loader cannot find NCCL: prepend `<NCCL_HOME>/lib` to
`LD_LIBRARY_PATH` without discarding the existing value.
- MPI headers or libraries missing: disable MPI unless required, or follow
`references/nccl_tests.md` after the user supplies the MPI installation.
## Limitations
- This skill supports CUDA Linux hosts only; it does not build NCCL on macOS or
Windows.
- A no-GPU host can compile but cannot validate runtime collective behavior.
- Cross-compilation, package creation, container-image construction, and
cluster provisioning are outside the default workflow.
- Successful local compilation does not prove multi-node networking, RDMA, or
performance correctness.
- Repository examples and nccl-tests have separate dependencies and consent
boundaries; building NCCL does not authorize building or running them.
## Examples
### Standard local build
For “Build NCCL with the visible GPUs,” run the prerequisite checks, derive and
validate the GPU targets, resolve all parameters, then present:
```bash
env -u LD_PRELOAD -u LD_AUDIT -u LD_LIBRARY_PATH \
make -j<N> src.build CUDA_HOME=<cuda> BUILDDIR=<dir> \
NVCC_GENCODE="<validated-targets>"
```
Show the goal and `Parameter | Value | Meaning | Source` table, then wait for
the user to run as shown, change, or cancel.
### Build when no GPU is visible
For “Build NCCL in this CUDA container; no GPU is visible,” explain that
compilation is still possible, ask for the target architecture, validate it
with `nvcc --list-gpu-code`, and only then present the resolved build command.
Report `built, not run` after successful artifact validation.
### Missing CUDA compiler
For “Prepare an NCCL build, but nvcc is unavailable,” report `nvcc` as a
missing prerequisite, ask whether the user has a CUDA Toolkit path to use, and
stop without installing packages, invoking Make, or claiming success.
## Guardrails
Tests come only from NVIDIA/nccl-tests, checked out outside the NCCL tree.
Environment checks are read-only. Never install packages or use `sudo` to
repair a missing dependency unless the user explicitly asks.