stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Bug]: Image generation crashing: "Tensor with all NaNs was produced in Unet"

Open cobble7169 opened this issue 2 years ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What happened?

Image generation stopped at 8-12% and gave the error: "modules.devices.NansException: A tensor with all NaNs was produced in Unet. This could be either because there's not enough precision to represent the picture, or because your video card does not support half type. Try setting the "Upcast cross attention layer to float32" option in Settings > Stable Diffusion or using the --no-half commandline argument to fix this. Use --disable-nan-check commandline argument to disable this check."

Steps to reproduce the problem

Started a generation I had run previously from PNG Info, so the same generation data was used. Same model as well, Chilloutmix, no VAE. Other models worked fine, but this model worked fine yesterday and I have not changed its version. Have tested multiple other PNG Info's from generations from the same model, same result.

What should have happened?

The image should have generated.

Commit where the problem happens

5ab7f213bec2f816f9c5644becb32eb72c8ffb89

What platforms do you use to access the UI ?

MacOS

What browsers do you use to access the UI ?

Brave

Command Line Arguments

Launching Web UI with arguments: --skip-torch-cuda-test --upcast-sampling --opt-sub-quad-attention --use-cpu interrogate

List of extensions

a1111-sd-webui-lycoris instruct-pix2pix loopback_scaler openpose-editor sd-dynamic-thresholding sd-webui-additional-networks sd-webui-aspect-ratio-helper sd-webui-controlnet sd_webui_SAG ultimate-upscale-for-automatic1111 LDSR | built-in |   |   Lora | built-in |   |   ScuNET | built-in |   |   SwinIR | built-in |   |   prompt-bracket-checker

Console logs

modules.devices.NansException: A tensor with all NaNs was produced in Unet. This could be either because there's not enough precision to represent the picture, or because your video card does not support half type. Try setting the "Upcast cross attention layer to float32" option in Settings > Stable Diffusion or using the --no-half commandline argument to fix this. Use --disable-nan-check commandline argument to disable this check.

Additional information

No response

cobble7169 avatar May 12 '23 04:05 cobble7169

I got this as well just a couple of days ago while doing an upscale in img2img! Sorry I can't help you further, just chiming in so that you know it's not your system!

Also, I'm on Windows so this is not specific to MacOS!

oliverban avatar May 12 '23 12:05 oliverban

I think this same error has been popping up for other people in different places. Not sure why it just happened for me, I don't have it set to auto update, so my commit should have been the same as before the issue.

cobble7169 avatar May 12 '23 17:05 cobble7169

I ran into the same problem. Windows 10, RTX 3070 notebook 8GB VRAM. I tried the parameters --no-half, --no-half-vae, --disable-nan-check, turned on the "Upcast cross attention layer to float32" option, but the best result I got was a black image. Then I deleted all parameters, switched to the v-1-5-pruned checkpoint and then the image was generated. From then on, the problem disappeared.

teherauto avatar May 13 '23 05:05 teherauto

I’ve noticed this since the update to Torch 2 maybe

I’ll get to a point where I get the error every time I press generate, then switching the model to a new one causes the error to stop happening for a bit.

I don’t know the inner workings but maybe some VRAM isn’t getting garbage collected etc?

I know I often get the NaN error when I try go 768x768 but not eg 640x640, so I’m assuming it’s memory related even though I don’t get an OOM error

just guessing though

related: https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/10343 https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/10227 https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/9294

jmp909 avatar May 25 '23 15:05 jmp909

A1111 updated for me and now I get this same error everytime I run it. Any updates coming or how can I roll back? modules.devices.NansException: A tensor with all NaNs was produced in Unet. This could be either because there's not enough precision to represent the picture, or because your video card does not support half type. Try setting the "Upcast cross attention layer to float32" option in Settings > Stable Diffusion or using the --no-half commandline argument to fix this. Use --disable-nan-check commandline argument to disable this check.

jcrsantiago avatar Jun 18 '23 19:06 jcrsantiago

Duplicate of https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/6923

catboxanon avatar Aug 26 '23 09:08 catboxanon