From 1a54b137c30cf3769c894f639f33439663b17d18 Mon Sep 17 00:00:00 2001 From: fbt Date: Mon, 23 Oct 2023 01:42:57 +0000 Subject: [PATCH] init Signed-off-by: fbt --- Containerfile | 14 ++++++++++++++ README.md | 11 +++++++++++ config.yaml | 27 +++++++++++++++++++++++++++ init | 19 +++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 Containerfile create mode 100644 README.md create mode 100755 config.yaml create mode 100755 init diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..1353823 --- /dev/null +++ b/Containerfile @@ -0,0 +1,14 @@ +# podman run -it -e NVIDIA_DRIVER_CAPABILITIES=compute,utility spark:latest bash + +FROM archlinux:latest +RUN pacman-key --init +RUN pacman -Suy --noconfirm + +COPY stable-diffusion-ui.pkg.tar.zst /stable-diffusion-ui.pkg.tar.zst +COPY init /init +COPY config.yaml /config.yaml + +RUN pacman -S --noconfirm curl which nvidia-utils +RUN useradd -m -s /usr/bin/bash -d /srv/stable-diffusion stable-diffusion + +ENTRYPOINT /init diff --git a/README.md b/README.md new file mode 100644 index 0000000..e3a9c66 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# HOWTO + +- Build stable-diffusion-ui from AUR, put it here as `stable-diffusion-ui.pkg.tar.zst`. +- Set up GPU access in docker/podman. +- Run the following: + +``` +podman build --no-cache . -t 'stable-diffusion-ui-server +podman run -it --device nvidia.com/gpu=all --security-opt=label=disable --name stable-diffusion-ui -p 9000:9000 -v ./data:/opt/stable-diffusion-ui -e NVIDIA_DRIVER_CAPABILITIES=compute,utility localhost/stable-diffusion-ui-server +browser http://localhost:9000 +``` diff --git a/config.yaml b/config.yaml new file mode 100755 index 0000000..a75c264 --- /dev/null +++ b/config.yaml @@ -0,0 +1,27 @@ +# Change listen_port if port 9000 is already in use on your system +# Set listen_to_network to true to make Easy Diffusion accessibble on your local network +net: + listen_port: 9000 + listen_to_network: true + +# Multi GPU setup +render_devices: auto + +# Set open_browser_on_start to false to disable opening a new browser tab on each restart +ui: + open_browser_on_start: true +update_branch: main + +# Set force_save_path to enforce an auto save path. Clients will not be able to change or +# disable auto save when this option is set. Please adapt the path in the examples to your +# needs. +# Windows: +# force_save_path: C:\\Easy Diffusion Images\\ +# Linux: +# force_save_path: /data/easy-diffusion-images/ +use_v3_engine: true +models_dir: /opt/stable-diffusion-ui/models +model: + stable-diffusion: lazyphoton-0.50000 + vae: vae-ft-mse-840000-ema-pruned +vram_usage_level: low diff --git a/init b/init new file mode 100755 index 0000000..d1cb239 --- /dev/null +++ b/init @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +pkg="/stable-diffusion-ui.pkg.tar.zst" +cfg="/opt/stable-diffusion-ui/config.yaml" + +if [[ -f "$pkg" ]]; then + pacman -U --noconfirm --overwrite '/opt/stable-diffusion-ui/*' "$pkg" + + if ! [[ -f "$cfg" ]]; then + mv /config.yaml "$cfg" || { + printf 'Failed to move the default config file to %s!\n' "$cfg" + } + fi + + chown -R stable-diffusion:stable-diffusion /opt/stable-diffusion-ui + rm -vf "$pkg" +fi + +exec su stable-diffusion -c '/usr/bin/stable-diffusion-ui-server'