Free | No tracking | Every fact with a source|German and English

Error / Graphics card and drivers

RuntimeError: CUDA error: an illegal memory access was encountered – the graphics card accessed invalid memory

A computation step on the graphics card accessed an invalid memory address, and after that CUDA is unusable for this process.

The message

RuntimeError: CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 (bei Sage Attention auch: Triton Error [CUDA]: an illegal memory access was encountered)

Affects: ComfyUI, AUTOMATIC1111 Stable Diffusion WebUI, Stable Diffusion WebUI Forge, TextGen (text-generation-webui), Python

Why is this happening?

The error is not “out of memory,” but an invalid read or write access in a GPU code path, often caused by a bug in a library or by exceeding an index boundary. A well-known example is Sage Attention with very long, high-resolution videos. Because the GPU works asynchronously, the traceback often points to the wrong place. After the error, every further CUDA operation in the same process returns the same error.

How to fix it

  1. Completely close the program and restart it. According to NVIDIA, the process is in an inconsistent state after this error.
  2. If you use Sage Attention (--use-sage-attention or an attention mode “sage” in a node) and the error occurs with long videos, switch to sdpa or leave out the startup parameter. Alternatively, reduce the number of images or the resolution.
  3. Update the program and PyTorch to the current stable version. Some of these errors are in libraries and have been fixed in newer versions.
  4. If you want to report the error, start the program with synchronous GPU calls so the traceback shows up at the right place: in PowerShell, set $env:CUDA_LAUNCH_BLOCKING="1" beforehand. This makes everything slower, so only use it for testing.
  5. If the error only occurs with a specific workflow or node, test without that node and report the error with the traceback to the project.

Better not: Do not leave CUDA_LAUNCH_BLOCKING=1 set permanently; it is only for troubleshooting and slows things down a lot.

Set up from scratch again

If it still doesn’t work after that, a fresh setup step by step often helps:

Terms for this

Similar errors

Sources

Checked on Oct 27, 2026. Didn't help? Ask in the forum and name the graphics card, program, and the full message.