Here is the Solution to these 5 Frustrating Stable Diffusion Errors

Text to Image AI technology is pretty popular these days. Some known players of this game are MidJourney, DallE, and Stable Diffusion. Unlike DallE and MidJourney, you can install and run Stable Diffusion on your own machine, given it matches the system requirements for the AI model. However, it’s common for users to face Stable Diffusion errors while running it on their machines.

Well, if you are one of the users facing these errors, you are at the right place! In this article, we will explore some common Stable Diffusion errors which can stop you from generating some amazing art. We will also see how you can fix these Stable Diffusion errors so you can keep using the AI model without any further barrier. So without waiting any further, let’s dive in!

Fixing Stable Diffusion Errors

For any of the Stable Diffusion errors demonstrated below, you will have to browse to the location where you have installed the Stable Diffusion Web-UI. Once you are at the right location, look for “webui-user.bat”. Right-click on the file and click “edit”. Next, add the respective arguments to “set COMMANDLINE_ARGS=” as demonstrated below:

stable diffusion error

You can find all command line arguments and settings here.

 

Black Image Error

Black Image is one of the major Stable Diffusion errors which can be annoying at times. However, here is an effective fix for that as well.

Using --disable-nan-check can cause this error, however, persisting the command may result in a normal image.

For NVIDIA GPU, use --xformers to solve black image generation. It is worth noting, you will have to install “xformers”. For that, simply open the terminal by pressing shift + right click and clicking “Open PowerShell window here”. In the terminal, type pip install xformers.

Another way to solve this error is by adding --no-half to the command-line arguments. Usually, this argument can be used with--precision-full or  --precision-autocast. Both --no-half and --precision-full combined, force stable diffusion process in 32-bit floating-point numbers (fp32) instead of cut-off 16-bit floating-point numbers (fp16).

If you wish the opposite processing, you can use --precision-autocast which will then use fp16 wherever possible. Using full precision can possibly give you better results. But as a tradeoff, it will take a bit longer. Stable Diffusion by default uses fp16 wherever possible, to speed up the process, despite the fact that there is less possible variation in outcomes.

 

Unable to Load “safetensors”

If you are unable to load “safetensors” models,  here is the fix. Simply add the following command in “webui-user.bat”:set SAFETENSORS_FAST_GPU=1

It’s worth noting that you will not be able to use safetensors while using --lowramoption argument. On doing so, you will get the following error:

stable diffusion errors

 

Not Enough Memory

stable diffusion errors

Another Stable Diffusion error is “Not Enough Memory”, which occurs when you are running Stable Diffusion on a machine with low VRAM. If your machine has 4 to 6GB of VRAM, adding –lowvram to the command-line arguments will surely fasten the process. If you are running Stable Diffusion on a machine with 8GB of VRAM, add –medvram instead.

Using these commands will prevent the “Not Enough Memory” error from occurring. Your machine’s memory will be conserved at the cost of a slower generation. If the error still persists even after adding the above commands, this means you will have to remove a few of the other options that you added before. You can also add --no-half, if you haven’t already.

 

NansException

stable diffusion errors

On getting the above error, you have to use --disable-nan-check with the other command-line arguments, as mentioned. There are chances that you might encounter this error if you use --opt-sub-quad-attention.

 

Bonus Tips for Better Performance

For running Stable Diffusion on an NVIDIA GPU, it is recommended to install –xformers. We have already discussed how you can do that. xformers will boost Stable Diffusion performance on your machine.

Starting without any of the above-shared arguments can result in faster processing of the images. However, when you encounter any error, you can progressively add the arguments as per the requirements. In my case, along with –xformers, I started with –medvram only, as I have 8GB of VRAM. Later, I added--opt-sub-quad-attention for better performance.

--opt-split-attention or --opt-split-attention-v1 can also be used along with --opt-sub-quad-attention or separately. --opt-sub-quad-attention is considered better than --opt-split-attention for AMD GPUs. However, NaNsException happened to occur on using this, so I added --disable-nan-check.

But after adding that, stable diffusion started to generate black images. To fix that, I had to add --no-half and --precision-autocast.

After using the above shared arguments, never had an error as of writing this article.

 

Conclusion

Text-to-image AI technology is pretty popular these days. As Stable Diffusion is open source, it is a bit different than other AI models of its type like MidJourney, and DallE. However, installing Stable Diffusion on your own machine comes with some errors which can be frustrating at times. This blog provides you with a list of Stable Diffusion errors with their solution which can keep you going.

2 thoughts on “Here is the Solution to these 5 Frustrating Stable Diffusion Errors”

  1. Pingback: 7 Ways to Fix Stable Diffusion Cuda Out of Memory Error

  2. Pingback: Step by Step Guide to Install Stable Diffusion on Windows 10

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top