Skip to main content

SD.Next openvino docker compose

Install

vi Dockerfile
vi docker-compose.yml
docker compose up -d
docker logs sdnext-openvino --follow
#docker compose down

Dockerfile

example without proxy on branch master

# SD.Next OpenVINO Dockerfile
# docs: <https://github.com/vladmandic/sdnext/wiki/Docker>

# base image
FROM ubuntu:noble

# metadata
LABEL org.opencontainers.image.vendor="SD.Next"
LABEL org.opencontainers.image.authors="disty0"
LABEL org.opencontainers.image.url="https://github.com/vladmandic/sdnext/"
LABEL org.opencontainers.image.documentation="https://github.com/vladmandic/sdnext/wiki/Docker"
LABEL org.opencontainers.image.source="https://github.com/vladmandic/sdnext/"
LABEL org.opencontainers.image.licenses="AGPL-3.0"
LABEL org.opencontainers.image.title="SD.Next OpenVINO"
LABEL org.opencontainers.image.description="SD.Next: Advanced Implementation of Stable Diffusion and other Diffusion-based generative image models"
LABEL org.opencontainers.image.base.name="https://hub.docker.com/_/ubuntu:noble"
LABEL org.opencontainers.image.version="latest"

# essentials
RUN apt-get update && \
    apt-get install -y --no-install-recommends --fix-missing \
    software-properties-common \
    build-essential \
    ca-certificates \
    wget \
    gpg \
    git

# intel compute runtime
RUN wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | gpg --yes --dearmor --output /usr/share/keyrings/intel-graphics.gpg
RUN echo "deb [arch=amd64,i386 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu noble client" | tee /etc/apt/sources.list.d/intel-gpu-noble.list
RUN apt-get update

RUN apt-get install -y --no-install-recommends --fix-missing \
    intel-opencl-icd \
    libze-intel-gpu1 \
    libze1

# required by pytorch / ipex
RUN apt-get install -y --no-install-recommends --fix-missing \
    libgl1 \
    libglib2.0-0 \
    libgomp1

# python3.12
RUN apt-get install -y --no-install-recommends --fix-missing \
    python3 \
    python3-dev \
    python3-venv \
    python3-pip

# cleanup
RUN /usr/sbin/ldconfig
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# stop pip and uv from caching
ENV PIP_NO_CACHE_DIR=true
ENV UV_NO_CACHE=true

# set paths to use with sdnext
ENV SD_DOCKER=true
ENV SD_DATADIR="/mnt/data"
ENV SD_MODELSDIR="/mnt/models"
ENV venv_dir="/mnt/python/venv"

# paths used by sdnext can be a volume if necessary
#VOLUME [ "/app" ]
#VOLUME [ "/mnt/data" ]
#VOLUME [ "/mnt/models" ]
#VOLUME [ "/mnt/python" ]
#VOLUME [ "/root/.cache/huggingface" ]

# git clone and run sdnext
RUN echo '#!/bin/bash\ngit status || git clone https://github.com/vladmandic/sdnext.git .\n/app/webui.sh "$@"' | tee /bin/startup.sh
RUN chmod 755 /bin/startup.sh

# actually run sdnext
WORKDIR /app
ENTRYPOINT [ "startup.sh", "-f", "--use-openvino", "--uv", "--listen",  "--insecure", "--update", "--debug", "--api-log", "--log", "sdnext.log" ]

# expose port
EXPOSE 7860

# healthcheck function
# HEALTHCHECK --interval=60s --timeout=10s --start-period=60s --retries=3 CMD curl --fail http://localhost:7860/sdapi/v1/status || exit 1

# stop signal
STOPSIGNAL SIGINT

example with proxy

 (to be removed or replaced to one is working) and on Developer branch

# SD.Next OpenVINO Dockerfile
# docs: <https://github.com/vladmandic/sdnext/wiki/Docker>

# base image
FROM ubuntu:noble

# metadata
LABEL org.opencontainers.image.vendor="SD.Next"
LABEL org.opencontainers.image.authors="disty0"
LABEL org.opencontainers.image.url="https://github.com/vladmandic/sdnext/"
LABEL org.opencontainers.image.documentation="https://github.com/vladmandic/sdnext/wiki/Docker"
LABEL org.opencontainers.image.source="https://github.com/vladmandic/sdnext/"
LABEL org.opencontainers.image.licenses="AGPL-3.0"
LABEL org.opencontainers.image.title="SD.Next OpenVINO"
LABEL org.opencontainers.image.description="SD.Next: Advanced Implementation of Stable Diffusion and other Diffusion-based generative image models"
LABEL org.opencontainers.image.base.name="https://hub.docker.com/_/ubuntu:noble"
LABEL org.opencontainers.image.version="latest"

# essentials
RUN apt-get update && \
    apt-get install -y --no-install-recommends --fix-missing \
    software-properties-common \
    build-essential \
    ca-certificates \
    wget \
    gpg \
    git

# intel compute runtime
RUN https_proxy=http://proxy.example.com:18080/  wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | gpg --yes --dearmor --output /usr/share/keyrings/intel-graphics.gpg
RUN echo "deb [arch=amd64,i386 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu noble client" | tee /etc/apt/sources.list.d/intel-gpu-noble.list
RUN https_proxy=http://proxy.example.com:18080/  apt-get update

RUN https_proxy=http://proxy.example.com:18080/  apt-get install -y --no-install-recommends --fix-missing \
    intel-opencl-icd \
    libze-intel-gpu1 \
    libze1

# required by pytorch / ipex
RUN https_proxy=http://proxy.example.com:18080/  apt-get install -y --no-install-recommends --fix-missing \
    libgl1 \
    libglib2.0-0 \
    libgomp1

# python3.12
RUN https_proxy=http://proxy.example.com:18080/  apt-get install -y --no-install-recommends --fix-missing \
    python3 \
    python3-dev \
    python3-venv \
    python3-pip

# cleanup
RUN /usr/sbin/ldconfig
RUN https_proxy=http://proxy.example.com:18080/  apt-get clean && rm -rf /var/lib/apt/lists/*

# stop pip and uv from caching
ENV PIP_NO_CACHE_DIR=true
ENV UV_NO_CACHE=true

# set paths to use with sdnext
ENV SD_DOCKER=true
ENV SD_DATADIR="/mnt/data"
ENV SD_MODELSDIR="/mnt/models"
ENV venv_dir="/mnt/python/venv"

# paths used by sdnext can be a volume if necessary
#VOLUME [ "/app" ]
#VOLUME [ "/mnt/data" ]
#VOLUME [ "/mnt/models" ]
#VOLUME [ "/mnt/python" ]
#VOLUME [ "/root/.cache/huggingface" ]

# git clone and run sdnext
RUN echo '#!/bin/bash\ngit status || git clone https://github.com/vladmandic/sdnext.git -b dev .\n/app/webui.sh "$@"' | tee /bin/startup.sh
RUN chmod 755 /bin/startup.sh

# actually run sdnext
WORKDIR /app
ENTRYPOINT [ "startup.sh", "-f", "--use-openvino", "--uv", "--listen",  "--insecure", "--server-name sdnext.example.com", "--update", "--debug", "--api-log", "--log", "sdnext.log" ]

# expose port
EXPOSE 7860

# healthcheck function
# HEALTHCHECK --interval=60s --timeout=10s --start-period=60s --retries=3 CMD curl --fail http://localhost:7860/sdapi/v1/status || exit 1

# stop signal
STOPSIGNAL SIGINT

docker-compose.yml

services:
  sdnext-openvino:
    build:
      dockerfile: Dockerfile
    image: sdnext-openvino:latest
    container_name: sdnext-openvino
    restart: unless-stopped
    devices:
      - /dev/dri:/dev/dri
# if Intel CPU got NPU 
#      - /dev/accel:/dev/accel
# if need proxy for internet access
#    environment:
#      - https_proxy=http://proxy.example.com:18080/
    ports:
      - 7860:7860
    volumes:
      - /docker/sdnext/app-volume:/app
      - /docker/sdnext/mnt-volume:/mnt
      - /docker/sdnext/huggingface-volume:/root/.cache/huggingface
      - /dev/shm:/dev/shm

Application screenshots

image.png

image.png

Post-install fixes

add some python libraries

That is not something you beed to do, but in rare case of it kind of missing in requirements.txt

# In case of some dependencies is missing (like sentencepiece in Dev branch at 2025-07-14)
# docker exec -it sdnext-openvino bash
python3 -m venv /mnt/python/venv
/mnt/python/venv/bin/pip3 install sentencepiece

Fix access to gated repo

 (in case access is granted and token available)

Access error to gated repo

sdnext-ipex  | 20:01:16-163840 ERROR    Load model: repo="black-forest-labs/FLUX.1-Kontext-dev"
sdnext-ipex  |                          login=True 401 Client Error. (Request ID:
sdnext-ipex  |                          Root=1-6875620c-4ddbac246caa80376513448a;bea8cc0a-fb48-
sdnext-ipex  |                          452c-a738-debd0038cb43)
sdnext-ipex  |
sdnext-ipex  |                          Cannot access gated repo for url
sdnext-ipex  |                          https://huggingface.co/api/models/black-forest-labs/FLU
sdnext-ipex  |                          X.1-Kontext-dev/auth-check.
sdnext-ipex  |                          Access to model black-forest-labs/FLUX.1-Kontext-dev is
sdnext-ipex  |                          restricted. You must have access to it and be
sdnext-ipex  |                          authenticated to access it. Please log in.

login to huggingface manually

# docker exec -it sdnext-openvino bash
# export venv_dir=/mnt/python/venv/
source "${venv_dir}"/bin/activate
git config --global credential.helper store
/mnt/python/venv/bin/huggingface-cli login
# docker restart sdnext-openvino
# Download or use the model after a restart


System info

app: sdnext.git updated: 2025-07-14 hash: 79d0fb81 url: https://github.com/vladmandic/sdnext.git/tree/dev
arch: x86_64 cpu: x86_64 system: Linux release: 6.11.0-29-generic
python: 3.12.3 Torch: 2.7.1+cpu
device: Intel(R) Arc(TM) Graphics (iGPU) openvino: 2025.2.0
ram: free:95.64 used:29.69 total:125.33 gpu: total:125.33
xformers:  diffusers: 0.35.0.dev0 transformers: 4.53.2
active: cpu dtype: torch.float32 vae: torch.float32 unet: torch.float32
base: Diffusers/nvidia/Cosmos-Predict2-2B-Text2Image [acdb5fde99] refiner: none vae: none te: none unet: none

app: sdnext.git updated: 2025-08-02 hash: e90ac68d url: https://github.com/vladmandic/sdnext.git/tree/dev
arch: x86_64 cpu: x86_64 system: Linux release: 6.14.0-27-generic
python: 3.12.3 Torch: 2.7.1+cpu
device: Intel(R) Iris(R) Xe Graphics (iGPU) openvino: 2025.2.0
ram: free:59.83 used:34.14 total:93.97 gpu: total:93.97
xformers:  diffusers: 0.35.0.dev0 transformers: 4.54.1
active: cpu dtype: torch.float32 vae: torch.float32 unet: torch.float32
base: Diffusers/Kwai-Kolors/Kolors-diffusers [7e091c7519] refiner: none vae: none te: none unet: none

openvino (float32) note

Memory consumption in openvino (float32) significantly higher than ipex (bfloat16) so it may cause OOM on same HW with same models than ipex is OK with (Flux.1 dev kontext example, openvino/gpu iGPU Intel Arc)

image.png

Reinstall

Clean reinstall

Remove all sdnext related date and have clean install

docker compose down --rmi local
docker system prune --all --force
rm -Rf /docker/sdnext/*
docker compose up -d
docker compose logs --follow

Preserve downloaded models

save the models and output images

docker compose down --rmi local
docker system prune --all --force
rm -Rf /docker/sdnext/app-volume/ /docker/sdnext/python-volume/ /docker/sdnext/mnt-volume/python/
docker compose up -d
docker compose logs --follow

Config example for iGPU

cat /docker/sdnext/mnt-volume/data/config.json
{
  "no_half": false,
  "openvino_devices": [
    "GPU"
  ],
  "samples_filename_pattern": "[seq]-[date]-[model_name]-[height]x[width]-Seed[seed]-CFG[cfg]-STEP[steps]",
}

Example image generation on iGPU

SD.Next openvino Intel Xe iGPU on Intel core i7-1355U + 96GB DDR5 (25/55W power limits) float32

Kolors, Cosmos, Flux, Chroma not work

Model resolution time (at 20 STEPS)
dreamshaper_8  (SD1.5) 512x512 55.17s
dreamshaper_8  (SD1.5) 768x768 2m 27.75s 
dreamshaper_8  (SD1.5) 1024x1024 failed
TempestV0.1-Artistic (SDXL) 512x512 1m 58.98s
TempestV0.1-Artistic (SDXL) 768x768 3m 23.79s
TempestV0.1-Artistic (SDXL) 1024x1024 5m 24.46s
TempestV0.1-Artistic (SDXL) 1280x1280 8m 25.92s

SD1.5

00001-2025-08-07-dreamshaper_8-768x768-Seed4104685571-CFG6-STEP20.jpg

Prompt: car

Parameters: Steps: 20| Size: 768x768| Seed: 4104685571| CFG scale: 6| App: SD.Next| Version: a9c65c0| Pipeline: StableDiffusionPipeline| Operations: txt2img| Model: dreamshaper_8| Model hash: 879db523c3

Time: 2m 29.85s | total 184.46 pipeline 118.10 preview 34.60 decode 31.73 | RAM 6.66 GB 7%

Config example for CPU

{
  "no_half": false,
  "openvino_devices": [
    "CPU"
  ],
  "samples_filename_pattern": "[seq]-[date]-[model_name]-[height]x[width]-Seed[seed]-CFG[cfg]-STEP[steps]",
  "device_map": "cpu",
  "diffusers_generator_device": "CPU"
}

Example image generation on CPU

SD.Next openvino CPU on Intel core i7-1355U + 96GB DDR5 (25/55W power limits) float32

Model resolution time (at 20 STEPS)
Kolors 1280x1280 34m 51.83s
FLUX.1-Krea-dev 512x512 37m 28.47s  (96GB RAM + 42GB swap)
FLUX.1-Krea-dev 768x768 96GB RAM + 64GB swap is not enough
dreamshaper_8  (SD1.5) 512x512 2m 58.45s
dreamshaper_8  (SD1.5) 768x768 7m 53.50s
dreamshaper_8  (SD1.5) 1024x1024 18m 10.01s
TempestV0.1-Artistic (SDXL) 512x512 5m 16.53s
TempestV0.1-Artistic (SDXL) 768x768 11m 0.86s
TempestV0.1-Artistic (SDXL) 1024x1024 20m 41.39s
TempestV0.1-Artistic (SDXL) 1280x1280 34m 5.18s

Kolors

openvino-cpu-kolors-1280px.jpg

Prompt: car

Parameters: Steps: 20| Size: 1280x1280| Seed: 1747916893| CFG scale: 6| App: SD.Next| Version: e90ac68| Pipeline: KolorsPipeline| Operations: txt2img| Model: Kolors-diffusers

Execution: Time: 34m 51.83s | total 2091.82 pipeline 1960.52 decode 131.16 | RAM 90.33 GB 96%

openvino-cpu-kolors-1024px.jpg

Prompt: car

Parameters: Steps: 20| Size: 1024x1024| Seed: 3229942612| CFG scale: 6| App: SD.Next| Version: e90ac68| Pipeline: KolorsPipeline| Operations: txt2img| Model: Kolors-diffusers

Flux.1 Krea

93GB of RAM + ~ 46GB of swap

openvino-cpu-Krea-512px.jpg

Prompt: car

Parameters: Steps: 20| Size: 512x512| Seed: 1747916893| CFG scale: 6| App: SD.Next| Version: e90ac68| Pipeline: FluxPipeline| Operations: txt2img| Model: FLUX.1-Krea-dev

Execution: Time: 37m 28.47s | total 2292.37 pipeline 2224.84 decode 23.42 prompt 19.16 te 19.13 preview 5.59 | RAM 91.66 GB 98%

openvino-cpu-flux-krea.png

Use nginx for SD.Next

install nginx

# SSL certificate
#vi /etc/ssl/private/wildcard.pem
#chmod 600 /etc/ssl/private/wildcard.pem
#vi /etc/ssl/certs/wildcard.ca
# Nginx
sudo apt install -y nginx
vi /etc/nginx/conf.d/sdnext.conf
systemctl restart nginx
systemctl status nginx

nginx config example

server {
        listen       80;
        server_name sdnext.example.com;
        return 301 https://$server_name$request_uri;
    }
server {
        listen 443 ssl;
        server_name sdnext.example.com;
        # SSL Settings
        ssl_certificate /etc/ssl/private/wildcard.pem;
        ssl_certificate_key /etc/ssl/private/wildcard.pem;
        ssl_trusted_certificate /etc/ssl/certs/wildcard.ca;
        add_header Strict-Transport-Security 'max-age=15552000; includeSubDomains';
        ssl_protocols TLSv1.3 TLSv1.2;
        ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA HIGH !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
        ssl_session_cache shared:SSL:20m;
        ssl_session_timeout 1h;
        ssl_prefer_server_ciphers on;
        ssl_stapling on;
        ssl_stapling_verify on;
        # Timeouts
        client_max_body_size 50G;
        client_body_timeout 600s;
        proxy_read_timeout  600s;
        proxy_send_timeout  600s;
        send_timeout        600s;
        # Set headers
        proxy_set_header Host              $http_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;
        # enable websockets
        proxy_http_version 1.1;
        proxy_set_header   Upgrade    $http_upgrade;
        proxy_set_header   Connection "upgrade";
        proxy_redirect     off;
        # DNS
        resolver 1.1.1.1 8.8.4.4 valid=300s;
        resolver_timeout 5s;

        # ==========  Alternative image download page BEGIN
        location ~* /(download-text)/.*.(gif|jpg|png)$ {
         add_header Content-disposition "attachment; filename=$1";
         types {}
         default_type application/octet-stream;
         expires -1;
        }

        location /download-text {
         alias /docker/sdnext/mnt-volume/data/outputs/text/;
         autoindex on;
         expires 1s;
         location ~* ^.+\.(jpeg|gif|png|jpg)
          {
           add_header Content-disposition "attachment";
          }
        }
        # ========== Alternative image download page END
        
        location / {
         proxy_pass http://127.0.0.1:7860;
        }
}