updates UI

This commit is contained in:
mike
2026-07-01 02:25:51 +02:00
parent 66685684c1
commit 145fa686e4
22 changed files with 1559 additions and 159 deletions

41
MI50/deploy.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
# Install/refresh the systemd services for Qwen-Image-Edit on THIS host.
# Host-agnostic: the service user, group and install path are derived at run
# time, so the same file works on tour, hubby, etc.
#
# Run with sudo (needs to write /etc/systemd/system). Assumes bootstrap.sh has
# already created venv/, ComfyUI/ and the models under BASE.
set -e
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)"
exit 1
fi
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # .../comfyui/api
BASE="$( cd "$SCRIPT_DIR/.." && pwd )" # .../comfyui
TEMPLATES="$SCRIPT_DIR/systemd"
# The service should run as the owner of the project, not root.
SVC_USER="${SUDO_USER:-$(stat -c '%U' "$SCRIPT_DIR")}"
SVC_GROUP="$(id -gn "$SVC_USER")"
echo "Installing services: user=$SVC_USER group=$SVC_GROUP base=$BASE"
for unit in comfyui-backend comfyui-api; do
sed -e "s|__USER__|$SVC_USER|g" \
-e "s|__GROUP__|$SVC_GROUP|g" \
-e "s|__BASE__|$BASE|g" \
"$TEMPLATES/$unit.service" > "/etc/systemd/system/$unit.service"
echo " wrote /etc/systemd/system/$unit.service"
done
echo "Reloading systemd daemon..."
systemctl daemon-reload
echo "Enabling + (re)starting services..."
systemctl enable comfyui-backend.service comfyui-api.service
systemctl restart comfyui-backend.service comfyui-api.service
echo "Deployment complete."
echo "Check status with: systemctl status comfyui-backend comfyui-api"

30
MI50/env.sh Normal file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
# Shared path resolver for the Qwen-Image-Edit service scripts.
# Sourced by bootstrap.sh / run_comfyui.sh / start_api.sh.
#
# Why this exists: a Python venv CANNOT live on the NTFS (fuseblk) mount used
# on tour (/media/tour/APPS). Its interpreter symlinks turn into
# "unsupported reparse tag 0x..." after a reboot/remount, so `python`
# vanishes and every service dies. ComfyUI code and the model files are plain
# files and are fine on NTFS -- only the venv must be on a native fs.
#
# So: if BASE is on a non-native filesystem, the venv goes under $HOME (ext4);
# otherwise it stays at $BASE/venv. Override explicitly with COMFY_VENV.
ENV_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # .../comfyui/api
API_DIR="$ENV_DIR"
BASE="$( cd "$ENV_DIR/.." && pwd )" # .../comfyui
COMFY="$BASE/ComfyUI"
_basefs="$(stat -f -c %T "$BASE" 2>/dev/null || echo unknown)"
case "$_basefs" in
fuseblk|ntfs|ntfs3|exfat|vfat|msdos|9p|cifs|smb*)
VENV="${COMFY_VENV:-/home/mike/comfyui/venv}" ;; # NTFS-ish BASE -> venv on home
*)
if [ -d "/home/mike/comfyui/venv" ]; then
VENV="${COMFY_VENV:-/home/mike/comfyui/venv}"
else
VENV="${COMFY_VENV:-$BASE/venv}"
fi
;;
esac

23
MI50/run_comfyui_mi50.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
# Launch the ComfyUI backend (headless) for the Qwen-Image-Edit API.
# gfx906 (MI50) has no flash-attention, so use the pytorch cross-attention path.
set -e
# env.sh resolves BASE/COMFY/VENV (and keeps the venv off NTFS). Portable
# across hosts (tour: /media/tour/APPS/comfyui, hubby: /home/hubby/comfyui).
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/env.sh"
cd "$COMFY"
source "$VENV/bin/activate"
# MI50 / Vega20 is happiest in fp16; avoid bf16 emulation.
export PYTORCH_HIP_ALLOC_CONF="expandable_segments:True,garbage_collection_threshold:0.8"
export HSA_ENABLE_SDMA=0
# Split cross-attention chunks the attention matmul -> much lower peak VRAM,
# which is what lets the 20B Q8 edit model + reference-image sequence fit in 32GB.
# --lowvram offloads models to CPU RAM when not in use, preventing OOM.
exec python main.py \
--listen 127.0.0.1 \
--port 8188 \
--use-split-cross-attention \
--lowvram \
"$@"

23
MI50/start_api.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
# Launch the FastAPI edit service (talks to the local ComfyUI on :8188).
set -e
# env.sh resolves API_DIR/VENV (and keeps the venv off NTFS).
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/env.sh"
source "$VENV/bin/activate"
cd "$API_DIR"
# Add all nvidia CUDA library paths bundled with the venv (needed by onnxruntime-gpu / insightface)
_NV_BASE="$VENV/lib/python3.13/site-packages/nvidia"
_NV_LIBPATH="$_NV_BASE/cuda_runtime/lib:$_NV_BASE/cublas/lib:$_NV_BASE/cudnn/lib:$_NV_BASE/curand/lib:$_NV_BASE/cufft/lib:$_NV_BASE/cusolver/lib:$_NV_BASE/cusparse/lib:$_NV_BASE/nvjitlink/lib:$_NV_BASE/cuda_nvrtc/lib"
export LD_LIBRARY_PATH="${_NV_LIBPATH}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export COMFY_URL="http://127.0.0.1:8188"
export HOST="0.0.0.0"
export PORT="8500"
# Output pixel budget. MI50 is compute-bound on this 20B model:
# ~0.59MP -> ~110s ~0.79MP -> ~140s ~1.0MP -> ~180s (4 steps)
# 0.79MP is a sane speed/quality default; raise for bigger output.
# Lowered to 0.65MP to help prevent GPU OOM on MI50.
export MAX_AREA="${MAX_AREA:-655360}"
exec python edit_api.py

9
MI50/start_watcher.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
# Launch the folder watcher service.
set -e
# env.sh resolves API_DIR/VENV (and keeps the venv off NTFS).
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/env.sh"
source "$VENV/bin/activate"
cd "$API_DIR"
exec python3 watcher.py

18
MI50/stop.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
# Stop and disable systemd services for Qwen-Image-Edit
set -e
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)"
exit 1
fi
echo "Stopping services..."
systemctl stop comfyui-api.service
systemctl stop comfyui-backend.service
echo "Disabling services..."
systemctl disable comfyui-api.service
systemctl disable comfyui-backend.service
echo "Services stopped and disabled."