From e0c302bcdd42e9c3d5804326ed4d420c59761126 Mon Sep 17 00:00:00 2001 From: Andy Bunce Date: Sat, 13 Dec 2025 11:04:32 +0000 Subject: [PATCH] [add] comfy xpu --- comfyui.xpu/Dockerfile | 188 ++++++++++++++++++ comfyui.xpu/README.txt | 104 ++++++++++ comfyui.xpu/builder-scripts/generate-pak5.sh | 51 +++++ comfyui.xpu/builder-scripts/pak3.txt | 30 +++ comfyui.xpu/builder-scripts/pak5.txt | 55 +++++ comfyui.xpu/builder-scripts/pak7.txt | 7 + comfyui.xpu/builder-scripts/pak9.txt | 3 + comfyui.xpu/builder-scripts/pakA.txt | 6 + comfyui.xpu/builder-scripts/preload-cache.sh | 86 ++++++++ comfyui.xpu/docker-compose.yml | 28 +++ comfyui.xpu/runner-scripts/entrypoint.sh | 62 ++++++ .../runner-scripts/pre-start.sh.example | 4 + .../runner-scripts/set-proxy.sh.example | 22 ++ 13 files changed, 646 insertions(+) create mode 100644 comfyui.xpu/Dockerfile create mode 100644 comfyui.xpu/README.txt create mode 100644 comfyui.xpu/builder-scripts/generate-pak5.sh create mode 100644 comfyui.xpu/builder-scripts/pak3.txt create mode 100644 comfyui.xpu/builder-scripts/pak5.txt create mode 100644 comfyui.xpu/builder-scripts/pak7.txt create mode 100644 comfyui.xpu/builder-scripts/pak9.txt create mode 100644 comfyui.xpu/builder-scripts/pakA.txt create mode 100644 comfyui.xpu/builder-scripts/preload-cache.sh create mode 100644 comfyui.xpu/docker-compose.yml create mode 100644 comfyui.xpu/runner-scripts/entrypoint.sh create mode 100644 comfyui.xpu/runner-scripts/pre-start.sh.example create mode 100644 comfyui.xpu/runner-scripts/set-proxy.sh.example diff --git a/comfyui.xpu/Dockerfile b/comfyui.xpu/Dockerfile new file mode 100644 index 0000000..ec463d5 --- /dev/null +++ b/comfyui.xpu/Dockerfile @@ -0,0 +1,188 @@ +################################################################################ +# Dockerfile that builds 'yanwk/comfyui-boot:xpu' +# A runtime environment for https://github.com/comfyanonymous/ComfyUI +# Running on XPU (Intel GPU). +# Does NOT install IPEX (Intel Extension for PyTorch). +# Using Python 3.13, GCC 14. +# Using 'root' inside the container. +################################################################################ + +FROM fedora:42 + +LABEL maintainer="code@yanwk.fun" + +RUN set -eu + +################################################################################ +# OS Packages + +RUN --mount=type=cache,target=/var/cache/dnf \ + dnf install -y --nogpgcheck \ + 'https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-42.noarch.rpm' \ + && dnf upgrade -y \ + && dnf install -y \ +python3.13-devel \ +python3-pip \ +python3-wheel \ +python3-setuptools \ +python3-cython \ +make \ +ninja \ +python3-cmake + +# RUN --mount=type=cache,target=/var/cache/dnf \ +# dnf install -y \ +# python3-matplotlib \ +# python3-mpmath \ +# python3-numpy \ +# python3-onnx + +RUN --mount=type=cache,target=/var/cache/dnf \ + dnf install -y \ +ffmpeg \ +x264 \ +x265 \ +default-fonts-cjk + +RUN --mount=type=cache,target=/var/cache/dnf \ + dnf install -y \ +python3-opencv \ +python3-cairo + +RUN --mount=type=cache,target=/var/cache/dnf \ + dnf install -y \ +mesa-libGL \ +mesa-libEGL \ +# python3-GitPython \ +git \ +# python3-pandas \ +# python3-scikit-build-core \ +# python3-scikit-image \ +# python3-scikit-learn \ +fish \ +aria2 \ +fd-find \ +vim \ +which + +RUN --mount=type=cache,target=/var/cache/dnf \ + dnf install -y \ +intel-compute-runtime \ +intel-level-zero \ +intel-level-zero-devel \ +oneapi-level-zero \ +oneapi-level-zero-devel \ +intel-ocloc \ +intel-opencl \ +intel-igc \ +clinfo \ +openssl + +################################################################################ +# GCC 14 +# Fedora 42 defaults to GCC 15 + +RUN --mount=type=cache,target=/var/cache/dnf \ + dnf install -y \ +gcc14 \ +gcc14-c++ \ + && update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-14 90 \ + && update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-14 90 \ + && update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-14 90 \ + && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 90 \ + && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 90 \ + && update-alternatives --install /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-14 90 \ + && update-alternatives --install /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-14 90 \ + && update-alternatives --install /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-14 90 \ + && update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-14 90 \ + && update-alternatives --install /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-14 90 \ + && update-alternatives --install /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-14 90 + +# ################################################################################ +# PyTorch (No IPEX) + +ARG PIP_ROOT_USER_ACTION='ignore' +ARG PIP_NO_BUILD_ISOLATION=1 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip list \ + && pip install \ + --upgrade pip wheel setuptools + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --dry-run torch torchvision torchaudio \ + --index-url https://download.pytorch.org/whl/xpu \ + && pip install \ + --no-deps torch \ + --index-url https://download.pytorch.org/whl/xpu + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + torch torchvision torchaudio \ + --index-url https://download.pytorch.org/whl/xpu + +# Deps for ComfyUI & custom nodes +COPY builder-scripts/. /builder-scripts/ + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + -r /builder-scripts/pak3.txt + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + -r /builder-scripts/pak5.txt + +# Temp fix for SentencePiece on CMAKE 4+ +ENV CMAKE_POLICY_VERSION_MINIMUM=3.5 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + -r /builder-scripts/pak7.txt + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + -r /builder-scripts/pak9.txt + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + -r /builder-scripts/pakA.txt + +# Ensure deps match +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + torch torchvision torchaudio \ + --index-url https://download.pytorch.org/whl/xpu + +################################################################################ + +WORKDIR /default-comfyui-bundle + +RUN bash /builder-scripts/preload-cache.sh + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + -r '/default-comfyui-bundle/ComfyUI/requirements.txt' \ + -r '/default-comfyui-bundle/ComfyUI/manager_requirements.txt' \ + && pip list + +################################################################################ + +ENV LD_LIBRARY_PATH="/usr/local/lib\ +:/usr/local/lib64/python3.13/site-packages/torch/lib/\ +${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" + +################################################################################ + +RUN df -h \ + && du -ah /root \ + && find /root/ -mindepth 1 -delete + +COPY runner-scripts/. /runner-scripts/ + +USER root +VOLUME /root +WORKDIR /root +EXPOSE 8188 +ENV CLI_ARGS="" +CMD ["bash","/runner-scripts/entrypoint.sh"] diff --git a/comfyui.xpu/README.txt b/comfyui.xpu/README.txt new file mode 100644 index 0000000..a962c65 --- /dev/null +++ b/comfyui.xpu/README.txt @@ -0,0 +1,104 @@ +Usage +----- + +1. Check the Linux Kernel Module (driver) for Intel GPU: + + lsmod | grep -i xe + + For desktop distros with rolling-ish kernel updates, xe is usually included already. + +2. Search and install `intel-compute-runtime` (or similar) with your host OS' package manager. + If not found, just ignore it and run directly. + + For Ubuntu, follow this instruction and install the compute-related packages: + https://dgpu-docs.intel.com/driver/client/overview.html + +3. Run the container: + +==== +mkdir -p \ + storage \ + storage-models/models \ + storage-models/hf-hub \ + storage-models/torch-hub \ + storage-user/input \ + storage-user/output \ + storage-user/workflows + +podman run -it --rm \ + --name comfyui-xpu \ + --device=/dev/dri \ + --ipc=host \ + --security-opt label=disable \ + -p 8188:8188 \ + -v "$(pwd)"/storage:/root \ + -v "$(pwd)"/storage-models/models:/root/ComfyUI/models \ + -v "$(pwd)"/storage-models/hf-hub:/root/.cache/huggingface/hub \ + -v "$(pwd)"/storage-models/torch-hub:/root/.cache/torch/hub \ + -v "$(pwd)"/storage-user/input:/root/ComfyUI/input \ + -v "$(pwd)"/storage-user/output:/root/ComfyUI/output \ + -v "$(pwd)"/storage-user/workflows:/root/ComfyUI/user/default/workflows \ + -e CLI_ARGS="--disable-smart-memory --async-offload" \ + yanwk/comfyui-boot:xpu +==== + +Note: + +1. "--disable-smart-memory" is useful for XPU, although it consumes more RAM. +2. "--async-offload" gives subtle improvement and no visible harm. + +More CLI_ARGS: + +--lowvram +--bf16-unet +--bf16-vae +--bf16-text-enc +--mmap-torch-files +--reserve-vram 1 + +Check the doc before use: +https://github.com/comfyanonymous/ComfyUI/blob/master/comfy/cli_args.py + + +Test result on Arc B580 +----------------------- + +Time on generating one 1024x1024px image (pre-warmed, only infer time) + +* SD 1.5 (20-step): OK (5s) | 512x512: GOOD (1s) +* SDXL (28-step): OK (6s) +* SDXL Refiner (20+5-step): OK (4+1s) +* Stable Cascade (20+10-step): FAST (3+3s) +* SD 3.5 large fp8 (20-step): GOOD (26s) +* Flux1 schnell (4-step): GOOD (8s) +* Flux1 dev fp8 (20-step): GOOD (35s) +* Flux1 Krea dev (20-step): OK (46s) + +* Hunyuan3D 2.0 (Comfy Repackaged): 'Non-uniform work-groups are not supported by the target device' +* StableZero123: 'Non-uniform work-groups are not supported by the target device' + +* Wan 2.2 5B Text to Video (640x352, 121 frames): FAST (60s, very poor quality) +* Wan 2.2 5B Text to Video (960x544, 121 frames): OK (181s, low quality) +* Wan 2.2 5B Text to Video (1280x704, 121 frames): FAILED (OOM) + + +Notes +-------------- + +1. Once OOM, ComfyUI won't crash, but GPU will stop responding + for future prompt (UR_RESULT_ERROR_DEVICE_LOST). + In that case, you will need to restart ComfyUI. + +2. IPEX (Intel Extension for PyTorch) is not included, as most of its features + have been merged upstream and it is being phased out: + https://github.com/intel/intel-extension-for-pytorch/releases + + +For Windows Users +----------------- + +Just use Intel AI Playground: +https://game.intel.com/us/stories/introducing-ai-playground/ + +Or yet another ComfyUI portable: +https://github.com/YanWenKun/ComfyUI-WinPortable-XPU diff --git a/comfyui.xpu/builder-scripts/generate-pak5.sh b/comfyui.xpu/builder-scripts/generate-pak5.sh new file mode 100644 index 0000000..303d645 --- /dev/null +++ b/comfyui.xpu/builder-scripts/generate-pak5.sh @@ -0,0 +1,51 @@ +#!/bin/bash +set -eu + +echo '#' > pak5.txt + +array=( +https://github.com/comfyanonymous/ComfyUI/raw/refs/heads/master/requirements.txt +https://github.com/Comfy-Org/ComfyUI-Manager/raw/refs/heads/main/requirements.txt +# Performance +https://github.com/openvino-dev-samples/comfyui_openvino/raw/refs/heads/main/requirements.txt +https://github.com/welltop-cn/ComfyUI-TeaCache/raw/refs/heads/main/requirements.txt +https://github.com/city96/ComfyUI-GGUF/raw/refs/heads/main/requirements.txt +# Workspace +https://github.com/crystian/ComfyUI-Crystools/raw/refs/heads/main/requirements.txt +# General +https://github.com/ltdrdata/was-node-suite-comfyui/raw/refs/heads/main/requirements.txt +https://github.com/kijai/ComfyUI-KJNodes/raw/refs/heads/main/requirements.txt +https://github.com/jags111/efficiency-nodes-comfyui/raw/refs/heads/main/requirements.txt +https://github.com/yolain/ComfyUI-Easy-Use/raw/refs/heads/main/requirements.txt +# Control +https://github.com/ltdrdata/ComfyUI-Impact-Pack/raw/refs/heads/Main/requirements.txt +https://github.com/ltdrdata/ComfyUI-Impact-Subpack/raw/refs/heads/main/requirements.txt +https://github.com/ltdrdata/ComfyUI-Inspire-Pack/raw/refs/heads/main/requirements.txt +https://github.com/Fannovel16/comfyui_controlnet_aux/raw/refs/heads/main/requirements.txt +https://github.com/Gourieff/ComfyUI-ReActor/raw/refs/heads/main/requirements.txt +https://github.com/huchenlei/ComfyUI-layerdiffuse/raw/refs/heads/main/requirements.txt +https://github.com/kijai/ComfyUI-Florence2/raw/refs/heads/main/requirements.txt +# Video +https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite/raw/refs/heads/main/requirements.txt +https://github.com/Fannovel16/ComfyUI-Frame-Interpolation/raw/refs/heads/main/requirements-no-cupy.txt +https://github.com/melMass/comfy_mtb/raw/refs/heads/main/requirements.txt +# Pending Removal +https://github.com/cubiq/ComfyUI_essentials/raw/refs/heads/main/requirements.txt +) + +for line in "${array[@]}"; + do curl -w "\n" -sSL "${line}" >> pak5.txt +done + +sed -i '/^#/d' pak5.txt +sed -i 's/[[:space:]]*$//' pak5.txt +sed -i 's/>=.*$//' pak5.txt +sed -i 's/_/-/g' pak5.txt + +# Don't "sort foo.txt >foo.txt". See: https://stackoverflow.com/a/29244408 +sort -ufo pak5.txt pak5.txt + +# Remove duplicate items, compare to pak3.txt +grep -Fixv -f pak3.txt pak5.txt > temp.txt && mv temp.txt pak5.txt + +echo " generated. Check before use." diff --git a/comfyui.xpu/builder-scripts/pak3.txt b/comfyui.xpu/builder-scripts/pak3.txt new file mode 100644 index 0000000..de5bb2f --- /dev/null +++ b/comfyui.xpu/builder-scripts/pak3.txt @@ -0,0 +1,30 @@ +accelerate +compel +diffusers +fairscale +ftfy +gguf +huggingface-hub[cli] +imageio +joblib +kornia +lark +matplotlib +omegaconf +onnx +opencv-contrib-python-headless +pandas +pilgram +pillow +protobuf +pygit2 +python-ffmpeg +regex +scikit-build-core +scikit-image +scikit-learn +scipy +timm +torchdiffeq +torchmetrics +transformers diff --git a/comfyui.xpu/builder-scripts/pak5.txt b/comfyui.xpu/builder-scripts/pak5.txt new file mode 100644 index 0000000..ee7765b --- /dev/null +++ b/comfyui.xpu/builder-scripts/pak5.txt @@ -0,0 +1,55 @@ +addict +aiohttp +albumentations +alembic +av +cachetools +chardet +clip-interrogator +color-matcher +colour-science +deepdiff +dill +einops +filelock +fvcore +GitPython +imageio-ffmpeg +importlib-metadata +mss +numba +peft +piexif +pixeloe +psutil +py-cpuinfo +pydantic-settings +pydantic +PyGithub +python-dateutil +pyyaml +qrcode[pil] +rembg +requirements-parser +rich +rich-argparse +safetensors +segment-anything +sentencepiece +simpleeval +spandrel +SQLAlchemy +tokenizers +toml +torchsde +tqdm +transparent-background +trimesh[easy] +typer +typing-extensions +ultralytics +uv +webcolors +yacs +yapf +yarl diff --git a/comfyui.xpu/builder-scripts/pak7.txt b/comfyui.xpu/builder-scripts/pak7.txt new file mode 100644 index 0000000..b5a4e21 --- /dev/null +++ b/comfyui.xpu/builder-scripts/pak7.txt @@ -0,0 +1,7 @@ +dlib +facexlib +insightface +git+https://github.com/facebookresearch/sam2.git +git+https://github.com/ltdrdata/cstr.git +git+https://github.com/ltdrdata/ffmpy.git +git+https://github.com/ltdrdata/img2texture.git diff --git a/comfyui.xpu/builder-scripts/pak9.txt b/comfyui.xpu/builder-scripts/pak9.txt new file mode 100644 index 0000000..d43dc32 --- /dev/null +++ b/comfyui.xpu/builder-scripts/pak9.txt @@ -0,0 +1,3 @@ +# https://www.intel.com/content/www/us/en/developer/tools/openvino-toolkit/download.html +onnxruntime +onnxruntime-openvino diff --git a/comfyui.xpu/builder-scripts/pakA.txt b/comfyui.xpu/builder-scripts/pakA.txt new file mode 100644 index 0000000..d04117a --- /dev/null +++ b/comfyui.xpu/builder-scripts/pakA.txt @@ -0,0 +1,6 @@ +# https://www.intel.com/content/www/us/en/developer/tools/openvino-toolkit/download.html +# https://github.com/openvino-dev-samples/comfyui_openvino/blob/main/requirements.txt +--pre +--extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly +openvino +openvino-genai diff --git a/comfyui.xpu/builder-scripts/preload-cache.sh b/comfyui.xpu/builder-scripts/preload-cache.sh new file mode 100644 index 0000000..de00cda --- /dev/null +++ b/comfyui.xpu/builder-scripts/preload-cache.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +set -euo pipefail + +gcs() { + git clone --depth=1 --no-tags --recurse-submodules --shallow-submodules "$@" +} + +echo "########################################" +echo "[INFO] Downloading ComfyUI & Nodes..." +echo "########################################" + +cd /default-comfyui-bundle +git clone 'https://github.com/comfyanonymous/ComfyUI.git' +cd /default-comfyui-bundle/ComfyUI +# Using stable version (has a release tag) +git reset --hard "$(git tag | grep -e '^v' | sort -V | tail -1)" + +# Force ComfyUI-Manager to use PIP instead of UV +mkdir -p /default-comfyui-bundle/ComfyUI/user/__manager + +cat < /default-comfyui-bundle/ComfyUI/user/__manager/config.ini +[default] +use_uv = False +EOF + +cd /default-comfyui-bundle/ComfyUI/custom_nodes + +# Performance +gcs https://github.com/openvino-dev-samples/comfyui_openvino.git +gcs https://github.com/welltop-cn/ComfyUI-TeaCache.git +gcs https://github.com/city96/ComfyUI-GGUF.git + +# Workspace +gcs https://github.com/crystian/ComfyUI-Crystools.git + +# General +gcs https://github.com/ltdrdata/was-node-suite-comfyui.git +gcs https://github.com/kijai/ComfyUI-KJNodes.git +gcs https://github.com/bash-j/mikey_nodes.git +gcs https://github.com/chrisgoringe/cg-use-everywhere.git +gcs https://github.com/jags111/efficiency-nodes-comfyui.git +gcs https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git +gcs https://github.com/rgthree/rgthree-comfy.git +gcs https://github.com/shiimizu/ComfyUI_smZNodes.git +gcs https://github.com/yolain/ComfyUI-Easy-Use.git + +# Control +gcs https://github.com/ltdrdata/ComfyUI-Impact-Pack.git +gcs https://github.com/ltdrdata/ComfyUI-Impact-Subpack.git +gcs https://github.com/ltdrdata/ComfyUI-Inspire-Pack.git +gcs https://github.com/Fannovel16/comfyui_controlnet_aux.git +gcs https://github.com/florestefano1975/comfyui-portrait-master.git +gcs https://github.com/huchenlei/ComfyUI-layerdiffuse.git +gcs https://github.com/kijai/ComfyUI-Florence2.git +gcs https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet.git +gcs https://github.com/mcmonkeyprojects/sd-dynamic-thresholding.git +gcs https://github.com/twri/sdxl_prompt_styler.git + +# Video +gcs https://github.com/Fannovel16/ComfyUI-Frame-Interpolation.git +gcs https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git +gcs https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git +gcs https://github.com/melMass/comfy_mtb.git + +# More +gcs https://github.com/pythongosssss/ComfyUI-WD14-Tagger.git +gcs https://github.com/SLAPaper/ComfyUI-Image-Selector.git +gcs https://github.com/ssitu/ComfyUI_UltimateSDUpscale.git + +# To be removed in future +gcs https://github.com/cubiq/ComfyUI_essentials.git +gcs https://github.com/Gourieff/ComfyUI-ReActor.git ComfyUI-ReActor.disabled + + +echo "########################################" +echo "[INFO] Downloading Models..." +echo "########################################" + +# VAE Models +cd /default-comfyui-bundle/ComfyUI/models/vae + +aria2c 'https://github.com/madebyollin/taesd/raw/refs/heads/main/taesdxl_decoder.pth' +aria2c 'https://github.com/madebyollin/taesd/raw/refs/heads/main/taesd_decoder.pth' +aria2c 'https://github.com/madebyollin/taesd/raw/refs/heads/main/taesd3_decoder.pth' +aria2c 'https://github.com/madebyollin/taesd/raw/refs/heads/main/taef1_decoder.pth' diff --git a/comfyui.xpu/docker-compose.yml b/comfyui.xpu/docker-compose.yml new file mode 100644 index 0000000..f5ef7f5 --- /dev/null +++ b/comfyui.xpu/docker-compose.yml @@ -0,0 +1,28 @@ +# Compose file for Intel GPU + +services: + + comfyui: + init: true + container_name: comfyui-xpu + build: + context: . + dockerfile: Dockerfile + image: "yanwk/comfyui-boot:xpu" + ports: + - "8188:8188" + volumes: + - "./storage:/root" + - "./storage-models/models:/root/ComfyUI/models" + - "./storage-models/hf-hub:/root/.cache/huggingface/hub" + - "./storage-models/torch-hub:/root/.cache/torch/hub" + - "./storage-user/input:/root/ComfyUI/input" + - "./storage-user/output:/root/ComfyUI/output" + - "./storage-user/workflows:/root/ComfyUI/user/default/workflows" + environment: + - CLI_ARGS= + devices: + - /dev/dri + ipc: host + security_opt: + - label:disable diff --git a/comfyui.xpu/runner-scripts/entrypoint.sh b/comfyui.xpu/runner-scripts/entrypoint.sh new file mode 100644 index 0000000..1232a95 --- /dev/null +++ b/comfyui.xpu/runner-scripts/entrypoint.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +set -e + +echo "########################################" + +# Run user's set-proxy script +cd /root +if [ ! -f "/root/user-scripts/set-proxy.sh" ] ; then + mkdir -p /root/user-scripts + cp /runner-scripts/set-proxy.sh.example /root/user-scripts/set-proxy.sh +else + echo "[INFO] Running set-proxy script..." + + chmod +x /root/user-scripts/set-proxy.sh + source /root/user-scripts/set-proxy.sh +fi ; + +# Copy ComfyUI from cache to workdir if it doesn't exist +cd /root +if [ ! -f "/root/ComfyUI/main.py" ] ; then + mkdir -p /root/ComfyUI + # 'cp --archive': all file timestamps and permissions will be preserved + # 'cp --update=none': do not overwrite + if cp --archive --update=none "/default-comfyui-bundle/ComfyUI/." "/root/ComfyUI/" ; then + echo "[INFO] Setting up ComfyUI..." + echo "[INFO] Using image-bundled ComfyUI (copied to workdir)." + else + echo "[ERROR] Failed to copy ComfyUI bundle to '/root/ComfyUI'" >&2 + exit 1 + fi +else + echo "[INFO] Using existing ComfyUI in user storage..." +fi + +# Run user's pre-start script +cd /root +if [ ! -f "/root/user-scripts/pre-start.sh" ] ; then + mkdir -p /root/user-scripts + cp /runner-scripts/pre-start.sh.example /root/user-scripts/pre-start.sh +else + echo "[INFO] Running pre-start script..." + + chmod +x /root/user-scripts/pre-start.sh + source /root/user-scripts/pre-start.sh +fi ; + +echo "[INFO] Starting ComfyUI..." +echo "########################################" + +# Let .pyc files be stored in one place +export PYTHONPYCACHEPREFIX="/root/.cache/pycache" +# Let PIP install packages to /root/.local +export PIP_USER=true +# Add above to PATH +export PATH="${PATH}:/root/.local/bin" +# Suppress [WARNING: Running pip as the 'root' user] +export PIP_ROOT_USER_ACTION=ignore + +cd /root + +python3 ./ComfyUI/main.py --listen --port 8188 --enable-manager ${CLI_ARGS} diff --git a/comfyui.xpu/runner-scripts/pre-start.sh.example b/comfyui.xpu/runner-scripts/pre-start.sh.example new file mode 100644 index 0000000..dba55bb --- /dev/null +++ b/comfyui.xpu/runner-scripts/pre-start.sh.example @@ -0,0 +1,4 @@ +#!/bin/bash +set -eu + +echo "[INFO] Continue without pre-start script." diff --git a/comfyui.xpu/runner-scripts/set-proxy.sh.example b/comfyui.xpu/runner-scripts/set-proxy.sh.example new file mode 100644 index 0000000..8801050 --- /dev/null +++ b/comfyui.xpu/runner-scripts/set-proxy.sh.example @@ -0,0 +1,22 @@ +#!/bin/bash +set -eu + +# Tip: Within containers, you cannot access your host machine via 127.0.0.1. +# You will need "host.docker.internal"(for Docker) or "host.containers.internal"(for Podman) + +# Example of setting proxy +#export HTTP_PROXY=http://host.docker.internal:1081 +#export HTTPS_PROXY=$HTTP_PROXY +#export http_proxy=$HTTP_PROXY +#export https_proxy=$HTTP_PROXY +#export NO_PROXY="localhost,*.local,*.internal,[::1],fd00::/7, +#10.0.0.0/8,127.0.0.0/8,169.254.0.0/16,172.16.0.0/12,192.168.0.0/16, +#10.*,127.*,169.254.*,172.16.*,172.17.*,172.18.*,172.19.*,172.20.*, +#172.21.*,172.22.*,172.23.*,172.24.*,172.25.*,172.26.*,172.27.*, +#172.28.*,172.29.*,172.30.*,172.31.*,172.32.*,192.168.*, +#*.cn,ghproxy.com,*.ghproxy.com,ghproxy.org,*.ghproxy.org, +#gh-proxy.com,*.gh-proxy.com,ghproxy.net,*.ghproxy.net" +#export no_proxy=$NO_PROXY +#echo "[INFO] Proxy set to $HTTP_PROXY" + +echo "[INFO] Continue without proxy."