AUTOMATIC1111's stable-diffusion-webui is a browser front end for running Stable Diffusion image-generation models on your own machine. It wraps model loading, text-to-image, image-to-image, inpainting and upscaling in a Gradio interface served on port 7860, and supports extensions such as ControlNet. The steps below get it running; the later sections explain what happens when you press Generate, which settings matter, the launch flags for different hardware, and common problems.
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui
pip install -r requirements.txt
If some dependencies fail, try installing them manually:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
Run the following command to start the Web UI:
python launch.py
If you encounter the "Torch is not able to use GPU" error, use this command:
export COMMANDLINE_ARGS="--skip-torch-cuda-test"
python launch.py
Once the server is running, the terminal will display a message like:
Running on local URL: http://127.0.0.1:7860
Open your web browser and go to:
http://127.0.0.1:7860
To stop the Web UI, press Ctrl+C in the terminal where it's running.
If you're using a Mac with an M1/M2 chip, run with MPS acceleration:
export PYTORCH_ENABLE_MPS_FALLBACK=1
python launch.py
Stable Diffusion is a latent diffusion model. The prompt is turned into embeddings by a CLIP text encoder. Generation starts from random noise in a compressed latent space (for SD 1.x, a 64x64x4 tensor for a 512x512 image), and a U-Net predicts and removes noise over a series of sampler steps, guided by the text embeddings. Classifier-free guidance compares a prompted and an unprompted prediction at every step and pushes the result toward the prompt by the CFG scale. Finally the VAE decoder expands the latent back into pixels. Working in latent space rather than pixel space is what makes the model small and fast enough for consumer GPUs.
launch.py (or the webui.sh / webui-user.bat wrappers) creates or checks the Python environment, installs pinned dependencies, and starts the Gradio server. Model checkpoints in .safetensors or .ckpt format go in models/Stable-diffusion/ and are selectable from the dropdown at the top of the page; LoRA files go in models/Lora/ and are invoked from the prompt with <lora:name:0.8>. Prefer .safetensors: .ckpt files are Python pickles and can execute code when loaded. Generated images are saved under outputs/ with the generation parameters embedded in the PNG metadata, so the PNG Info tab can restore the exact settings later.
| Setting | What it controls | Typical starting value |
|---|---|---|
| Sampling method | Numerical solver for the denoising steps | DPM++ 2M with Karras schedule, or Euler a |
| Sampling steps | Number of denoising iterations | 20 to 30 |
| CFG scale | How strongly the prompt is followed | 5 to 7; high values oversaturate |
| Width / height | Output size; should match the model's training resolution | 512 for SD 1.5, 1024 for SDXL |
| Seed | Initial noise; same seed and settings reproduce an image | -1 for random |
| Denoising strength (img2img) | How much of the input image is replaced | 0.3 to 0.6 |
Change one setting at a time with a fixed seed when tuning: with the seed held constant, differences between images come only from the setting you changed. The X/Y/Z plot script in the Script dropdown automates this by rendering a grid across, for example, several CFG values and samplers in one run.
# webui-user.sh (Linux/macOS) - set flags once instead of exporting each time
export COMMANDLINE_ARGS="--xformers" # NVIDIA, faster attention
# export COMMANDLINE_ARGS="--medvram" # 4-6 GB VRAM
# export COMMANDLINE_ARGS="--lowvram" # under 4 GB VRAM, slow
# export COMMANDLINE_ARGS="--skip-torch-cuda-test --use-cpu all --no-half" # CPU only
# export COMMANDLINE_ARGS="--listen --port 7860" # reachable from the LAN
./webui.sh
# check that PyTorch sees the GPU before launching
python -c "import torch; print(torch.cuda.is_available(), torch.__version__)"
The CPU-only pip install torch ... /whl/cpu command in step 2 is a fallback; it produces a working install but generation takes minutes per image instead of seconds. On an NVIDIA machine install the CUDA build of PyTorch instead, or let webui.sh install it, and see the NVIDIA setup guide for drivers.
--skip-torch-cuda-test only silences the check; it does not enable the GPU.--medvram, or enable xformers.--no-half-vae.--listen or --share makes the UI reachable by others, including its file and extension features; add --gradio-auth user:pass or keep it on localhost.