How to Install Stable Diffusion Locally (Easy Guide)

If you like using text-to-image AI tools, you've surely heard of Stable Diffusion. It's one of the few AI models that really attracted a ton of attention when it comes to image generation. Along with ...

If you like using text-to-image AI tools, you've surely heard of Stable Diffusion. It's one of the few AI models that really attracted a ton of attention when it comes to image generation. Along with Midjourney and DALL-E, it's among the best AI models for creating images from words.

The best part about Stable Diffusion is that you can run it locally. I know that the installation process is complicated for some people, which is why I decided to write this guide. Today, you'll learn how to run the Stable Diffusion model locally on your PC without having to do hours of research.

I wanted to make this guide as easy as possible so that you can set everything up quickly. Before I get to the guide, I want to take a quick minute to talk about Stable Diffusion for readers who may not be familiar with it.

install stable diffusion locally

What Is Stable Diffusion?

Stable Diffusion represents what's called a latent diffusion model. It enables users to easily create images from text. Just like Midjourney and DALL-E, Stable Diffusion has managed to attract a big and dedicated community that experiments with various concepts every day.

What separates Stable Diffusion from nearly all other text-to-image models is that it's under an open-source license. The code and model weights have been released to the public. Another amazing feature of this model is its ability to run locally on your computer. The best part about it is that it can run on most consumer hardware.

This is very different from text-to-image models like Midjourney and DALL-E, which are accessible only through cloud services. In some of my previous articles, I've talked about the Runway AI video generation platform. But did you know that the Runway research company co-created Stable Diffusion?

One thing I want to make clear before I move on to the installation guide is that you can also access Stable Diffusion via the cloud. Users have the option to use a cloud-based version, and it comes with some benefits like faster image generation. But I'll talk about that more another time. Today, I'm focusing solely on how to run this AI model locally.

How to Run Stable Diffusion Locally

What I'm about to show you may seem complicated to some people. But rest assured that all you have to do is follow the steps laid out in this guide and you'll quickly complete the installation process.

Prepare for the Installation

The first step of the whole process is to create an account on Github.

creating github account

If you're not familiar with this platform, it's essentially what developers use to create software and contribute to the open-source community. If you already have a Github account, you can skip this step.

Simply press the 'Sign Up' button in the upper right corner of the website and it will take you to a page where you can create an account in less than a minute. I created a new account just to show you what the process looks like.

creating github account 2

You'll be asked to enter your email, create a password, come up with a username, and solve a captcha. It's really easy and shouldn't take more than a minute or two.

The second step is to create an account on Hugging Face. This is a platform that was created in 2016 and represents a place where the community can help users build, train, and deploy machine learning models. You'll see why you need an account on this website later on in the article.

creating hugging face account

It's really easy to create an account on Hugging Face. It took me around 30 seconds. You won't have to pay a subscription for any of the two websites mentioned above.

Downloading the Right Tools

The easiest part of the installation process is complete. You now have accounts on both Github and Hugging Face. The next step of the process is to download a few software programs.

I suspect that most of my readers use Windows, in which case you're going to need to download Git for Windows. This is a free and open-source distributed version control system. You're going to need it to install the Stable Diffusion local client.

download git for windows

Simply head over to the official Git for Windows website and press the download button. It'll likely take only a few seconds for the software to download.

Go to the folder where the program was downloaded and start the installation process. The only thing I recommend you do is uncheck the 'Windows Explorer integration' button. Once you do that, you can simply press the 'Next' button until the installation is finished. You'll have to press this button several times.

installing git for windows

After the setup is complete, press the button to launch Git for Windows. Now, you'll need to go to your C drive and make a folder called 'Stable'. Of course, I'm just giving an example with the name. You can name the folder however you like.

You can now select the folder and click on the 'Copy' button. Go to the Git program and type in cd, press the space button one time, followed by right-clicking on the program and clicking the 'Paste' button.

installing git for windows 2

All you have to do now is press the 'Enter' button on your keyboard.

Download Automatic1111 For Stable Diffusion

Once you've finished the previous step, you'll now need to copy the code to the Stable Diffusion Web UI on Github (Automatic1111). I linked this page so that you don't have to search for it yourself.

automatic1111 stable diffusion

This is where you'll need to go to copy the code. Simply press on the green 'Code' button and then hit copy right next to the link. Now, you can go back to the Git for Windows program and type in 'git clone' followed by pressing the space button and pasting the link you copied from Github. Press the 'Enter' button once you've done everything I mentioned in this paragraph.

git clone stable diffusion

It takes less than a minute for this whole process to be finished. You now see why it was important to create a GitHub account.

How To Get Stable Diffusion

The next part of the process involves navigating to the Hugging Face website to find the newest version of Stable Diffusion. At the time of writing this article, the latest version is 2.1 and can easily be found on the Hugging Face website.

downloading latest stable diffusion

What you'll need to download from this website is pictured in the image above. The file you're downloading here is around 5 gigabytes, so it might take 10-20 minutes to download depending on your internet speed.

It's good that there are other actions you need to take while the download is in progress. You'll need Python installed on your computer to run Stable Diffusion locally.

installing python for stable diffusion

I initially downloaded the latest version of Python (3.11.5) but when I tried to run the Stable Diffusion installation, I got an error message saying that I should use the 3.10.6 version. So, I got the 3.10.6 Python version, which was released in August 2022. This file is only 25 megabytes so it should be downloaded in a few seconds.

installing python for stable diffusion 2

You're going to have to make sure that the 'Add python.exe to PATH' box is checked before you start the installation process. After you check the box, press the 'Install Now' button. It took around 30 seconds for the installation to be finished on my laptop.

Install Stable Diffusion Locally

The preparation process takes up the most time, so if you've made it this far know that you're only a few easy steps away from running Stable Diffusion locally.

By this time, you should have set up a Github account and a Hugging Face account. You also should have downloaded the latest version of Python, the Git for Windows client, the Stable Diffusion Web UI, as well as the latest Stable Diffusion model.

So, the latest Stable Diffusion version (the .ckpt file) has finished downloading. What now?

install stable diffusion on pc 1

The next step in this installation process is to go to the 'Stable' folder and then enter the 'models' subfolder pictured in the image above. When you're in the 'models' folder, you'll see a subfolder called 'Stable-diffusion'. This is where you'll need to move the .ckpt file.

install stable diffusion on pc 2

Now, it's easy to get the main installation started. You simply go back to the 'stable-diffusion-webui' folder and double click on the Windows Batch File called 'webui-user'. Make sure you don't click on the Shell Script file with the same name.

install stable diffusion on pc 3

One double click on the Windows Batch File and the installation will finally begin. Make sure you don't click on the program while it's installing because that can pause the installation process.

Depending on the speed of your computer, this process might take between 20-40 minutes. This would be a good time to think about what types of prompts you'll write when you start using the AI model.

install stable diffusion on pc 4

When the installation is complete, you'll notice a URL address as seen in the image above. Copy this address and paste it in an internet browser. You'll now have local access to Stable Diffusion.

stable diffusion user interface

The installation process is now complete and you can start writing prompts. You can also expect a lot of different articles from me showing you how to write prompts for Stable Diffusion.

Final Thoughts

It might seem like it's a complicated task to get Stable Diffusion running locally, but it's a relatively simple process that just takes a bit of time. You will have to complete several steps, including registering on two websites and downloading two pieces of software.

The good news is that the registrations and downloads won't take up too much of your time. You can also step away from the computer once the main Stable Diffusion download is in progress.

You should do this only if you specifically want to run Stable Diffusion locally. There is also the option to use it online, in which case you won't have to download anything but instead subscribe to a service.

Leave a Comment