How to install Stable Diffusion on a PC? | Installation and Troubleshooting guide for stable diffusion Automatic1111

Are you one of those guys wondering how to install Stable Diffusion on a PC and still haven’t gotten the answer yet? Well, you have come to the right place. In this article, I am gonna guide you step by step on stable diffusion installation.

This stable diffusion install guide is going to help you with everything, from installation to troubleshooting problems faced after installing stable diffusion automatic1111 webui. If you are wondering if it’s worth the trouble let me give you a few points on why you should install Stable Diffusion on your system.

If you have already installed stable diffusion then you should read these articles:
1. How to install and use controlnet
2. How to upscale images on stable diffusion
3. Stable diffusion Tips and Tricks to get great images in 2023

Table of Contents

Why should you install Stable Diffusion AI on your system?

  • You can get better images than any AI art image generator available online.
  • You can generate unlimited images for free, that isn’t the case with good generators available online
  • You can upscale your old images for free using Stable Diffusion locally.
  • Highly customizable -You can customized the kind of images you want to make if stable diffusion is run locally.
  • You can train your own model with your images if you install stable diffusion locally and produce unlimited fantasy art which includes you. Isn’t it awesome?
  • You can even train your own model to generate a specific kind of art. There is a stable diffusion model trained on generating Anime art or there is a model trained on the Spiderman universe.
  • It works even offline. Yes you heard it right Stable diffusion works offline.
  • Running stable diffusion locally is far more convenient. Local stable diffusion can be run anywhere and anytime without having to worry about internet connection. So, install stable diffusion if your pc has the required specs and enjoy making art 🙂
  • If you install stable diffusion, you can train embeddings too they are small files trained on small set of images if you have a powerful pc.
  • There are so many models to choose from if you install stable diffusion locally. Different artstyle different models, that’s how good it is. stable diffusion downloaded models can be switched in stable diffusion webUI simultaneously.
  • Your one prompt can generate so many styles just by switching to different downloaded stable diffusion models

So, if you’re wondering how to install stable diffusion locally? This is where you start. After following my steps carefully you will be able to run stable diffusion locally.

How to Install Stable Diffusion on a PC?

There are two ways to install stable diffusion, but my preferable way is second one.

First Way to Install Stable diffusion Automatic1111 webUI on a PC

Install Python 3.10.6, checking “Add Python to PATH”. Download this version as Stable Diffusion is tested with this version of python, and I am using this version only. The other version hasn’t been tested. If you want to, you can test it on your own. Install git.

Download the stable-diffusion-WebUI repository, for example by running git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git or you can download it as a zip file as shown in the screenshot Below

How to install Stable diffusion on a PC - stable diffusion install
Download the ZIP file from here

After you have downloaded the ZIP file, extract it to your desired location and click on the webui-user.bat file.

install stable diffusion download folder
The file you have to click is highlighted in green

It will start to download a few files on its own then. Give it some time. The time taken in this process will depend on the speed of your connection. This process will install Stable diffusion offline It will show a screen like this :

Stable diffusion installation progress screenshot
Stable diffusion installation progress screenshot

Requirements before stable diffusion installation – Stable diffusion, VAE and restoration models

Stable diffusion Models download

While this process is happening in the background use this link for downloading stable diffusion. Now you must be wondering which file to downloading, if you have less powerful GPU like GTX series and less than 4GB or equal to 4GB VRAM then you should use this v1-5-pruned-emaonly.safetensors version of stable diffusion to download, as safetensors stable diffusion models generally take less time to load on slow machines. People with powerful machines can use any model but always remember safetensors are virus free so prefer safetensors stable diffusion models to download no matter which custom model are you using.

You can also use civit ai website to download custom models, but beware you might find a bit of adult content on that site so click at your own discretion. My recommended models which i personally use would be deliberate and dreamshaper models. All these are custom stable diffusion models which are available for download on civit ai website.

Stable diffusion VAE download

VAE is an autoencoder which uses less input to produce the accurate output which in the absence of VAE must have taken a long prompt to get the same output. Download VAE from here.

Face Restoration models download for stable diffusion

Stable diffusion uses two face restoration models one is codeformers and gfpgan. Face restoration models will auto download when you start using restore faces option on the automatic1111 webUI or else you can download the gfpgan model before hand.

The stable diffusion models you downloaded should be put it in the stable-diffusion-webui\models\Stable-diffusion folder. Remember to not put any spaces while naming the folders else it will not work.

VAE file should be kept in stable-diffusion-webui\models\VAE

Once your system has finished stable diffusion install then you should be ready to launch the program by clicking on webui-user.bat in the folder. The screen should show something like this and I will explain the thing in the text highlighted in red later in the article. This text highlighted in red will not be on your launching screen

stable diffusion starting after completion of stable diffusion install
stable-diffusion-launching-screen

After the process of loading models has been completed it will show Running on the local URL: https://127.0.0.1:7860 You just have to put the URL https://127.0.0.1:7860 in your chrome or whatever browser you are using. Remember this URL will only work after the webui.user.bat programmed has launched successfully and it shows the URL, else it will show the connection error. After putting the URL 127.0.0.1:7860 in your browser, you should see something like this :

Stable diffusion webui
Stable diffusion interface

Now Enjoy creating AI images for free on your own. If it works for you perfectly, you are able to create images then fine you can close the window, but if you are facing problems like I faced when I first time used the stable diffusion you should keep reading and let me give you guys simple tips.

Second Way to Install Stable Diffusion Automatic1111 WebUI – The git clone method Preferred

This is almost similar to the one first all you have to do is just copy and paste
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git this code into your command prompt window and press enter and the rest of things will installed automatically, then follow rest of the steps like I have described above.

How to install automatic1111 webUI

Stable Diffusion Problems and Troubleshooting

Let’s talk about the problems I faced first

Problem

  1. Black Images: I was getting black images no matter what my text input was.
  2. Low VRAM issues

Stable diffusion Troubleshooting

Stable diffusion webUI Black Image

When I tried my first prompt on the stable diffusion webUI I was getting black images and then I tried many prompts but the results were the same. Then I did some digging and found out it’s an issue with some of the Nvidia Graphics cards. The Green or black screen is common in the 16xx series graphic cards. This is how i fixed stable diffusion webui’s black image problem –

There are two solution to fix stable diffusion black image problem

  1. Copy this exactly –precision full –no-half and paste it where I have pasted it in the screenshot below also.
  2. You can only use –medvram or –lowvram(depends on your VRAM or Graphics card memory) –opt-split-attention.

The second solution works for the most people. If it doesn’t just copy paste everything as I have shown in the next segment.

Low VRAM issues while running Stable diffusion

If you have VRAM less than or equal to 4GB then you should also paste –lowvram in the argument. In my testing sometimes medvram argument works sometimes it doesn’t work for me as I have a 4GB graphic card. If you have a 6GB graphics card then you can use –medvram argument. If you want to make larger images than 512 x 512 which is a squared size image then you should use –lowvram –opt-split-attention. Here is how you should do this:

  • Go to your stable diffusion folder, and locate webui-user.bat file.
  • Right click on the file and click the edit button.
  • A notepad file will open.
  • Paste everything in front of this set COMMANDLINE_ARGS=
  • Save the file and close the notepad window.
  • Run the webui-user.bat file again and now your program should run fine.
Stable diffusion install
Stable diffusion trouble shooting
Stable diffusion webUI black image
Stable diffusion trouble shooting 2

NOTE for users with 4GB VRAM – If you use –precision-full –no-half argument your image generation will be a lot slower, using –no-half alone will produce images faster but you can’t create images more than 512×512 resolution. My current setting is --autolaunch --opt-split-attention --xformers --medvram

Slow Image generation on Stable diffusion Automatic1111 webui?

You may experience or have been experiencing slow image generation on stable diffusion. Here’s how to fix slow image generation on Stable diffusion Automatic1111 webUI interface. You need to again edit the file as i showed in the screenshot above, You can remove –precision full –no-half and add –xformers as shown below in the image, Removing –precision full –no-half will increase the speed of image generation on stable diffusion. using xformers command has shown to improve slight improvement in the speed.

Using specific Samplers to improve art generation speed on Stable diffusion

In my testing I have found that DPM++2M Karras, UniPC and DDIM were the fast samplers for generating images on stable diffusion and Euler a sampler is at second place regarding the speed. You will have to keep to keep in mind that UniPC uses DDIM while using highres fix on stable diffusion. For improving your image generation on stable diffusion, i have written an extensively researched article here

Fastest way to use stable diffusion if you don’t have a powerful system

If you don’t have a powerful Pc or a laptop and don’t want to use any of the websites for stable diffusion then there is a work around for that. All you need to do is click on this link and it will take you to google colab stable diffusion repository.
Then you have to go to runtime and click on run all and when the process is finished you will see a link at the end of the page. Click on the link and the automatic1111 interface will open just like the one I have posted above. I have noticed colab is blocking free access recently in may 2023

install stable diffusion without powerful laptop or pc, screenshot from google colab automatic1111 fast stable diffusion repository

Conclusion

So, there you go, you have installed stable diffusion and you can use stable diffusion offline now. Enjoy creating art with locally installed stable diffusion.

You can use extensions for improving stable diffusion art and one such extension is controlnet which when used with stable diffusion can be a massive leap in the field of Text to image generation. You can find the full tutorial here

If you have any questions or queries regarding installation, just comment them down below and I will try to answer them or redirect you to the websites where you can find the answers to your queries. Thank you for reading the article.

In case, you are in a dilemma about this whole AI art thing and probably thinking whether AI art is really art, and what is the future of human-made art, I recently wrote an article on this topic. If you are interested you can go to this link and read my article. Thank you.

FAQ

Is it necessary to download stable diffusion models?

Yes, it is necessary to download stable diffusion models after the installation of automatic1111 or any GUI you are using.

Which websites are best to download stable diffusion models?

Currently Civit AI has the vast variety of models to choose from, hugging face is another website.

How much VRAM is required to run Stable Diffusion on a windows PC?

Minimum 4GB of VRAM is required to run stable diffusion locally

How much RAM is required to run stable diffusion program smoothly?

My recommendation is 16GB minimum, but I have ran stable diffusion even on 8GB of ram, but you can’t run any program with it or your PC will freeze

Is VAE necessary for stable diffusion models to run?

No, you can run any stable diffusion models without VAE but results might be bad or different.

Can I use higher version of Python to run Automatic1111 stable diffusion?

As the official document says that they have tested it on Python 3.10, you can try installing Python newer versions but chances are it will not work properly

Can you train textual inversions on 4GB VRAM?

Absolutely not, You need at least 8GB of VRAM

Can I generate images larger than 512×512 on automatic1111 stable diffusion on a PC with less than 4GB VRAM?

Yes, you can generate large images, use –xformers –medvram in your argument as guided in the article. However, speeds might be slower.

Can I install stable diffusion automatic1111 on a PC with AMD GPU?

Yes, you can but there are compatibility issues, there are several workarounds being build around AMD GPUs, you can check those out

Which GPUs are supported to run stable Diffusion?

Any NVIDIA GPU above 1050 with minimum 4GB VRAM. I have ran stable diffusion on 1050 and it worked fine.

Leave a Reply

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