Stable Diffusion WebUI
Stable Diffusion WebUI (commonly referring to AUTOMATIC1111’s stable-diffusion-webui project) is the most popular graphical interface for Stable Diffusion. It offers rich features including text-to-image (txt2img), image-to-image (img2img), upscaling, ControlNet, and more. It is accessible through a browser and well-suited for deployment on GPU servers for team use.
System Requirements
Section titled “System Requirements”- CentOS Stream 9 & 10 / AlmaLinux 9 & 10 / Rocky Linux 9 & 10
- Python 3.10 or 3.11 (EL 10 defaults to Python 3.12, but SD WebUI recommends 3.10/3.11, so an older version must be installed manually)
- Git
- NVIDIA GPU with at least 6 GB VRAM (8 GB or more recommended)
- NVIDIA drivers and CUDA installed (see NVIDIA Drivers and CUDA)
- At least 20 GB disk space (model files are large)
Pre-Installation
Section titled “Pre-Installation”Install System Dependencies
Section titled “Install System Dependencies”sudo dnf install -y git python3.11 python3.11-devel python3.11-pip \ gcc gcc-c++ make wget \ libffi-devel openssl-devel bzip2-devel \ mesa-libGLVerify GPU Environment
Section titled “Verify GPU Environment”nvidia-smiMake sure the output shows your GPU model and driver version.
Create a Dedicated User (Optional but Recommended)
Section titled “Create a Dedicated User (Optional but Recommended)”sudo useradd -m -s /bin/bash sdusersudo su - sduserInstalling Stable Diffusion WebUI
Section titled “Installing Stable Diffusion WebUI”Clone the Repository
Section titled “Clone the Repository”cd /optsudo mkdir -p stable-diffusionsudo chown $(whoami):$(whoami) stable-diffusioncd stable-diffusion
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.gitcd stable-diffusion-webuiDownload Models
Section titled “Download Models”You need at least one Stable Diffusion model checkpoint file. Download a model from Hugging Face or Civitai and place it in the models/Stable-diffusion/ directory:
# Download Stable Diffusion v1.5 (approximately 4 GB)wget -P models/Stable-diffusion/ \ https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
# Or download SDXL Base (approximately 6.5 GB)wget -P models/Stable-diffusion/ \ https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensorsFirst Launch
Section titled “First Launch”The WebUI launch script will automatically create a virtual environment and install all Python dependencies:
cd /opt/stable-diffusion/stable-diffusion-webui
# Launch using Python 3.11python3.11 launch.py --listen --xformersParameter descriptions:
--listen: Listen on all network interfaces (default is 127.0.0.1 only), allowing remote access--xformers: Enable xformers acceleration, reducing VRAM usage and speeding up generation
The first run will download and install a large number of dependencies, which may take 10-20 minutes depending on network speed.
Once installation is complete, you will see output similar to:
Running on local URL: http://0.0.0.0:7860Common Startup Parameters
Section titled “Common Startup Parameters”python3.11 launch.py \ --listen \ --port 7860 \ --xformers \ --enable-insecure-extension-access \ --api \ --medvram| Parameter | Description |
|---|---|
--listen | Listen on all interfaces |
--port | Specify port number |
--xformers | Enable xformers memory optimization |
--api | Enable REST API endpoint |
--medvram | Medium VRAM optimization (recommended for 6-8 GB VRAM) |
--lowvram | Low VRAM optimization (for 4-6 GB VRAM) |
--enable-insecure-extension-access | Allow installing extensions from the WebUI |
--gradio-auth user:pass | Set access username and password |
--no-half-vae | Try this parameter if generated images are black |
Basic Usage
Section titled “Basic Usage”Accessing the WebUI
Section titled “Accessing the WebUI”Open http://your-server-ip:7860 in your browser.
Text-to-Image (txt2img)
Section titled “Text-to-Image (txt2img)”- Select the loaded model at the top
- Enter English prompt words in the Prompt box describing the image you want to generate
- Enter elements you do not want in the Negative Prompt box
- Adjust parameters:
- Sampling method: DPM++ 2M Karras or Euler a recommended
- Sampling steps: 20-30 steps
- Width/Height: 512x512 recommended for SD 1.5; 1024x1024 recommended for SDXL
- CFG Scale: 7-12
- Seed: -1 for random
- Click Generate
Image-to-Image (img2img)
Section titled “Image-to-Image (img2img)”Switch to the img2img tab, upload a reference image, fill in the prompt, adjust the Denoising strength (0.3-0.7), and click Generate.
API Calls
Section titled “API Calls”When launched with the --api parameter, you can generate images via the HTTP API:
curl -X POST http://localhost:7860/sdapi/v1/txt2img \ -H "Content-Type: application/json" \ -d '{ "prompt": "a beautiful sunset over mountains, photorealistic", "negative_prompt": "blurry, low quality", "steps": 25, "width": 512, "height": 512, "cfg_scale": 7 }'API documentation is available at http://your-server-ip:7860/docs.
systemd Service
Section titled “systemd Service”Create a systemd service for management and auto-start:
sudo tee /etc/systemd/system/stable-diffusion.service > /dev/null <<'EOF'[Unit]Description=Stable Diffusion WebUIAfter=network-online.targetWants=network-online.target
[Service]Type=simpleUser=sduserGroup=sduserWorkingDirectory=/opt/stable-diffusion/stable-diffusion-webuiExecStart=/usr/bin/python3.11 launch.py --listen --port 7860 --xformers --api --enable-insecure-extension-accessRestart=on-failureRestartSec=10Environment="HOME=/home/sduser"
# Resource limitsLimitNOFILE=65536
[Install]WantedBy=multi-user.targetEOFEnable and start the service:
sudo systemctl daemon-reloadsudo systemctl enable --now stable-diffusionManage the service:
# Check statussudo systemctl status stable-diffusion
# View logssudo journalctl -u stable-diffusion -f
# Restartsudo systemctl restart stable-diffusionFirewall Configuration
Section titled “Firewall Configuration”sudo firewall-cmd --permanent --add-port=7860/tcpsudo firewall-cmd --reloadSecurity Recommendations
Section titled “Security Recommendations”Example Nginx reverse proxy configuration:
sudo tee /etc/nginx/conf.d/sd-webui.conf > /dev/null <<'EOF'server { listen 443 ssl; server_name sd.example.com;
ssl_certificate /etc/letsencrypt/live/sd.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/sd.example.com/privkey.pem;
client_max_body_size 100M;
location / { proxy_pass http://127.0.0.1:7860; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 300s; }}EOFStartup Error: No module named pip
Section titled “Startup Error: No module named pip”python3.11 -m ensurepip --upgradeBlack or Solid-Color Images
Section titled “Black or Solid-Color Images”Try adding the --no-half or --no-half-vae startup parameters:
python3.11 launch.py --listen --xformers --no-half-vaeOut of Memory
Section titled “Out of Memory”# Enable VRAM optimizationpython3.11 launch.py --listen --xformers --medvram
# More aggressive VRAM optimizationpython3.11 launch.py --listen --xformers --lowvram
# Reduce generation size# In the WebUI, reduce Width/Height to 512x512Slow pip Dependency Installation
Section titled “Slow pip Dependency Installation”Set a pip mirror:
mkdir -p ~/.config/pipcat > ~/.config/pip/pip.conf <<'EOF'[global]index-url = https://mirrors.aliyun.com/pypi/simple/trusted-host = mirrors.aliyun.comEOFUpdating the WebUI
Section titled “Updating the WebUI”cd /opt/stable-diffusion/stable-diffusion-webuigit pull# Simply restart; dependencies will be updated automatically