Skip to content
Free tool · runs in your browser

NCCL environment generator

Hours disappear into environment variables. A missingFI_PROVIDER=efaand every collective silently crawls over TCP. A missingCUDA_DEVICE_MAX_CONNECTIONS=1and Megatron's tensor-parallel overlap just doesn't happen — with no error anywhere. Pick your cloud and framework, get the right set with the reason for each one.

Every variable explained Conflict checker for the env you have

Your setup

1 value depend on your hardware and must be verified, not pasted: NCCL_SOCKET_IFNAME. Check NCCL_SOCKET_IFNAME against `ip -br addr`, NCCL_IB_HCA against `ibstat`, and NCCL_IB_GID_INDEX against `show_gids`.

#!/usr/bin/env bash
# Denpex — NCCL/PyTorch environment for AWS (p4d / p5, EFA) + PyTorch FSDP
# Every value is explained at denpex.com/nccl-env. Values marked VERIFY depend on
# your hardware — check them before trusting them.

# ── REQUIRED ────────────────────────────────────────────────────
# Makes EFA safe across fork(). PyTorch DataLoader workers fork, so without this you get intermittent, un-debuggable corruption or hangs that correlate with num_workers.
export FI_EFA_FORK_SAFE=1

# Enables device RDMA so the NIC reads GPU memory directly. Required on p4d; already the default on p5 and later, where setting it is harmless.
export FI_EFA_USE_DEVICE_RDMA=1

# Selects the EFA libfabric provider. Without it libfabric picks tcp or sockets and every byte crosses the kernel network stack instead of the fabric — often a 10x collective slowdown that looks like a model problem.
export FI_PROVIDER=efa

# EFA and its OpenMPI live outside the default loader path. Missing this is why FI_PROVIDER=efa "does nothing".
export LD_LIBRARY_PATH="/opt/amazon/efa/lib:/opt/amazon/openmpi/lib:$LD_LIBRARY_PATH"

# The bootstrap interface prefix (NOT the data path — that is EFA). AWS instances name interfaces ens5/ens32; the danger is NCCL picking docker0 or a virtual bridge and failing rendezvous.
# VERIFY: this value depends on your hardware.
export NCCL_SOCKET_IFNAME=ens

# Makes a failed collective raise instead of hanging forever. Without it a dead rank turns into a job that burns GPU-hours doing nothing until the wall clock kills it.
export TORCH_NCCL_ASYNC_ERROR_HANDLING=1

# ── RECOMMENDED ─────────────────────────────────────────────────
# Loads the checkpoint on rank 0 and broadcasts, instead of every rank materializing the full model in host RAM. On a 70B model this is the difference between loading and being OOM-killed at startup.
export FSDP_CPU_RAM_EFFICIENT_LOADING=1

# The LL and LL128 protocols are not supported over EFA in several aws-ofi-nccl versions; leaving the choice to NCCL can produce hangs or wrong results. Pin it to simple unless AWS docs for your exact version say otherwise.
export NCCL_PROTO=simple

# Lets the caching allocator grow segments instead of fragmenting. This is the single highest-value setting for OOM-at-step-N failures where memory is available but not contiguous.
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True

# FSDP's all-gather/reduce-scatter pattern interacts badly with recorded streams; this reduces peak memory.
export TORCH_NCCL_AVOID_RECORD_STREAMS=1

# Keep the watchdog asynchronous. Setting this to 1 serializes the wait and hides which rank actually stalled.
export TORCH_NCCL_BLOCKING_WAIT=0

Why each one, 11 variables

REQUIREDFI_EFA_FORK_SAFE=1

Makes EFA safe across fork(). PyTorch DataLoader workers fork, so without this you get intermittent, un-debuggable corruption or hangs that correlate with num_workers.

Source: AWS EFA documentation

REQUIREDFI_EFA_USE_DEVICE_RDMA=1

Enables device RDMA so the NIC reads GPU memory directly. Required on p4d; already the default on p5 and later, where setting it is harmless.

Source: AWS EFA documentation

REQUIREDFI_PROVIDER=efa

Selects the EFA libfabric provider. Without it libfabric picks tcp or sockets and every byte crosses the kernel network stack instead of the fabric — often a 10x collective slowdown that looks like a model problem.

Source: AWS aws-ofi-nccl / EFA documentation

REQUIREDLD_LIBRARY_PATH=/opt/amazon/efa/lib:/opt/amazon/openmpi/lib:$LD_LIBRARY_PATH

EFA and its OpenMPI live outside the default loader path. Missing this is why FI_PROVIDER=efa "does nothing".

Source: AWS EFA installer layout

REQUIREDNCCL_SOCKET_IFNAME=ensVERIFY ON YOUR HARDWARE

The bootstrap interface prefix (NOT the data path — that is EFA). AWS instances name interfaces ens5/ens32; the danger is NCCL picking docker0 or a virtual bridge and failing rendezvous.

Source: NCCL environment variables

REQUIREDTORCH_NCCL_ASYNC_ERROR_HANDLING=1

Makes a failed collective raise instead of hanging forever. Without it a dead rank turns into a job that burns GPU-hours doing nothing until the wall clock kills it.

Source: PyTorch distributed docs (renamed from NCCL_ASYNC_ERROR_HANDLING in 2.2)

RECOMMENDEDFSDP_CPU_RAM_EFFICIENT_LOADING=1

Loads the checkpoint on rank 0 and broadcasts, instead of every rank materializing the full model in host RAM. On a 70B model this is the difference between loading and being OOM-killed at startup.

Source: HuggingFace Accelerate / FSDP docs

RECOMMENDEDNCCL_PROTO=simple

The LL and LL128 protocols are not supported over EFA in several aws-ofi-nccl versions; leaving the choice to NCCL can produce hangs or wrong results. Pin it to simple unless AWS docs for your exact version say otherwise.

Source: aws-ofi-nccl known issues

RECOMMENDEDPYTORCH_CUDA_ALLOC_CONF=expandable_segments:True

Lets the caching allocator grow segments instead of fragmenting. This is the single highest-value setting for OOM-at-step-N failures where memory is available but not contiguous.

Source: PyTorch CUDA allocator docs (expandable_segments, 2.1+)

RECOMMENDEDTORCH_NCCL_AVOID_RECORD_STREAMS=1

FSDP's all-gather/reduce-scatter pattern interacts badly with recorded streams; this reduces peak memory.

Source: PyTorch FSDP notes

RECOMMENDEDTORCH_NCCL_BLOCKING_WAIT=0

Keep the watchdog asynchronous. Setting this to 1 serializes the wait and hides which rank actually stalled.

Source: PyTorch distributed docs

Frequently asked questions

Why does this exist?

Because the knowledge is public but scattered. FI_EFA_FORK_SAFE is in an AWS doc, CUDA_DEVICE_MAX_CONNECTIONS=1 is one line in the Megatron-LM README, the NCCL_IB_GID_INDEX advice is in a Mellanox configuration guide, and the fact that LL protocols are unsupported over EFA is in an aws-ofi-nccl GitHub issue. Nobody has all four in their head, and the failures they cause look like model bugs, not configuration bugs.

Can I just paste the output and run?

Mostly, with three exceptions the tool marks explicitly. NCCL_SOCKET_IFNAME depends on what your interfaces are actually called — check `ip -br addr`. NCCL_IB_HCA depends on your HCAs and which ports are ACTIVE — check `ibstat`. NCCL_IB_GID_INDEX depends on which GID is RoCEv2 on your hardware — check `show_gids`. Everything flagged VERIFY ON YOUR HARDWARE is a value we cannot know for you, and guessing it is worse than leaving it out.

What does the conflict checker find that I wouldn't?

Contradictions, which are much harder to see than omissions because each variable looks reasonable alone. NCCL_IB_DISABLE=1 sitting next to a carefully-tuned NCCL_IB_HCA. NCCL_SOCKET_IFNAME pointing at docker0, so rendezvous can never complete across hosts. An LL protocol pinned while running over EFA. NCCL_P2P_DISABLE=1 left over from debugging on a box with NVLink, quietly costing an order of magnitude. A 60-second NCCL_TIMEOUT that a checkpoint write will trip.

Does my environment leave my machine?

No. Both the generator and the checker run entirely in your browser as compiled JavaScript. That matters more here than on most tools — a pasted environment block routinely contains API keys and tokens.

Why are debug variables off by default?

NCCL_DEBUG=INFO and TORCH_DISTRIBUTED_DEBUG are diagnostic settings, not production ones. They add real overhead and enormous log volume. They belong in the run where you are chasing a problem, and nowhere else — so the tool makes turning them on a deliberate choice and warns when you do.

Then check the fabric underneath it

The right variables still need the right topology. The NCCL topology linter validates GPU→NIC affinity, PCIe ACS and your NCCL settings against the real hardware — and denpex preflight run measures what the fabric actually delivers.

Topology linter & preflight benchmark