Skip to content

Stable Diffusion WebUI Installation

In this article

Stable Diffusion WebUI (formerly Automatic1111) is a graphical interface for working with Stable Diffusion models, which generate images from text descriptions (prompts). Instead of a command line, Stable Diffusion WebUI provides an intuitive interface with buttons, input fields, and settings, simplifying the image generation process. It allows you to easily change parameters, save and load images, and makes Stable Diffusion accessible to a wide audience, even those unfamiliar with command lines.

Installing Stable Diffusion WebUI on a Ubuntu Server

Attention

Stable Diffusion WebUI works with acceptable performance only on vGPU/GPU servers with Nvidia graphics cards with tensor cores starting from A4000 and above. Make sure you have pre-installed Nvidia drivers and CUDA.

  1. Log in to the server via ssh or other methods as root.

  2. Install dependencies:

    apt install python3.10
    apt install python3-pip
    apt install python3-venv -y
    apt install libgl1 
    apt install libglib2.0-0
    apt install google-perftools
    
  3. Create the sd user:

    adduser sd
    adduser sd sudo
    
  4. Switch to the user's home directory and switch to it:

    cd /home/sd/
    su sd
    
  5. Download the installation script:

    wget -q https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh
    chmod +x ./webui.sh
    
  6. Install the web interface:

    ./webui.sh
    
  7. Add parameters for launch:

    • To launch with a graphical interface accessible by the server's IP address:
    echo 'export COMMANDLINE_ARGS="--autolaunch --no-half-vae --xformers --medvram-sdxl --opt-sdp-attention --listen"' >>  /home/sd/stable-diffusion-webui/webui-user.sh 
    
    • To launch without a graphical interface with OpenWebUI:
    echo 'export COMMANDLINE_ARGS="--autolaunch --no-half-vae --xformers --medvram-sdxl --opt-sdp-attention --nowebui --api --api-auth username:password"' >>  /home/sd/stable-diffusion-webui/webui-user.sh
    

    where username:password is the username and password for accessing the API.

    Note

    You may not need to specify the --api-auth username:password parameter if no one else will access this API on the server.

  8. Download the SDXL model:

    wget https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors -O ~/stable-diffusion-webui/models/Stable-diffusion/sd_xl_base_1.0.safetensors
    
  9. Create a systemd service for automatic startup:

    sudo tee /usr/lib/systemd/system/sdwebui.service > /dev/null <<EOF
    [Unit]
    Description=Stable Diffusion Webui Service
    After=network-online.target
    
    [Service]
    ExecStart=/home/sd/stable-diffusion-webui/webui.sh
    User=sd
    Restart=always
    RestartSec=3
    
    [Install]
    WantedBy=default.target
    EOF
    
  10. Start the service:

    sudo systemctl daemon-reload
    sudo systemctl enable sdwebui
    sudo systemctl start sdwebui
    

    Note

    You can manage the Stable Diffusion WebUI service using the commands sudo service start sdwebui and sudo service stop sdwebui.

  11. Check the service status:

    sudo service status sdwebui
    

Using the Stable Diffusion WebUI Graphical Interface

To access the graphical interface, use the address http://<YOUR_SERVER_IP>:7861.

In the interface, set the following parameters for image generation:

  • Stable Diffusion checkpoint: sd_xl_base_1.0.safetensors;
  • Width: 1024;
  • Height: 1024;
  • Sampling steps: from 30 to 50.

Note

Generated images are saved in the ~/stable-diffusion-webui/outputs/txt2img-images directory, sorted by creation date.

Using Stable Diffusion WebUI in an AI Chatbot

Setting up Image Generation in an AI Chatbot

To enable image generation in an AI chatbot (OpenWebUI), follow these steps:

  1. Log in to the AI chatbot as an administrator;
  2. Go to the menu Admin Name >> Admin Panel >> Settings >> Images;
  3. Enter the value http://0.0.0.0:7861 in the AUTOMATIC1111 Base URL field, and in the AUTOMATIC1111 Api Auth String field, enter the previously set username:password;
  4. After this, set the Image Generation (Experimental) option to On;
  5. Change the Set Image Size parameter to 1024x1024 and set the Set Steps value to between 30 and 50;
  6. Save the changes by clicking the Save button.

Instructions for Generating Images in an AI Chatbot

To generate images, follow these steps:

  1. Select any model and in the chatbot's input field, send the command Repeat this back: <you prompt for image generation>;
  2. In the chatbot's response, click the Generate Image icon;
  3. Wait for the result for 20 to 50 seconds, depending on your server's load.

Attention

To generate a new image, repeat steps 1-4. Clicking the Regenerate icon will replace the displayed image with a new one, without saving the old one.

Note

All generated images are saved on the server in the directory in the directory /var/lib/docker/volumes/open-webui/_data/cache/image/generations/.

Adding Other Models to Stable Diffusion OpenWebUI

You can add any supported models in .safetensors and LORA format yourself. To do this, you need to log in to your server via SSH, switch to the SD user with the command

cd /home/sd/
su sd

and download the models using the commands provided below.

Attention

After installing models, be sure to restart Stable Diffusion WebUI with the command sudo systemctl restart sdwebui.

We recommend using the following models:

  1. UI Icons: A model for drawing icons in monochrome format.
wget -O ~/stable-diffusion-webui/models/uiIcons_v10.safetensors https://civitai.com/api/download/models/367044

Required settings:

- Stable Diffusion checkpoint: `uiIcons_v10.safetensors`;
- Width: `256`;
- Height: `256`;
- Sampling steps: `30`.
  1. Deliberate v6: A fast model based on SD 1.5 that can be used for both image generation and inpainting, or with ControlNet for style transfer or sketch-based image generation in image2image mode.
wget https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v6.safetensors -O ~/stable-diffusion-webui/models/Deliberate_v6.safetensors

Required settings:

- Stable Diffusion checkpoint: `Deliberate_v6.safetensors`;
- Width: `512`;
- Height: `512`;
- Sampling steps: `30` to `50`.