stable-diffusion-webui
stable-diffusion-webui copied to clipboard
[Bug]: NansException: A tensor with all NaNs was produced in VAE on some images in img2img
Is there an existing issue for this?
- [X] I have searched the existing issues and checked the recent builds/commits
What happened?
For this input image in img2img it throws a error:

modules.devices.NansException: A tensor with all 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. Use --disable-nan-check commandline argument to disable this check.
I tried to use both of these flags and other models, but it just returns a black image
BUT
If I use the same settings with another picture it works perfectly fine
Input image:

Output image:

Steps to reproduce the problem
- Go to img2img
- Upload image proided above
- Set those settings:

- Press generate
- See an error:

What should have happened?
It should work with this picture
Commit where the problem happens
ea9bd9fc7409109adcd61b897abc2c8881161256
What platforms do you use to access the UI ?
Windows
What browsers do you use to access the UI ?
Google Chrome
Command Line Arguments
--listen --medvram --opt-split-attention
List of extensions

Console logs
`Traceback (most recent call last):
File "C:\Software\Other Software\sdautomatic111\modules\call_queue.py", line 56, in f
res = list(func(*args, **kwargs))
File "C:\Software\Other Software\sdautomatic111\modules\call_queue.py", line 37, in f
res = func(*args, **kwargs)
File "C:\Software\Other Software\sdautomatic111\modules\img2img.py", line 169, in img2img
processed = process_images(p)
File "C:\Software\Other Software\sdautomatic111\modules\processing.py", line 486, in process_images
res = process_images_inner(p)
File "C:\Software\Other Software\sdautomatic111\modules\processing.py", line 632, in process_images_inner
devices.test_for_nans(x, "vae")
File "C:\Software\Other Software\sdautomatic111\modules\devices.py", line 152, in test_for_nans
raise NansException(message)
modules.devices.NansException: A tensor with all 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. Use --disable-nan-check commandline argument to disable this check.`
Additional information
No response
I live also same problem. :(
Same issue Feelsbadman
try —no-half-vae
try —no-half-vae
I wrote that I already tried --disable-nan-check and --no-half-vae
It was solved for me in the following way: 1- Edit with Notepad++ or notepad the webui-user.bat file 2- copy and paste the following: set PYTHON="here you must put the path of the python executable with the quotes" setGIT= set VENV_DIR= set COMMANDLINE_ARGS=--xformers git pull call webui.bat 3- save all
It was solved for me in the following way: 1- Edit with Notepad++ or notepad the webui-user.bat file 2- copy and paste the following: set PYTHON="here you must put the path of the python executable with the quotes" setGIT= set VENV_DIR= set COMMANDLINE_ARGS=--xformers git pull call webui.bat 3- save all
Thank you ! its works for me !
I have setted "--xformers" but when it start to tain it still raise this error. 6GB3060
doesn't work for me
right-click the webui-user.bat file, then click edit, find "set COMMANDLINE_ARGS="--no-half-vae" I don't know why this error appears, I had it too, this fixed it
right-click the webui-user.bat file, then click edit, find "set COMMANDLINE_ARGS="--no-half-vae"
I wrote that I tried to use both "--no-half-vae" and "--disable-nan-check"
Quote from issue description:
I tried to use both of these flags and other models, but it just returns a black image
hello, I know it has nothing to do with anything but I would like to ask you something. What props or how to make it so that it doesn't modify the composition of the image? I want to achieve an anime effect like the one you achieved in the second picture. sorry for the question and I hope you can solve the problem soon.
hello, I know it has nothing to do with anything but I would like to ask you something. What props or how to make it so that it doesn't modify the composition of the image? I want to achieve an anime effect like the one you achieved in the second picture. sorry for the question and I hope you can solve the problem soon.
I used img2img with low denoising strength (0.15-0.3)
make sure ur size is 512 x 512 or Multiple of 512
For me the error message told me to use "set COMMANDLINE_ARGS="--no-half"" and this worked.
Anyone who has still this error? I've noticed it only gives me the error when using Anime VAEs, like Orangemix or anything vae, while it never gives me the error when I use the Stability AI one (MSE one). Tried using no half vae argument but then I have problems with CUDA Memory because I only have 8 gbs of Vram. The --disable-nan-check works but the error doesn't disappear, simply it gives me black images sometimes. If anyone has some solutions please help. Is there maybe a way to fix VAEs?
What's the python executable?
here you must put the path of the python executable with the quotes"
See https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Troubleshooting Issue was solved for me by using the command line arguments --precision full --no-half
It was solved for me in the following way: 1- Edit with Notepad++ or notepad the webui-user.bat file 2- copy and paste the following: set PYTHON="here you must put the path of the python executable with the quotes" setGIT= set VENV_DIR= set COMMANDLINE_ARGS=--xformers git pull call webui.bat 3- save all
I have the exact same except no quotes (path has no spaces) This can't be the issue
make sure ur size is 512 x 512 or Multiple of 512
I have this issue with a generated image of 768x768, but no issue with a 512x512. No other way ? this seems strange
I started to have this problem with "revAnimated_v121.safetensors [f57b21e57b]" model with an especific image too. I change the model to finish my work to "dreamshaper_4BakedVae.safetensors". Today i tested my problematic image and no erros yet.
So i tested the file from original author post (BTW my card is a 4GB ram so can set the tested resolution) But have no problems so far. Lots of uspscale and inpaints. The image below was maded with revAnimated_v121.safetensors [f57b21e57b].

seems to be an issue when i use RevAnimated v121. other chkpts seem ok.
I am getting this on the dreamlike diffusion model.
right-click the webui-user.bat file, then click edit, find "set COMMANDLINE_ARGS="--no-half-vae"
I wrote that I tried to use both "--no-half-vae" and "--disable-nan-check"
Quote from issue description:
I tried to use both of these flags and other models, but it just returns a black image
Same here, did you figure it out?
it happens to me in txt2img when using lora or locon without vae, except it looks good in preview until the last step then it it one colour
Settings - Stable Diffusion - SD VAE - Automatic
helped me
What will --no-half-vae do to my image? Will I get lower quality images if I add it to COMMANDLINE_ARGS?
same issue to me, in img2img tab, with multi params xyz plots
I suggest you try adding the command line argument --no-half (additional to --no-half-vae ) and remove --disable-nan-check
From the error I encountered I gathered this could relate to "your video card does not support half type" It might be the case that you originaly encountered: "A tensor with all NaNs was produced in VAE" When adding the commandline argument --no-half-vae you might have fixed your original issue. Ultimatly you then ran into the error I ran into: "A tensor with all NaNs was produced in Unet" --disable-nan-check discards the check if you get not a number errors. Therefore you no longer get any exceptions but a black image. I suspect, if you remove --disable-nan-check without adding --no-half, you encounter the error I ran into.
What will --no-half-vae do to my image? Will I get lower quality images if I add it to COMMANDLINE_ARGS?
From what I was able to understand it shouldn't change a lot about the appearance of the images. The parameter appears to adjust the precision your graphics card does its computations with. Some cards appear to not support "half precision". Maybe this parameter impacts performance negatively tho
What will --no-half-vae do to my image? Will I get lower quality images if I add it to COMMANDLINE_ARGS?
From what I was able to understand it shouldn't change a lot about the appearance of the images. The parameter appears to adjust the precision your graphics card does its computations with. Some cards appear to not support "half precision". Maybe this parameter impacts performance negatively tho
Based on my tests, it does impact performance. I added this to my command line arguments and it caused me to run out of vram much sooner when I started pushing up the parameters. Can't say if I noticed a clear speed difference or not. I'm definitely going to try and find another way around this error.