stable-diffusion-webui
stable-diffusion-webui copied to clipboard
Error(Ошибка): NansException: A tensor with all NaNs was produced in Unet.
[RU]Решение ошибки: NansException: A tensor with all NaNs was produced in Unet.
[EN]Bug fix: NansException: A tensor with all NaNs was produced in Unet.
Ошибка: NansException: A tensor with all NaNs was produced in Unet.
Сама ошибка выглядит так:
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 command line argument to disable this check.
Первое что нужно сделать это изменить некоторые параметры в файле webui-user.bat его нужно перевести в формат .txt (Путь до файла указан выше на картинке).
Второе - в самом файле необходимо добавить данные строчки как на картинке:
Для удобства текст для копирования:
@echo off
set PYTHON= set GIT= set VENV_DIR= set COMMANDLINE_ARGS=--opt-split-attention --precision full --no-half --xformers --autolaunch
call webui.bat
Третье - измените формат файла обратно в .bat Ну конечно если вы искали решение проблемы, то скорее всего способ выше вам не поможет. Расскажу способ, который лично я использую и скорее всего он поможет. При заходе в интерфейс нейронной сети нам нужно её «разогреть», у меня сложилось чёткое мнение, что программа не понимает полные возможности вашего ПК. И поэтому при любом использовании будет давать ошибку. Чтобы переубедить программу ей нужно давать лёгкие настройки для генерации.
- Выберете наиболее лёгкий (Sampling method), чаще всего используется Euler a
- Sampling steps – выставляйте от 10 до 15 шагов.
- Разрешение – по ситуации лучше оставить стандартные 512 x 512 Дальше только подбор. Вскоре нейросеть должна начать генерировать, а вы должны постепенно увеличивать требования для генерации. Вскоре можно менять метод и разрешение количество шагов и т.д. (Бывает что из – за неправильного негативного промпта выдаёт ошибку – будьте внимательнее) Бывает нужно несколько перезагрузок нейросети, но тут только при том случае если прям вообще никак не хочет работать. Так-же если вы владелец слабой или средней видеокарты то выключайте видео на YouTube это выжирает 25% видеокарты. На этом всё, дайте обратную связь если будет возможность. Попытаюсь помочь, да и в целом хотелось бы посмотреть верна ли моя теория.
English version
The error itself looks like this:
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 command line argument to disable this check.
First of all, you need to correct the data in webui-user.bat. The file needs to be .txt (The path to the file is in the picture above)
Secondly, lines like in the picture should also be added to the file:
The text for copying:
@echo off
set PYTHON= set GIT= set VENV_DIR= set COMMANDLINE_ARGS=--opt-split-attention --precision full --no-half --xformers –autolaunch Thirdly, change the file format back to .bat However, If you are looking this problem up, this method will not help you. So, I will tell you how I dealt with it and it may possibly help. When you start using the ai, you need to "warm it up". I realised that the program does not understand all the features of you PC, so it gives you an error with every use. To avoid this, it's better to give it the easier settings for generation.
- Choose an easier Sampling Method, most often it is Euler a.
- Sampling steps - from 10 to 15 steps.
- Resolution should be 512x512. Then it's just customisation. Soon the ai should start generating and you will be able to gradually increase the generation requirements. Then you can change the method, the resolution, the number of steps and etc. (It occurs that it may result in an error if you put in an incorrect prompt - be careful) You may also need to restart the ai if it does not work. Also, if you have a weak or medium graphics card, turn the YouTube videos off. They consume about 25% of the card. That's all. Give feedback if possible, I will try to help. It's interesting to see if my theory is correct.
Additional information
[RU]Помог с переводом музыкант с канала SGL (https://www.youtube.com/@TheSGL) - если всё-же гайд помог в качестве благодарности подпишитесь! [EN]A musician from the SGL channel helped with the translation (https://www.youtube.com/@TheSGL) - if the guide did help, subscribe as a thank you!
--no-half does help but it causes generations to be atleast x10 slower and also increases RAM usage so much that sometimes the WebUI will give out a out of memory error, to the point that its better to keep the nan-check disabled and keep generating until it decides to let you.
There has to be a better solution,
--no-half does help but it causes generations to be atleast x10 slower and also increases RAM usage so much that sometimes the WebUI will give out a out of memory error, to the point that its better to keep the nan-check disabled and keep generating until it decides to let you.
There has to be a better solution,
What are the components of your PC?
--no-half does help but it causes generations to be atleast x10 slower and also increases RAM usage so much that sometimes the WebUI will give out a out of memory error, to the point that its better to keep the nan-check disabled and keep generating until it decides to let you. There has to be a better solution,
What are the components of your PC?
Intel core I5-3340 NVDIA GTX 1650 (4gb vram) 8gb ram ive used stable difussion for like..a year now and now this NaN error has suddenly started happening and i cant figure out a way to fix it.
I have the same problem. I have done everything mentioned in the text below to fix the error. I added --no-half and --disable-nan-check as arguments and enabled "Upcast cross attention layer to float32" in the settings. Still it does not work.
This error occurred when using SDXL to img2img for the first time. But if using SDXL to txt2img before img2img, this error won't happen.
This error occurred when using SDXL to img2img for the first time. But if using SDXL to txt2img before img2img, this error won't happen.
Sounds wired......
https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/15872
Solution: https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/15872#issuecomment-2241234472
Спасибо большое, помогло!
--no-half does help but it causes generations to be atleast x10 slower and also increases RAM usage so much that sometimes the WebUI will give out a out of memory error, to the point that its better to keep the nan-check disabled and keep generating until it decides to let you.
There has to be a better solution,
Yes. This worked for me too but you're right. Draws crazy resources.
Have you figured out a better configuration?
--no-half does help but it causes generations to be atleast x10 slower and also increases RAM usage so much that sometimes the WebUI will give out a out of memory error, to the point that its better to keep the nan-check disabled and keep generating until it decides to let you. There has to be a better solution,
Yes. This worked for me too but you're right. Draws crazy resources.
Have you figured out a better configuration?
I did not.
I have a better pc now so i can run --no-half without as many issues as it csn handle the increased load but i didnt find a solution. I just left it like that