NCCL Build
بناء NCCL وأمثلته واختباراته.
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.
Install
npx skills add NVIDIA/skills --skill nccl-buildWorks with
claude-code (native), claude (native), codex (native), chatgpt (native), gemini-cli (native), cursor (native), copilot (native), opencode (native), amp (native), roo (native), kiro (native), goose (native), junie (native), trae (native), cline (compatible), continue (compatible), antigravity (compatible), windsurf (compatible), augment (compatible), qwen-code (compatible)
Content
NCCL Build
Purpose
Get NCCL, its examples, and optionally 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 clonehttps://github.com/NVIDIA/nccl.git. - Write access to the selected build directory and enough free disk space.
- Optional: NVIDIA driver and
nvidia-smifor 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 containsmakefiles/version.mk.CUDA_HOME: user-supplied CUDA Toolkit root, otherwise derive it fromnvcconPATH.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:
- Show the exact command and affected paths.
- Explain its purpose and expected changes.
- Ask the user to approve, modify, or cancel it.
- 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
- 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
nvccfrom<CUDA_HOME>/bin/nvccwhenCUDA_HOMEis given, otherwise fromPATH; runnvcc --versionandnvcc --list-gpu-code command -v make g++ python3- once the checkout and
BUILDDIRare resolved, verify that the build directory's parent is writable and inspect available disk space - if
nvidia-smiis available, runnvidia-smi --query-gpu=index,name,compute_cap --format=csv,noheaderReport missing requirements instead of installing them. An unavailable, failing, empty, or unparseablenvidia-smiresult 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 innvcc --list-gpu-code.
- Work in an NCCL checkout (
makefiles/version.mkpresent), or show:git clone https://github.com/NVIDIA/nccl.git, identify the destination, and wait for explicit approval before cloning. - Show the resolved build command:
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.
- Verify
<dir>/include/nccl.hand<dir>/lib/libnccl.so*; this directory isNCCL_HOME. For static-only builds, seereferences/build_options.md. For runtime:export LD_LIBRARY_PATH="<NCCL_HOME>/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}". - 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:
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-codebefore 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.hand at least one<dir>/lib/libnccl.so*. After a static-only build, require<dir>/include/nccl.hand<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
nvccmissing: report that CUDA Toolkit is unavailable and ask for a validCUDA_HOME; do not install CUDA.nvidia-smimissing or no GPU visible: compilation can continue after the user supplies a target architecture; do not guess one.- Unsupported
NVCC_GENCODE: show the codes fromnvcc --list-gpu-codeand ask for a supported target. makefiles/version.mkmissing: 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>/libtoLD_LIBRARY_PATHwithout discarding the existing value. - MPI headers or libraries missing: disable MPI unless required, or follow
references/nccl_tests.mdafter 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:
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.
Source and license
- Source
- NVIDIA Skills
- Original
- NVIDIA/skills/skills/nccl-build/SKILL.md
- License
- Apache-2.0 AND CC-BY-4.0