Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error(Ошибка): NansException: A tensor with all NaNs was produced in Unet. #15718

Open
bigmother1337 opened this issue May 5, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@bigmother1337
Copy link

bigmother1337 commented May 5, 2024

[RU]Решение ошибки: NansException: A tensor with all NaNs was produced in Unet.
[EN]Bug fix: NansException: A tensor with all NaNs was produced in Unet.
browser_4a5t8angEl

Ошибка: 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 (Путь до файла указан выше на картинке).
explorer_GDIEZ7nYSL
Второе - в самом файле необходимо добавить данные строчки как на картинке:
notepad_58erZrl2FX
Для удобства текст для копирования:
@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
Ну конечно если вы искали решение проблемы, то скорее всего способ выше вам не поможет.
Расскажу способ, который лично я использую и скорее всего он поможет.
При заходе в интерфейс нейронной сети нам нужно её «разогреть», у меня сложилось чёткое мнение, что программа не понимает полные возможности вашего ПК. И поэтому при любом использовании будет давать ошибку. Чтобы переубедить программу ей нужно давать лёгкие настройки для генерации.

  1. Выберете наиболее лёгкий (Sampling method), чаще всего используется Euler a
  2. Sampling steps – выставляйте от 10 до 15 шагов.
  3. Разрешение – по ситуации лучше оставить стандартные 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)
explorer_GDIEZ7nYSL
Secondly, lines like in the picture should also be added to the file:
notepad_58erZrl2FX
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.

  1. Choose an easier Sampling Method, most often it is Euler a.
  2. Sampling steps - from 10 to 15 steps.
  3. 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!

@bigmother1337 bigmother1337 added the enhancement New feature or request label May 5, 2024
@MagyTheMage
Copy link

MagyTheMage commented May 19, 2024

--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,

@bigmother1337
Copy link
Author

--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?

@MagyTheMage
Copy link

MagyTheMage commented May 19, 2024

--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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants