Xid 13: Graphics Engine Exception due to Kernel Out-of-Bounds Access
A custom PyTorch C++ / CUDA kernel (or a bug in a framework like TensorRT/DeepSpeed) calculates an incorrect thread index or memory offset, resulting in a read or write operation past the allocated bounds of a tensor. The NVIDIA hardware traps this memory violation (Warp Illegal Address) and halts the GPU context, logging an Xid 13 error.
A custom PyTorch C++ / CUDA kernel (or a bug in a framework like TensorRT/DeepSpeed) calculates an incorrect thread index or memory offset, resulting in a read or write operation past the allocated bounds of a tensor.
- Symptom
dmesg shows NVRM Xid 13 Graphics Engine Exception.- Root cause
- A custom PyTorch C++ / CUDA kernel (or a bug in a framework like TensorRT/DeepSpeed) calculates an incorrect thread index or memory offset, resulting in a read or write operation past the allocated bounds of a tensor. The NVIDIA hardware traps this memory violation (Warp Illegal Address) and halts the GPU context, logging an Xid 13 error.
- Recommended fix
- Fix the CUDA Kernel Bounds Checking if (idx < target_size) { out[idx] = in[idx]; } Ensures the CUDA kernel threads do not attempt to access memory beyond the allocated array size.
- How Denpex helps
- Denpex matches Xid 13: Graphics Engine Exception due to Kernel Out-of-Bounds Access across every rank in a distributed run and reports which rank failed first, so you act on the initiating node instead of the loudest one.
What this failure is
Xid 13: Graphics Engine Exception due to Kernel Out-of-Bounds Access is a Software failure seen during ML training runs. A custom PyTorch C++ / CUDA kernel (or a bug in a framework like TensorRT/DeepSpeed) calculates an incorrect thread index or memory offset, resulting in a read or write operation past the allocated bounds of a tensor. The NVIDIA hardware traps this memory violation (Warp Illegal Address) and halts the GPU context, logging an Xid 13 error. Common tags: Xid Error.
Is this what broke your run? Paste your log.
You're reading about Xid 13: Graphics Engine Exception due to Kernel Out-of-Bounds Access. Paste your own crash log or traceback below and get the real root cause for YOUR run, not this generic entry. No account, no card. Logs are masked at ingress and never saved to account history.
Want 14 days on the Scale plan?
Request an evaluation code. A verified workplace organization activates up to 50 diagnoses a day, alerts, history, and follow-up questions. No credit card or automatic subscription.
Why it happens (the mechanism)
Because Xid 13 is a driver-level fault (Graphics Engine Exception), users often mistake this for failing GPU hardware or a driver bug, replacing GPUs unnecessarily rather than debugging their custom CUDA code.
What you'll observe
- NVRM: Xid (PCI:0000:01:00): 13, Graphics Exception: Warp Illegal Address
- NVRM: Xid (PCI:0000:01:00): 13, Graphics Exception: ESR 0x404490=0x80000000
- RuntimeError: CUDA error: an illegal memory access was encountered
Common symptoms and what they mean
| Symptom | Why it happens |
|---|---|
| Training script crashes abruptly with a CUDA illegal memory access error. | A custom PyTorch C++ / CUDA kernel (or a bug in a framework like TensorRT/DeepSpeed) calculates an incorrect thread index or memory offset, resulting in a read or write operation past the allocated bounds of a tensor. The NVIDIA hardware traps this memory violation (Warp Illegal Address) and halts the GPU context, logging an Xid 13 error. |
| dmesg shows NVRM Xid 13 Graphics Engine Exception. | A custom PyTorch C++ / CUDA kernel (or a bug in a framework like TensorRT/DeepSpeed) calculates an incorrect thread index or memory offset, resulting in a read or write operation past the allocated bounds of a tensor. The NVIDIA hardware traps this memory violation (Warp Illegal Address) and halts the GPU context, logging an Xid 13 error. |
| Subsequent PyTorch operations fail until the process is restarted. | A custom PyTorch C++ / CUDA kernel (or a bug in a framework like TensorRT/DeepSpeed) calculates an incorrect thread index or memory offset, resulting in a read or write operation past the allocated bounds of a tensor. The NVIDIA hardware traps this memory violation (Warp Illegal Address) and halts the GPU context, logging an Xid 13 error. |
Which systems are affected
- PyTorch
- CUDA
- NVIDIA Driver
How to confirm this is the problem
Use this checklist to test the hypothesis against a small reproduction. No single line proves the root cause, so preserve the preceding events and compare one variable at a time.
- ✓Run the training script wrapped in compute-sanitizer: compute-sanitizer --tool memcheck python train.py
- ✓Look for 'Invalid __global__ read of size X' or 'Invalid __global__ write of size X' in the sanitizer output.
- ✓Set export CUDA_LAUNCH_BLOCKING=1 to get an accurate Python stack trace pointing to the failing operation.
Searchable error signature
dmesg shows NVRM Xid 13 Graphics Engine Exception.
RuntimeError: CUDA error: an illegal memory access was encounteredUse this text as a lookup key in logs and upstream issue trackers. It is not presented as a captured customer log. Confirm the cause from your own preceding events, versions, configuration and the cited references.
The fix and the prevention pattern
The root cause is on this page and stays free. A free account adds the exact remediation steps, saved history, and the fix on every entry in the encyclopedia.
Sign up free. Unlock the full analysisNo credit card. Daily allowance follows verified trust tier. Instant access.
Xid 13 in context
Xid 13 is one of a small set of codes the NVIDIA driver uses to report GPU faults, and the number is most of the diagnosis: it tells you whether you are looking at your own code, the driver, or a board that needs replacing.
Compare every Xid code side by sideDiagnose this failure in VS Code
Select the traceback or open the failed terminal, then run Denpex locally to see the initiating rank, collateral failures, exact fix, and verification command without uploading the log.
Install the free VS Code extensionRoot cause
- A custom PyTorch C++ / CUDA kernel (or a bug in a framework like TensorRT/DeepSpeed) calculates an incorrect thread index or memory offset, resulting in a read or write operation past the allocated bounds of a tensor. The NVIDIA hardware traps this memory violation (Warp Illegal Address) and halts the GPU context, logging an Xid 13 error.
The fix and how to prevent it
Evaluate Denpex on your own logs
Request a Scale evaluation code. A verified workplace organization activates 14 days with up to 50 diagnoses a day. Every account keeps its current diagnosis allowance and gets a verification path. No card or automatic subscription.
Don't just read the fix, diagnose your run
The encyclopedia tells you what went wrong. Denpex tells you what went wrong in YOUR training run. With your logs, your config, and your stack.