====Stable diffusion====
Stable diffusion tests on the [[boards:n100|N100 Mini PC]].
===Environment===
==Debian bookworm==
apt update
apt full-upgrade
apt install build-essential git mercurial
apt install google-perftools libgl1 libglib2.0-0
==Python==
apt install python3-full
update-alternatives --remove-all python
update-alternatives --install /usr/bin/python python /usr/bin/python3 1
update-alternatives --config python
python -V
Python 3.11.2
==Swap==
The system has 16 GB RAM so make at least 24 GB swap space.
swapoff /var/swap
dd if=/dev/zero of=/var/swap bs=4M count=6144
mkswap /var/swap
echo "/var/swap none swap sw 0 0" >> /etc/fstab
swapon /var/swap
===AUTOMATIC1111===
[[https://github.com/AUTOMATIC1111/stable-diffusion-webui|Github]]
==Install==
mkdir -p ~/src && cd ~/src
git clone --recursive https://github.com/AUTOMATIC1111/stable-diffusion-webuii
cd stable-diffusion-webui stable-diffusion-webui.automatic1111
echo 'export PYTORCH_TRACING_MODE=TORCHFX' >> webui-user.sh
echo 'export COMMANDLINE_ARGS="--skip-torch-cuda-test --precision full --no-half --listen"' >> webui-user.sh
==Run==
./webui.sh
===OPENVINO===
[[https://github.com/openvinotoolkit/stable-diffusion-webui|Github]]
NB OpenVINO acceleration is not working (the script is never loaded).
==Install==
mkdir -p ~/src && cd ~/src
git clone --recursive https://github.com/openvinotoolkit/stable-diffusion-webui stable-diffusion-webui.openvino
cd stable-diffusion-webui
wget "https://raw.githubusercontent.com/openvinotoolkit/stable-diffusion-webui/refs/heads/master/scripts/openvino_accelerate.py" -O scripts/openvino_accelerate.py
==Patch==
/*
diff -u requirements.txt.bak requirements.txt
--- requirements.txt.bak 2024-12-08 10:05:07.531033313 +0000
+++ requirements.txt 2024-12-08 10:21:51.939748587 +0000
@@ -28,7 +28,8 @@
scikit-image>=0.19
timm
tomesd
-torch
+torch==2.1.0
+torchvision==0.16.0
torchdiffeq
torchsde
diffusers
*/
diff -u webui-user.sh.orig webui-user.sh
--- webui-user.sh.orig 2024-12-08 00:47:06.593715977 +0000
+++ webui-user.sh 2024-12-08 09:59:09.850730395 +0000
@@ -9,8 +9,11 @@
# Name of the subdirectory
#clone_dir="stable-diffusion-webui"
+export PYTORCH_TRACING_MODE=TORCHFX
+export USE_OPENVINO=1
+
# Commandline arguments for webui.py, for example: export COMMANDLINE_ARGS="--medvram --opt-split-attention"
-#export COMMANDLINE_ARGS=""
+export COMMANDLINE_ARGS="--skip-torch-cuda-test --precision full --no-half --listen"
# python3 executable
#python_cmd="python3"
==Run==
./webui.sh
===SD.Next===
[[https://github.com/vladmandic/automatic|Github]]
==Install==
mkdir -p ~/src && cd ~/src
git clone --recursive https://github.com/vladmandic/automatic automatic.sd.next
cd automatic
==Run==
The process gets killed with OOM even with 16 GB RAM and 24 GB swap space performing any operation.
./webui.sh --debug --use-openvino --listen --device-id 0
===WEBUI===
[[http://192.168.0.130:7860/|My SD WEBUI]]