From ct
Deep GPU/CUDA operational intuition — nvidia-smi/dcgm fields, NCCL tuning, MIG vs MPS, NVLink/InfiniBand/GPUDirect, Nsight profiling, Xid/ECC diagnosis, Hopper/Blackwell specifics. Load when debugging cluster-level GPU issues, distributed-training hangs, multi-tenant sharing, interconnect sizing, or architecture tuning. Skip for training-loop authoring, model architecture, dataloader perf, or ROCm/Gaudi. Triggers on: "nvidia-smi", "DCGM_FI_PROF", "NCCL_TOPO_FILE", "MIG", "NVLink", "GPUDirect RDMA", "nsys", "Xid", "ECC row remapping", "TMA", "FP8", "Hopper", "Blackwell".
How this skill is triggered — by the user, by Claude, or both
Slash command
/ct:cuda-gpu-opsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Concise operational pointers for cluster-level GPU debugging, distributed training, and architecture-specific tuning.
Concise operational pointers for cluster-level GPU debugging, distributed training, and architecture-specific tuning.
Assumes you already know that GPUs run kernels, that CUDA exists, and basic CUDA programming concepts. This skill covers the operational layer — the parts models tend to gloss over: what nvidia-smi numbers actually mean, NCCL knobs and topology, MIG/MPS/streams decisions, interconnect sizing, profiling, power/thermal/ECC, Xid forensics, and Hopper/Blackwell specifics — current as of late 2025/early 2026.
Load when the question is about:
dmesg / journal for NVRM: Xid and deciding "RMA the card or reboot"reserved headroom (fragmentation)nvidia-peermem failures on a new IB fabricDo NOT load for: model architecture or dataset pipelines without a GPU-systems angle, plain PyTorch/TF API questions, AMD ROCm / Intel Gaudi / Apple MPS, cost/billing comparisons.
GPU-Util (Volatile) is the percentage of time in the sample window that at least one kernel was running. Aggregate over all SMs, treats GPU as a single unit. A single warp pinging one SM yields 100%. You can hit 100% on pure memcpy with zero compute. Occupancy proxy at best, saturation never.dcgm-exporter give real saturation:
DCGM_FI_PROF_SM_ACTIVE — fraction of cycles an SM had a resident warpDCGM_FI_PROF_SM_OCCUPANCY — average warp slots filled / maxDCGM_FI_PROF_PIPE_TENSOR_ACTIVE — tensor-core busy ratio (the metric you actually want for LLM training)DCGM_FI_PROF_PIPE_FP16_ACTIVE, _FP32_ACTIVE, _FP64_ACTIVEDCGM_FI_PROF_DRAM_ACTIVE — HBM bandwidth utilization. High DRAM_ACTIVE + low TENSOR_ACTIVE = memory-bound.DCGM_FI_PROF_PCIE_TX_BYTES, _NVLINK_TX_BYTES — interconnect.Memory-Usage is allocator-reserved VRAM, not application-resident. Frameworks hold caching pools — high Memory-Usage with low actual tensor footprint is normal.Pwr:Usage/Cap — sustained Usage == Cap means you are power-throttled (check Throttle Reasons from nvidia-smi -q).Memory Temp separately (HBM3 throttles ~95°C). Watch Throttle Reasons: HW Thermal Slowdown.nvidia-smi -q -d ECC: Volatile resets on driver reload; Aggregate is lifetime. SBE corrected; DBE uncorrectable, on Ampere+ triggers row remapping.nvidia-smi -pm 1) keeps the kernel module loaded between client exits. Without it, every CUDA process pays a ~1–3 s init and clock state resets. Mandatory on any node with custom power/clock locks.dcgmi diag -r 3 runs an active diagnostic (PCIe, NVLink, memory bandwidth, SM stress, ECC). Use as admission test before scheduling on a suspect node.NCCL_DEBUG=INFO (or WARN, TRACE); NCCL_DEBUG_SUBSYS=INIT,NET,GRAPH to scope; NCCL_DEBUG_FILE=/tmp/nccl.%h.%p.log for per-host/PID.
Transport selection — at init NCCL prints lines like Channel 00 : 0[0] -> 1[1] via P2P/NVLink or via NET/IB/.... These tell you whether intra-node went over NVLink (good), PCIe P2P (acceptable), or shared memory/sockets (bad).
NCCL_IB_HCA=mlx5_0,mlx5_1 — filter HCAs. Always prefix = for exact match — mlx5_1 without = also matches mlx5_10..mlx5_19. :1 for port; ^ excludes.NCCL_IB_DISABLE=1 — force TCP fallback; confirms IB-specific issue.NCCL_SOCKET_IFNAME=eth0,ib0 — filter TCP control-plane interfaces. Mandatory on hosts with bond/docker/cni interfaces or NCCL picks the wrong one and hangs at init.NCCL_P2P_DISABLE=1 — diagnostic only; perf drops sharply.NCCL_SHM_DISABLE=1 — disable host-shared-memory fallback; forces P2P or net.NCCL_TOPO_FILE — override auto-detect with NVIDIA-provided XML for DGX/HGX or non-standard PCIe topology.NCCL_ALGO=Ring|Tree|CollNet|NVLS and NCCL_PROTO=Simple|LL|LL128. Don't set unless benchmarking. Ring = best peak BW for large messages; Tree = log(n) latency at medium sizes; NVLS uses NVLink Sharp on NVSwitch (H100 NVL/GB200) — ~2× faster all-reduce.NCCL_BUFFSIZE (default 4 MB) — raise for very large all-reduce sizes if memory permits.Common breakage: containers without --privileged or without NVIDIA_VISIBLE_DEVICES; missing nvidia-peermem kernel module silently drops to staged TCP.
nvidia-smi -mig 1, then nvidia-smi mig -cgi. Hardware-isolated; safe for multi-tenant. Caveat: no NVLink between MIG instances; tensor-parallel inside a partition only.nvidia-cuda-mps-control -d. Multiple CUDA contexts share one GPU concurrently. On Volta+ each client gets isolated GPU address space, but a fatal fault propagates to all clients. Trusted tenants only. Best for ensemble inference, MoE expert dispatch, batched microservices. Avoid for untrusted code or long-running training.Decision: untrusted multi-tenant → MIG (only on supported SKUs). Trusted concurrent → MPS. Casual pool → time-slicing. Within one app → streams.
| Gen | Per-GPU NVLink | Use |
|---|---|---|
| NVLink 3 (A100) | 600 GB/s | Ampere |
| NVLink 4 (H100) | 900 GB/s | Hopper |
| NVLink 5 (B100/B200) | 1.8 TB/s | Blackwell — 18 sublinks × 100 GB/s |
NVSwitch — full-bandwidth crossbar across an NVLink domain. 4th-gen on Blackwell: 72 NVLink5 ports/chip; GB200 NVL72 aggregates 130 TB/s across 72 GPUs in one rack-scale NVLink domain; scales to 576 GPUs.
PCIe — Gen5 x16 = 64 GB/s bidir (~14× slower than NVLink5). Gen6 doubles to 128 GB/s; rolling out 2025–2026. PCIe is the GPU-CPU and GPU-NIC path; NVLink is GPU-GPU.
InfiniBand — HDR 200 Gb/s (25 GB/s), NDR 400 Gb/s (50 GB/s), XDR 800 Gb/s (100 GB/s, shipping 2025). One ConnectX-7/8 NIC per GPU is the rule on H100/B200 nodes.
GPUDirect RDMA — NIC reads/writes GPU HBM directly, bypassing host bounce buffers. Requires nvidia-peermem (CUDA 11.4+, R470+). Validate with ibv_devinfo and ib_write_bw --use_cuda=0.
GPUDirect Storage (GDS) — NVMe (or NVMe-oF) → GPU memory via DMA, bypassing CPU memcpy. cuFile API; 2–5× on read-heavy data loaders.
Topology matters: NIC↔GPU on different PCIe switches/sockets → RDMA crosses sockets via UPI and tanks. nvidia-smi topo -m shows the affinity matrix (PIX = same switch, PXB = across switches, SYS = across sockets).
nsys (Nsight Systems) — system-wide timeline; CPU+GPU+NCCL+CUDA APIs. Use first to find where time goes. nsys profile -t cuda,nvtx,osrt,cudnn,cublas -o run --capture-range=cudaProfilerApi --cuda-graph-trace=node python train.py. Wrap iterations with torch.cuda.nvtx.range_push("step")/pop() and torch.cuda.cudart().cudaProfilerStart().ncu (Nsight Compute) — single-kernel deep dive (SM/L1/L2/HBM counters, occupancy, roofline). Use after nsys identifies a hot kernel: ncu --target-processes all --set full -k regex:matmul -o report python train.py. Replays the kernel with different counter groups; expensive — bound with --launch-skip and --launch-count.nvprof is deprecated since CUDA 11.x; not supported on Hopper/Blackwell. Use ncu.torch.profiler and nsys collide.nvidia-smi -pm 1 — persistence on first, otherwise other settings get reset.nvidia-smi -pl <W> — set power cap. Bounded by min/max from -q -d POWER. Cluster-wide downcapping (e.g., 500W on 700W H100) commonly buys 5–15% PUE for ~3–7% perf loss.nvidia-smi -lgc <minMHz>,<maxMHz> — lock graphics clocks for deterministic benchmarking. -rgc resets.-q -d PERFORMANCE): SW Power Cap (soft from -pl), HW Slowdown (board PSU/OCP), HW Thermal Slowdown / HW Power Brake Slowdown (physical), Sync Boost (multi-GPU sync). Sustained HW Thermal Slowdown = airflow/coolant problem.nvidia-smi -q -d ECC,ROW_REMAPPER:
cudaErrorECCUncorrectable; on training that's a dead rank.Remapping Failure: Yes or Pending: Yes means reboot. Uncorrectable Error: Yes after reboot = remap exhausted, RMA.dmesg | grep -i NVRM for Xid codes:
Swap thresholds (rule of thumb): >5 row remaps in a week, any Xid 64/79/95, sustained DBE > 0/day.
mma. Compiles to GMMA SASS.The legacy default stream (NULL stream) is shared by all host threads in a process and implicit-syncs against all other blocking streams. Launches on user streams will serialize against it. Symptoms: "I created 4 streams but they run sequentially."
Two fixes:
nvcc --default-stream per-thread or -DCUDA_API_PER_THREAD_DEFAULT_STREAM. Each host thread gets its own non-blocking default.cudaStreamCreateWithFlags(&s, cudaStreamNonBlocking).Mixing matters: a library compiled with legacy default and your code per-thread will still sync against legacy stream 0 if either side touches it.
cudaMallocAsync / cudaFreeAsync (CUDA 11.2+) — stream-ordered allocation; participates in stream graph and CUDA Graphs. Lets you allocate inside captured graphs.
cudaStreamSynchronize blocks the host; cudaEventRecord + cudaStreamWaitEvent lets streams synchronize on the device without host involvement (preferred).
| Memory | BW | Capacity |
|---|---|---|
| HBM2e (A100) | 2.0 TB/s | 40/80 GB |
| HBM3 (H100) | 3.35 TB/s | 80 GB |
| HBM3e (H200) | 4.8 TB/s | 141 GB |
| HBM3e (B200) | 8.0 TB/s | 192 GB |
Fragmentation — long-running training with variable shapes leaves "swiss cheese" segments. Reserved high but no contiguous slab → OOM despite low allocated. Fix: PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True (uses CUDA VMM cuMemMap/cuMemSetAccess). Caveat: doesn't currently interop cleanly with ncclMemAlloc-based allocators — relevant for some FSDP/NCCL VMM paths.
Unified memory (cudaMallocManaged) — single pointer, page-migrated on access. Useful for prototyping; bad for hot loops (page-fault stalls). Hides OOM until access time.
Pinned host memory (cudaMallocHost) — required for true async H2D/D2H. Pages cannot be swapped; bound to ~half of total RAM as a safe upper limit.
CUDA_MODULE_LOADING=LAZY), Hopper PTX (sm_90a).sm_100), MXFP4/MXFP6 in cuBLASLt, Green Contexts (lightweight contexts for SM partitioning without MIG), graph memory nodes via cudaMallocAsync capture.nvprof fully unsupported.Before recommending a non-trivial GPU operational change (NCCL env, MIG/MPS, power cap, allocator config, FP8/FP4 enable):
Tuning without measurement is worse than defaults.
npx claudepluginhub pvillega/claude-templates --plugin ctOptimizes PyTorch, XGBoost GPU, and CUDA workloads on consumer NVIDIA GPUs (8-24GB VRAM) with patterns for mixed precision, gradient checkpointing, torch.compile, CuPy/cuDF migration, and OOM prevention.
Detects when CoreWeave multi-node GPU jobs silently fall back to TCP due to missing RDMA conditions, provides verdict and fix using NCCL_DEBUG logs.
Analyzes NVIDIA Nsight Systems GPU profiles (.sqlite/.nsys-rep) to identify root causes and fixes for bottlenecks, NCCL slowdowns, and efficiency issues.