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

Error / Graphics card and drivers

A1111/Forge: A tensor with NaNs was produced (black image)

When calculating in half precision (fp16), invalid numbers were created, and the image turns black or green or crashes.

The message

modules.devices.NansException: A tensor with NaNs was produced in VAE. This could be because there's not enough precision to represent the picture. Try adding --no-half-vae commandline argument to fix this.

Affects: AUTOMATIC1111 Stable Diffusion WebUI, Stable Diffusion WebUI Forge

Why is this happening?

To save memory, the WebUI computes in 16-bit precision. Some VAEs (often with SDXL) and older GTX 10 and 16 series cards cannot handle that, which creates NaN values. A faulty model or a bad merge can also be the cause.

How to fix it

  1. If the error comes from the VAE: Add the option --no-half-vae in webui-user.bat under set COMMANDLINE_ARGS= and restart.
  2. If the error comes from the Unet: Enable the option "Upcast cross attention layer to float32" under Settings > Stable Diffusion, or try the startup option --upcast-sampling.
  3. For GTX 10 and GTX 16 cards, the wiki recommends --upcast-sampling together with --xformers, and if needed also --no-half-vae.
  4. Only use --no-half as a last resort. It is the slowest and uses the most VRAM, possibly together with --medvram.
  5. If the error only happens with a specific model, the model is the problem. Try a different model or a different VAE.

Better not: --disable-nan-check only hides the error message; the affected images stay black anyway.

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 21, 2026. Didn't help? Ask in the forum and name the graphics card, program, and the full message.