AI tools

How do you run Stable Diffusion on your own computer?

· By Robert Scales · 4 min read

Short answer

The easiest route is a free community program such as the Stable Diffusion web UI: you install Python and git, download the program and the model weights, and run a start-up script that opens a point-and-click interface in your browser. Everything then runs on your own graphics card, with no account, credits or waiting list.

Stable Diffusion is different from DALL·E 2 and Midjourney in one important way: the model itself is public. Stability AI released the weights, the trained numbers that make up the model, in August, along with the code and a model card. That means you can download it and make images on your own machine, offline, as many as you like.

The official code from the CompVis research group is aimed at researchers and expects comfort with the command line. In the month since the release, volunteers have built friendlier front ends. One of them is the Stable Diffusion web UI maintained on GitHub under the name AUTOMATIC1111. It wraps the model in a browser interface built with a library called Gradio, and adds features such as inpainting, outpainting, upscaling, negative prompts and batch processing.

Before you start

You need three things on your computer:

  • Python, the programming language the software is written in. The web UI's instructions name version 3.10.6.
  • git, a tool for downloading and updating code projects.
  • The model weights, a single checkpoint file a few gigabytes in size. Stability AI recommends version 1.4. The weights are published through the CompVis page on Hugging Face under the CreativeML OpenRAIL-M licence, so read that licence when you download them.

Installing the web UI on Windows

These are the steps from the project's README:

  1. Install Python 3.10.6 and, during setup, tick the box Add Python to PATH, which lets other programs find it.
  2. Install git.
  3. Download the web UI by opening a command prompt and running:
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
  1. Rename your weights file to model.ckpt if needed and place it in the models folder inside the new stable-diffusion-webui folder.
  2. Optionally, add the GFPGAN file, a separate model that repairs faces, as described on the project's wiki.
  3. Double-click webui-user.bat as a normal user, not as administrator.

When the script has finished starting up, open the browser interface it runs on your machine.

On Linux, the README asks you to install wget, git and Python 3 with your package manager and then run a single setup script. Apple Silicon Macs and AMD graphics cards have their own instruction pages on the project's wiki. If you have no suitable computer at all, the project also links to a Google Colab notebook, which runs the same interface on Google's servers.

Your first image

The model was trained on 512 by 512 pixel images, so keep that size for your first tries. In the txt2img tab, type a prompt such as:

Prompt
a cozy reading nook by a rainy window, warm lamp light, oil painting

Leave the other settings at their defaults and click Generate. For comparison, the official reference script uses 50 sampling steps and a guidance scale of 7.5, which controls how strongly the image follows your prompt. Once you have a result you like, note its seed, the number that sets the starting noise; reusing it lets you change one word at a time and see what that word does. The web UI also writes the generation settings into the PNG file as text, so every image carries its own recipe.

Try it: Generate the reading-nook prompt four times with random seeds, pick your favorite, then fix its seed and change only "oil painting" to "watercolor" and "pencil sketch". Keep all three images and compare them.

Licence and safety notes

Running a model at home does not remove its rules. The CreativeML OpenRAIL-M licence permits commercial and non-commercial use but makes you responsible for using the model ethically and legally, and it contains specific restrictions on harmful uses. If you share the model or build a service on it, the licence has to go with it.

The official package includes an AI-based safety classifier that filters out unwanted outputs by default, and its settings can be adjusted. The CompVis reference script also adds an invisible watermark so that images can be identified as machine-generated. Community interfaces may handle these features differently, so check what your chosen program does before you share its images. The CompVis team also notes that the model mirrors biases in its training data.

What hardware do you need?

The key part is the graphics card, or GPU, and specifically its video memory (VRAM), because the model must fit inside it while it works. Stability AI says the released model should need about 6.9 GB of VRAM and recommends NVIDIA chips for now, with optimizations for AMD and Apple's M1 and M2 chips promised. The CompVis README gives a more conservative figure for its reference script: a GPU with at least 10 GB of VRAM.

Community tools have pushed that lower. The web UI lists support for 4 GB video cards among its features. In practice, then, an NVIDIA card with 8 GB or more clears Stability's figure with room to spare, a card with 4 to 6 GB depends on the web UI's low-memory support, and a computer without a dedicated GPU is better served by the Colab notebook or a hosted service.

Beyond the GPU, you need enough free disk space for the software, the checkpoint file of several gigabytes and the images you create. A faster card shortens each image, but even a modest one turns a prompt into a picture on your own desk, with no credits to count.

Sources

  1. Stable Diffusion web UI (README at commit of 22 September 2022) — AUTOMATIC1111 on GitHub, September 22, 2022
  2. Stable Diffusion Public Release — Stability AI, August 22, 2022
  3. CompVis/stable-diffusion (README) — CompVis (LMU Munich) on GitHub, August 22, 2022

Get the free Guide to Artificial Intelligence

Sign up for the weekly newsletter and receive the free guide: what changed in AI this week, one lesson, one prompt to try. Unsubscribe in one click.

How we handle your address

Back to top

Display

Your choices are saved in this browser only. No data is sent.

Text size
100%
Colours
Reading
More settings
Accessibility statement