Skip to content
Search RunEntLinux

Searches general documentation on RunEntLinux. Each distribution has its own documentation search.

    Browse this documentation

    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.

    • 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)
    Terminal window
    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-libGL
    Terminal window
    nvidia-smi

    Make sure the output shows your GPU model and driver version.

    Section titled “Create a Dedicated User (Optional but Recommended)”
    Terminal window
    sudo useradd -m -s /bin/bash sduser
    sudo su - sduser
    Terminal window
    cd /opt
    sudo mkdir -p stable-diffusion
    sudo chown $(whoami):$(whoami) stable-diffusion
    cd stable-diffusion
    git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
    cd stable-diffusion-webui

    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:

    Terminal window
    # 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.safetensors

    The WebUI launch script will automatically create a virtual environment and install all Python dependencies:

    Terminal window
    cd /opt/stable-diffusion/stable-diffusion-webui
    # Launch using Python 3.11
    ./webui.sh --listen --xformers

    Parameter 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:7860
    Terminal window
    ./webui.sh \
    --listen \
    --port 7860 \
    --xformers \
    --enable-insecure-extension-access \
    --api \
    --medvram
    ParameterDescription
    --listenListen on all interfaces
    --portSpecify port number
    --xformersEnable xformers memory optimization
    --apiEnable REST API endpoint
    --medvramMedium VRAM optimization (recommended for 6-8 GB VRAM)
    --lowvramLow VRAM optimization (for 4-6 GB VRAM)
    --enable-insecure-extension-accessAllow installing extensions from the WebUI
    --gradio-auth user:passSet access username and password
    --no-half-vaeTry this parameter if generated images are black

    Open http://your-server-ip:7860 in your browser.

    1. Select the loaded model at the top
    2. Enter English prompt words in the Prompt box describing the image you want to generate
    3. Enter elements you do not want in the Negative Prompt box
    4. 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
    5. Click Generate

    Switch to the img2img tab, upload a reference image, fill in the prompt, adjust the Denoising strength (0.3-0.7), and click Generate.

    When launched with the --api parameter, you can generate images via the HTTP API:

    Terminal window
    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.

    Create a systemd service for management and auto-start:

    Terminal window
    sudo tee /etc/systemd/system/stable-diffusion.service > /dev/null <<'EOF'
    [Unit]
    Description=Stable Diffusion WebUI
    After=network-online.target
    Wants=network-online.target
    [Service]
    Type=simple
    User=sduser
    Group=sduser
    WorkingDirectory=/opt/stable-diffusion/stable-diffusion-webui
    ExecStart=/opt/stable-diffusion/stable-diffusion-webui/webui.sh --listen --port 7860 --xformers --api --enable-insecure-extension-access
    Restart=on-failure
    RestartSec=10
    Environment="HOME=/home/sduser"
    # Resource limits
    LimitNOFILE=65536
    [Install]
    WantedBy=multi-user.target
    EOF

    Enable and start the service:

    Terminal window
    sudo systemctl daemon-reload
    sudo systemctl enable --now stable-diffusion

    Manage the service:

    Terminal window
    # Check status
    sudo systemctl status stable-diffusion
    # View logs
    sudo journalctl -u stable-diffusion -f
    # Restart
    sudo systemctl restart stable-diffusion
    Terminal window
    sudo firewall-cmd --permanent --add-port=7860/tcp
    sudo firewall-cmd --reload

    Example Nginx reverse proxy configuration:

    Terminal window
    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;
    }
    }
    EOF
    Terminal window
    python3.11 -m ensurepip --upgrade

    Try adding the --no-half or --no-half-vae startup parameters:

    Terminal window
    ./webui.sh --listen --xformers --no-half-vae
    Terminal window
    # Enable VRAM optimization
    ./webui.sh --listen --xformers --medvram
    # More aggressive VRAM optimization
    ./webui.sh --listen --xformers --lowvram
    # Reduce generation size
    # In the WebUI, reduce Width/Height to 512x512

    Set a pip mirror:

    Terminal window
    mkdir -p ~/.config/pip
    cat > ~/.config/pip/pip.conf <<'EOF'
    [global]
    index-url = https://mirrors.aliyun.com/pypi/simple/
    trusted-host = mirrors.aliyun.com
    EOF
    Terminal window
    cd /opt/stable-diffusion/stable-diffusion-webui
    git pull
    # Simply restart; dependencies will be updated automatically