Skip to content

Instantly share code, notes, and snippets.

@looeee
Last active December 17, 2022 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save looeee/b3c325e7878a7423e66f140e40c6f86a to your computer and use it in GitHub Desktop.
Save looeee/b3c325e7878a7423e66f140e40c6f86a to your computer and use it in GitHub Desktop.
Install AUTOMATIC1111/stable-diffusion-webui on Windows

If you check the wiki and readme on AUTOMATIC1111/stable-diffusion-webui you would be forgiven for thinking that installing this will be easy. It's not! There are loads of prerequisites and potential issues that will confuse the hell out of you unless you are already very familiar with running Python ML packages.

We will install AUTOMATIC1111 into in C:\dev\stable-diffusion-webui. But most of this probably applies to other stable diffusion installs too.

WSL

If you're thinking about using WSL, you probably stop thinking that. It seems like there's a bunch of issues that make this way more complicated than installing directly under Linux would be. I wasted several hours on this. You might have more luck but make sure to read the WSL install docs before you start!

We will install directly under Windows.

Prerequites

Install git (latest version is fine) Install Python 3.10.6 (this exact version, if you have another installed then delete it and also delete any pip or python folders in %appData% then install 3.10.6).

VS Build tool.

Install VS Build tools: https://aka.ms/vs/17/release/vs_BuildTools.exe There's lots of options, I checked most of them. I assume you need the C/C++ related tools. I ended up with about 10gb download here.

Install Cuda 11.3

Get it here 2.7gb download. It will warn you that you don't have Visual Studio installed. Unless you do I guess

#3 Install Ninja (optional)

Apparently this will speed up xformers on Windows https://github.com/ninja-build/ninja/releases

Extract ninja.exe to C:/windows or add it to the PATH.

Download the model

Find and download GFPGANv1.4.pth and put it in the base folder. Download your choice of stable diffusion model and put the .ckpt and associated .yaml files in the models/ folder. I'm using 768-v-ema.ckpt so I called the config 768-v-ema.yaml. The ckpt is about 5gb so start downloading now! Get the config here. Get the SD 2.0 model here

Clone the repo

Open a simple non-admin cmd prompt. Don't use Poweshell

cd dev
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui
webui-user.bat

Expect it to fail but it will set up the venv. Didn't fail? wow, lucky you.

Upgrade pip

Not 100% sure if this is required but it will silence some warnings.

C:\dev\stable-diffusion-webui\venv\Scripts\python.exe -m pip install --upgrade pip

Active the Python Virtual Environment

From a non-admin cmd inside C:\dev\stable-diffusion-webui

python -m venv venv
venv\Scripts\activate

You should see the prompt change to:

(venv) C:\dev\stable-diffusion-webui\

pip install cython
pip install pycocotools
pip install sparse_dot_topn
python -m pip install -U pip setuptools
pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu113

(these are supposed to be installed automatically but...)

Xformers package

NOTE: so far any attempt to run with Xformers has totally failed. I did manage to get it to compile using this guide Once I install it, I can launch the web ui but cannot generate any images and each solved cryotic error leads to another cryptic error... so maybe skip this for now. What does xformers do?

Make sure you have VS Build Tools and Cuda installed or this will fail!

SD does run without it though.

These are supposed to be the required steps:

Make sure you are in C:\dev\stable-diffusion-webui
Ensure venv is active venv\Scripts\activate

cd repositories git clone git@github.com:facebookresearch/xformers.git git submodule update --init --recursive pip install -r requirements.txt pip install -e .

OK... now we can run webui-user.bat again!

Run webui-user.bat again from a non-admin cmd prompt. You should see various logs until finally this one:

DiffusionWrapper has 865.91 M params.

At this point it froze. I waited about 5 minutes then I pressed the "enter" key and it moved to the next line:

Downloading... 1%...

Again it froze and again after several minutes I pressed enter and it started downloading. It's another 4gb download so go make a coffee or something.

Once the download completes, you should finally see:

Running on local URL: http://127.0.0.1:7860

Congratulations! You have Stable Diffusion 2.0 running on Windows. Enjoy that coffee, you earned it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment