Skip to content

SD GUI Server

fszontagh edited this page Mar 2, 2025 · 7 revisions

These features are available from version 0.2.5

What is this?

The Stable Diffusion GUI Server is a variant of the Desktop GUI, designed to run Stable Diffusion in headless or server mode. Its primary function is to provide remote access and automated processing capabilities.

The server consists of the following components:

  • A simple queue manager, similar to the built-in Queue Manager in the GUI.

  • A TCP socket server that handles client connections.

  • An external process handler, which operates similarly to the GUI's process handler and performs the same tasks.

  • A basic model manager for internal model handling.

How can I connect to the server?

The server uses a custom binary protocol that is compatible with the GUI.

To manage connections to multiple servers in the GUI, navigate to Settings -> Servers.

OS Compatibility

The server is currently supported only on Linux-based operating systems. On Windows, it can be run using WSL or within a Docker container.

To install the server, you can either download prebuilt packages or build it from the source code.

Model File Management

There is no automated method for managing model files on the server, similar to the GUI's limitations. Model files cannot be added or removed while the server is running.

To add models:

  1. Stop the server.

  2. Place the new model files in the designated directory.

  3. Restart the server.

Upon startup, the server scans model directories for new files. If a new model is detected, the server generates an SHA-256 hash of its contents. Models cannot be used without this hash, as it serves as their unique identifier on the client side.

Security

Currently, TCP communication is not encrypted, making it susceptible to interception and reverse engineering.

For authentication, the server requires a unique auth key, which must be provided by clients to establish a connection. A server can handle only one auth key at a time.

Upon connection, the server requests authentication from the client. If the client fails to respond or provides an empty auth key, the server will terminate the connection. This behavior is configurable via the server's configuration file.

Future Security Enhancements

In upcoming releases, optional SSL/TLS encryption will be implemented to secure connections.

Configuration

After deploying the server and before start the server, please verifiy the initial configuration. The initial config file is deployed by the installer, or available from here.

The configuration file is a json file. If the json is invalid or some requied key is missing, the server will won't start. Comments are allowed in the configuration file, but the server don't keep it.

Do not edit the server configuration file if the server already running. The server overwrites the config file at the stop sequence.

If all initial parameters are configured, you can start the server. On first start, the server will generate a server id and the authentication key.

The authentication key is required to connect with the clients. Multple clients can use the same authentication key.

The server id is for identifying the server by the clients. If you plan to run multiple servers (for example using multiple HW devices on the same host), please verify if the server id is unique. One client can handle one server with the same server id.

Docker

To pull the latest server image:

docker run fszontagh/stablediffusiongui-server:latest-

Where the backend target part is can be:

  • all
  • allcpu
  • allgpu
  • avx
  • avx2
  • avx512
  • cuda
  • vulkan

If you select a backend alias, eg.: all/allcpu/allgpu, you have to modify the '/app/config.json' inside the container to specify a valid backend name.

For the complete tag list, please visit the docker hub

On the first start, the image will start to download some base models

You can skip it with passing the DOWNLOAD_BASE_MODELS environment variable to it:

docker run -it -e DOWNLOAD_BASE_MODELS=False -p 8191:8191 fszontagh/stablediffusiongui-server:tag

Here is an example to run the latest version with the default settings using vulkan backend:

docker run -it -p 8191:8191 fszontagh/stablediffusiongui-server:latest-vulkan

To add custom folder where the models are stored:

docker run -it -p 8191:8191 -v /path/to/models:/app/models fszontagh/stablediffusiongui-server:latest-vulkan

If the server starts up, you can copy the auth key, then connecting with the GUI to it.

Example docker-compose.yml:

version: '3.8'

services:
  stable-diffusion-vulkan:
    image: fszontagh/stablediffusiongui-server:latest-vulkan
    container_name: stable-diffusion-vulkan
    restart: unless-stopped
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    environment:
      - DOWNLOAD_BASE_MODELS=True
      - NVIDIA_DRIVER_CAPABILITIES=compute,utility
      - NVIDIA_VISIBLE_DEVICES=all
      - DISPLAY=localhost:0
    volumes:
      - /media/fszontagh/STABLEDIFFUSION/sdguiserver/models:/app/models
      - /media/fszontagh/STABLEDIFFUSION/sdguiserver/log:/app/log
      - /media/fszontagh/STABLEDIFFUSION/sdguiserver/data:/app/data
    ports:
      - "8196:8191"
    runtime: nvidia