We will go through how to download and install the popular Stable Diffusion software AUTOMATIC1111 on Windows step-by-step.
Stable Diffusion is a text-to-image AI that can be run on a consumer-grade PC with a GPU. After this tutorial, you can generate AI images on your own PC.
Systems requirements
Your PC should run Windows 10 or higher with a discrete Nvidia video card (GPU) with 4 GB VRAM or more. An integrated GPU will not work.
If your PC does not meet these requirements, alternatives are
- Fully managed A1111 service – Think Diffusion. (Affiliate link, you get 20% extra credits.)
- Cloud service – Google Colab.
- Mac Apple Silicon M1/M2.
Installing on AMD GPU
AUTOMATIC1111 does not officially support AMD GPUs, but it is possible to make it work if you are tech-savvy or willing to try. See the unofficial installation guide on the official GitHub page.
Installation steps
Step 1: Install python
You will need Python 3.10.6. (DON’T use Python 3.11 or newer) There are two ways to install Python on Windows
Option 1: Install from the Microsoft store.
Option 2: Use the 64-bit Windows installer provided by the Python website. (If you use this option, make sure to select “Add Python to 3.10 to PATH“)
I recommend installing it from the Microsoft store.
First, remove all Python versions you have previously installed. You can do that in Control Panel → Add or remove programs.
Visit Python 3.10 on Microsoft Store and install the Python software.
This step is most likely to go wrong. Let’s do a check.
Press the Windows key on your keyboard and type “cmd” to find a program called “Command Prompt”.
Open the Command Prompt App. You should see a black terminal like you are a hacker…
Type “python” and press Enter. You should see you see it prints out Python 3.10. This tells you your Python is installed correctly.
Now you can close the Command Prompt App.
Don’t proceed to the next step until you get Python 3.10 installed correctly.
If you don’t see Python 3.10 running, try
- Restarting the PC
- Removing all the previous versions of Python and reinstalling from the Microsoft Store
- If the one from Microsoft Store doesn’t work for you, remove it and try the one on the Python website.
Step 2: Install git
Git is a code repository management system. You will need it to install and update AUTOMATIC1111.
Go to this page to download the windows version.
Open the installer. Click Install to accept the license and install the software.
Follow the instruction to complete the installation.
Step 3: Clone web-ui
This step downloads the Stable Diffusion software (AUTOMATIC1111).
Press the Window key (It should be on the left of the space bar on your keyboard), and a search window should appear. Type cmd
.
Click on Command Prompt. The command prompt window would show up.
First, make sure you are in your home folder by typing the following command and then pressing Enter. (Tip: You should be able to use right-click to paste in Command Prompt.)
cd %userprofile%
You should see your prompt shows something like C:UsersYOUR_USER_NAME
>.
Next type the following command and press Enter to clone the AUTOMATIC1111 repository.
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
A folder called stable-diffusion-webui
should be created in your home directory.
It’s ok to clone the repository in a different folder instead of %userprofile%
, as long as you can find the newly created stable-diffusion-webui
folder. You will need to change the folder location accordingly in the following steps.
Step 4: Download a model file
Next, go to the newly created folder in File Explorer. Put in
%userprofile%stable-diffusion-webui
in the address bar and press enter.
Navigate to the folder models and then Stable-diffusion. You should see a file Put Stable Diffusion checkpoints here.txt
like below.
Download the Stable Diffusion v1.5 model checkpoint file (download link). Put it in that folder.
Step 5: Run webui
Now in File Explorer, go back to the stable-diffusion-webui
folder. That is, go back up two levels or type
%userprofile%stable-diffusion-webui
again in the address bar.
Find a file called webui-user.bat
. Double-click to run and complete the installation.
This last step is going to take a while. When it is done, you will see a message
Running on local URL: http://127.0.0.1:7860
like the one below.
In your web browser, go to the URL
http://127.0.0.1:7860/
You should see the AUTOMATIC1111 webui! Put in a prompt (e.g. “a cat”) and hit Generate to test if Stable Diffusion is running correctly.
When you are done using Stable Diffusion, close the cmd
black window to shut down Stable Diffusion.
To rerun Stable Diffusion, you need to double-click the webui-user.bat
.
Options
You can speed up Stable Diffusion with the --xformers
option. If you have less than 8 GB VRAM on GPU, it is a good idea to turn on the --medvram
option to save memory to generate more images at a time.
To enable them, right-click on the file webui-user.bat
and select Edit. (You may need to select “Show More Options” first if you use Windows 11).
Replace the line
set COMMANDLINE_ARGS=
With
set COMMANDLINE_ARGS=--xformers --medvram
Save and close the file.
Double-click the webui-user.bat
file to run Stable Diffusion.
Additional arguments
Use the argument --gradio-img2img-tool color-sketch
to enable the color sketch tool, which could be helpful in img2img.
If you want to use the computer as a server and access the GUI with another computer, use the argument --listen
to enable a connection from another computer. You will need to set the firewall appropriately on the server, and this is beyond the scope of this installation guide.
Next Step
That’s it! I hope you will have fun making AI images.
If you are new to Stable Diffusion, check out the Quick Start Guide for some quick tips to use Stable Diffusion.
Head to our beginner’s series to learn Stable Diffusion step by step.
Check out this prompt generator for building high-quality prompts.
RTX 4000 series graphic cards
Good news for you if you use RTX 4070, RTX 4080 or RTX 4090 Nvidia graphic cards. The latest version of AUTOMATIC1111 supports these video card. (with torch 2.0 and cuda 11.8)
I will provide a benchmark speed so that you can make sure your setup is working correctly. The settings are:
- batch size: 4
- batch count: 10
- Image size: 512×512
- Sampling steps: 20
- Sampling method: Euler a
- Model: SD v1.5
Using a batch size of 1 is not recommended, as the measured speed is likely to be highly dependent on other components on your system.
You should see the speed of generating each image. Pick a stable value, usually in the middle like the 5th batch. The speed is in it/s (iterations per second).
You should get about 10 its/s on RTX 4090. (Note that this is 4 images per iteration) This is the max speed you can get nowadays.
You can use one of the following speed-up parameters.
Option 1:
--xformers
Option 2:
--opt-sdp-no-mem-attention --no-half-vae --opt-channelslast
Option 2 is slightly faster, but test them out to see what works best for you.
Updating AUTOMATIC1111
By default, your copy of AUTOMATIC1111 won’t be automatically updated. Given how fast things are moving, you will likely need to update your copy at some point to use the latest and the coolest.
There are two options for updating it. (1) Updating every time when you run it, and (2) Updating only when needed.
Updating every time you run
To update whenever you run webui, edit the file webui-user.bat
. Add “git pull” before the line calling webui.bat. The file should look something like
@echo off
set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=--xformers --medvram
git pull
call webui.bat
From now on, webui will update itself every time it starts.
Updating as needed
It may not be a good idea to use the latest version because something could be broken. Updating periodically or only if you need a new feature is a more prudent approach.
To update the webui, open Command Prompt (cmd) and go to webui’s directory using the command below. (You will need to change %userprofile%
if you installed it somewhere else.)
cd %userprofile%stable-diffusion-webui
And run the command
git pull
Resetting webui
If git pull shows an error, it is usually because you have accidentally changed some files. You can reset the webui folder with the following two commands.
cd %userprofile%stable-diffusion-webui
git checkout -f master
And then run git pull again.
git pull
Note that all files will be reset. You will need to make changes to webui-user.bat
again.
Reverting back to a previous version
Sometimes the latest version of webui is broken, and you don’t want to use it. You can revert back to a previous version by following the instructions below.
Step 1: Go to this page to view previous versions. Each row is a previous version.
Step 2: Pick a previous version you want to revert back to. You can look at the date and comment to make a judgment.
Step 3: Press the copy button to copy the hash code of the version.
Step 4: In the command prompt, run the following commands. The hash code (highlighted below) is just an example. You will paste the one you just copied.
cd %userprofile%stable-diffusion-webui
git checkout 076d624a297532d6e4abebe5807fd7c7504d7a73
If you see errors, reset the webui (see the previous section) and retry.
After checking out the previous code, delete the venv
folder and restart WebUI.
Frequently Asked Questions
AUTOMATIC1111 does not start after updating.
Delete the venv
folder and restart AUTOMATIC1111.
If it still doesn’t work, delete both the venv
and the repositories
folders and restart.
If it still doesn’t work and you have recently installed an extension, delete the folder of that extension in the extensions
folder. Delete the venv
folder and restart.
Does it work on AMD GPU?
No, you have to have an NVIDIA GPU.
What Python version should I use?
Python 3.10.6. Later versions of 3.10 work fine. But don’t use 3.11 or later.
How to resolve NaN errors when generating images?
Add --no-half
argument to webui-user.bat (See Adding arguments)
How to resolve out-of-memory errors?
Use --lowvram
instead of --medvram
argument in webui-user.bat (See Adding arguments)
For optimizing memory usage for SDXL models:
- Nvidia (12GB+)
--xformers
- Nvidia (8GB)
--medvram-sdxl --xformers
- Nvidia (4GB)
--lowvram --xformers
See this article for more details.
Python doesn’t work correctly.
Try removing the previously installed Python using Add or remove programs.
There are two options for installing Python listed. Try the other one if the one you used didn’t work.
Is there an easier way to install AUTOMATIC1111?
The above is the official install instructions. Two alternatives:
- Recently they started to tag release builds. They are supposed to work after downloading and unzipping.
- There’s an unofficial easy installer for Windows you can try.
I tried everything, but it still does not work.
You can use Google Colab to run AUTOMATIC1111. This is what I use. The notebook launches AUTOMATIC1111 with one mouse click.
Or Use AUTOMATIC1111 online.