Skip to content

Operator task guide

How to fix NCCL error 1, 2, 3, and invalid usage errors

NCCL numeric return codes map to distinct layers: Error 1 (ncclUnhandledCudaError) means a CUDA call inside NCCL failed; Error 2 (ncclSystemError) means a Linux socket, mmap, /dev/shm, or RDMA syscall failed; Error 3 (ncclInternalError) signals an NCCL invariant or library-version mismatch; Error 4 (ncclInvalidUsage) points to duplicate GPU assignment or bad communicator setup.

Because NCCL wraps the underlying OS or CUDA error into a generic RuntimeError, re-run with NCCL_DEBUG=INFO (plus CUDA_LAUNCH_BLOCKING=1 for Error 1) to print the exact errno, CUDA status, or conflicting library path immediately preceding the wrapper.

Reviewed . Reference guidance is not a diagnosis of your workload.

Step-by-step method

  1. 1

    Identify the exact NCCL error class and run with NCCL_DEBUG=INFO

    Capture the first NCCL WARN/ERROR line before the Python RuntimeError wrapper so you see the syscall errno or CUDA error code.

    NCCL_DEBUG=INFO NCCL_DEBUG_SUBSYS=INIT,P2P,NET,SHM torchrun --nproc_per_node=8 train.py 2>&1 | grep -iE 'NCCL (WARN|ERROR)|cuda|errno'
  2. 2

    Debug NCCL Error 1 (unhandled cuda error)

    Error 1 is almost never an NCCL bug. An asynchronous CUDA illegal access, OOM, or hardware Xid poisoned the context before NCCL synchronized. Run with CUDA_LAUNCH_BLOCKING=1 and check dmesg for Xids.

    CUDA_LAUNCH_BLOCKING=1 torchrun --nproc_per_node=8 train.py
    dmesg -T | grep -iE 'NVRM: Xid|AER'
  3. 3

    Debug NCCL Error 2 (unhandled system error)

    Error 2 points to OS limits or networking: 64 MB /dev/shm exhaustion, ulimit -l memlock limits for RDMA, unreachable NCCL_SOCKET_IFNAME, or blocked ephemeral ports.

    df -h /dev/shm
    ulimit -l
    ip -br addr
    ibstat
  4. 4

    Debug NCCL Error 3 (internal error) and Error 4 (invalid usage)

    For Error 3, check for duplicate libnccl.so versions on LD_LIBRARY_PATH vs PyTorch bundled NCCL. For Error 4, check that two ranks are not assigned to the same GPU UUID via bad LOCAL_RANK or CUDA_VISIBLE_DEVICES.

    python3 -c "import torch; print(torch.cuda.nccl.version())"
    ldconfig -p | grep libnccl
    env | grep -E 'RANK|LOCAL_RANK|CUDA_VISIBLE_DEVICES'

NCCL error code lookup and owner

Signals, meanings and actions for how to fix nccl error 1, 2, 3, and invalid usage errors.
SignalWhat it meansNext action
Error 1: ncclUnhandledCudaErrorCUDA call inside NCCL failed or context was poisoned.Re-run with CUDA_LAUNCH_BLOCKING=1 and check host dmesg for Xids.
Error 2: ncclSystemError (unhandled system error)OS socket, shm, memlock, or IB verbs syscall failed.Check /dev/shm, ulimit -l, NCCL_SOCKET_IFNAME, and firewall/RDMA state.
Error 3: ncclInternalError (internal check failed)NCCL library conflict or broken topology state.Compare torch.cuda.nccl.version() against ldconfig and verify NVSwitch/P2P topology.
Error 4: ncclInvalidUsageDuplicate GPU ordinal or mismatched communicator rank args.Verify LOCAL_RANK maps 1:1 to CUDA_VISIBLE_DEVICES per node.

Evidence checklist

  • NCCL_DEBUG=INFO output showing WARN lines before the RuntimeError
  • torch.cuda.nccl.version() and ldconfig -p | grep libnccl
  • df -h /dev/shm and ulimit -a inside the container
  • CUDA_VISIBLE_DEVICES, RANK, and LOCAL_RANK per process
  • Host dmesg kernel logs for Xids or IB link drops

Common mistakes

Setting NCCL_IB_DISABLE=1 permanently to silence Error 2

Falling back to TCP sockets cuts multi-node training bandwidth massively; fix ulimit -l, HCA mounts, or subnet routing instead.

Ignoring duplicate libnccl.so installations

Pip-installed nvidia-nccl-cu* packages can conflict with system /usr/lib/x86_64-linux-gnu/libnccl.so.

Treating Error 1 as a network fault

Error 1 means CUDA failed on a GPU; check kernel memory access, OOM, or hardware Xids first.

Frequently asked questions

What does NCCL error 1 unhandled cuda error mean?

It means NCCL invoked a CUDA runtime/driver function and received an error. Run with NCCL_DEBUG=INFO and CUDA_LAUNCH_BLOCKING=1 to surface the actual CUDA error and check dmesg for hardware Xids.

What causes NCCL error 2 unhandled system error in Docker or Kubernetes?

Most often /dev/shm is capped at 64 MB, ulimit -l is too low for RDMA memory pinning, or NCCL picked an unreachable bridge interface instead of the cluster data NIC.

How do I fix NCCL error 3 internal check failed?

Verify all nodes run matching PyTorch and libnccl versions without conflicting LD_LIBRARY_PATH entries, and confirm GPU topology (nvidia-smi topo -m) is healthy across NVLink/PCIe.

Why does NCCL say invalid usage on multi-GPU launch?

Two processes attempted to initialize NCCL on the same physical GPU ordinal, usually because LOCAL_RANK was not wired to torch.cuda.set_device(local_rank) or Slurm CUDA_VISIBLE_DEVICES collided with torchrun.

Live diagnosis, no signup

Upload your GPU log. Find what happened first.

Get the likely cause, supporting evidence, and next safe steps with the same cloud reasoning used by paid plans. A crash the engine recognizes is answered in seconds, then checked by an independent AI review that updates this page when it finishes. A crash it does not recognize waits for the AI's own answer, which can take a few minutes. No account, card, or installation. Logs are masked at Denpex API ingress and are not saved to account history.

Before uploading, review cloud data handling and local options.

training_logs.txt
No log to hand? Try one:

Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.

3 free cloud diagnoses per day

Try Denpex for 30 days. FREE.

No credit card. No automatic subscription. See whether Denpex helps with an incident you already understand.

Start your free 30-day Team evaluation

Up to 50 diagnoses a day for 30 days. Verify your work email to activate an eligible company evaluation, then replay a resolved incident and compare the evidence and next steps with your team's confirmed cause.

Use your company email, for example alex@yourcompany.com.

Who qualifies?

Company email domains activate the free 30-day Team evaluation (up to 50 diagnoses a day) after an email and domain check, whatever mail provider you use. If we cannot verify your domain automatically, support reviews it: write to support@denpex.com. Free local diagnosis in the editor extension needs no account.

Using a personal email (Gmail, Outlook, Naver, QQ) or solo cluster? Create a free $0 account (no work email required) to save 7-day history and unlock AI fallback, or send a cluster crash log for a live walkthrough.

Apply the method to your incident

Use the three free diagnoses to review your error and relevant evidence. Keep reference guidance separate from the cause and recovery status of your own workload.

Diagnose your incident