From 4cbf83893b8b795bf4c4815a1bd5bb198e77c743 Mon Sep 17 00:00:00 2001 From: Brian Gebel Date: Mon, 28 Apr 2025 17:14:26 -0700 Subject: [PATCH 1/5] upgrade pytorch and comfy --- services/comfy/Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/services/comfy/Dockerfile b/services/comfy/Dockerfile index a58f25a..74a1288 100644 --- a/services/comfy/Dockerfile +++ b/services/comfy/Dockerfile @@ -1,13 +1,12 @@ -FROM pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime +FROM pytorch/pytorch:2.7.0-cuda12.8-cudnn9-runtime ENV DEBIAN_FRONTEND=noninteractive ENV PIP_PREFER_BINARY=1 -ENV APPLICATION_ROOT=/stable-diffusion ENV NVIDIA_VISIBLE_DEVICES=all ENV PYTHONPATH="${PYTHONPATH}:${PWD}" ENV CLI_ARGS="" -WORKDIR ${APPLICATION_ROOT} +WORKDIR /app # Explore how we can use the CLI to do this instead # https://docs.comfy.org/installation/system_requirements @@ -15,7 +14,7 @@ WORKDIR ${APPLICATION_ROOT} RUN apt-get update && \ apt-get install -y git && \ apt-get clean && \ - git clone --branch v0.3.19 --depth 1 https://github.com/comfyanonymous/ComfyUI.git ${APPLICATION_ROOT} + git clone --branch v0.3.30 --depth 1 https://github.com/comfyanonymous/ComfyUI.git . COPY . . From 8a615e26378a3730cf96c0eb68a94c138b5e88d5 Mon Sep 17 00:00:00 2001 From: Brian Gebel Date: Mon, 28 Apr 2025 20:15:00 -0700 Subject: [PATCH 2/5] add onnxruntime for more advanced nodes --- services/comfy/Dockerfile | 42 ++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/services/comfy/Dockerfile b/services/comfy/Dockerfile index 74a1288..0289fbc 100644 --- a/services/comfy/Dockerfile +++ b/services/comfy/Dockerfile @@ -1,26 +1,44 @@ -FROM pytorch/pytorch:2.7.0-cuda12.8-cudnn9-runtime +FROM pytorch/pytorch:2.7.0-cuda12.8-cudnn9-runtime AS base ENV DEBIAN_FRONTEND=noninteractive ENV PIP_PREFER_BINARY=1 -ENV NVIDIA_VISIBLE_DEVICES=all -ENV PYTHONPATH="${PYTHONPATH}:${PWD}" -ENV CLI_ARGS="" -WORKDIR /app +RUN apt-get update && \ + apt-get install -y git wget curl libgl1-mesa-glx libglib2.0-0 && \ + apt-get clean # Explore how we can use the CLI to do this instead # https://docs.comfy.org/installation/system_requirements # https://docs.comfy.org/comfy-cli/getting-started -RUN apt-get update && \ - apt-get install -y git && \ - apt-get clean && \ - git clone --branch v0.3.30 --depth 1 https://github.com/comfyanonymous/ComfyUI.git . +FROM base AS application -COPY . . +RUN useradd -m -s /bin/bash comfy -RUN --mount=type=cache,target=/root/.cache/pip \ +USER comfy + +WORKDIR /home/comfy/app + +# Using CLI (with conda venv -can do venv without all this too) +# python -m pip install -U pip && \ +# pip install comfy-cli && \ +# conda init bash && \ +# conda create -n comfy-env python=3.11 && \ +# conda activate comfy-env && \ +# comfy install +RUN git clone --branch v0.3.30 --depth 1 https://github.com/comfyanonymous/ComfyUI.git . && \ + mkdir -p .local/bin && \ pip install -r requirements.txt && \ - chmod u+x ./entrypoint.sh + pip install onnxruntime onnxruntime_gpu + +COPY --chown=comfy:comfy . . + +RUN chmod u+x ./entrypoint.sh + +ENV PATH="/home/comfy/.local/bin:${PATH}" +ENV PYTHONPATH="${PYTHONPATH}:${PWD}" + +ENV NVIDIA_VISIBLE_DEVICES=all +ENV CLI_ARGS="" EXPOSE 7860 From dc9aaeaf26e1d5f1fee7c60f706f1eb3626ae862 Mon Sep 17 00:00:00 2001 From: Brian Gebel Date: Mon, 28 Apr 2025 20:36:51 -0700 Subject: [PATCH 3/5] fixing issues with middleware --- TASK.md | 3 +++ services/comfy/Dockerfile | 2 +- services/comfy/extra_model_paths.yaml | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/TASK.md b/TASK.md index 51c5c64..353fa84 100644 --- a/TASK.md +++ b/TASK.md @@ -1,3 +1,6 @@ +- [] Fix Mappings for models `/data/models` and `data/config/comfy/models` the later is created by ComfyManager +- [] Add out of the box support for onnx but make it configurable (optional) not backed into the image +- [] Run everything in an venv - [] Update docker-compose to be a more readable - [] Add support for swarm - [] Pin / configurable versions diff --git a/services/comfy/Dockerfile b/services/comfy/Dockerfile index 0289fbc..0b78143 100644 --- a/services/comfy/Dockerfile +++ b/services/comfy/Dockerfile @@ -28,7 +28,7 @@ WORKDIR /home/comfy/app RUN git clone --branch v0.3.30 --depth 1 https://github.com/comfyanonymous/ComfyUI.git . && \ mkdir -p .local/bin && \ pip install -r requirements.txt && \ - pip install onnxruntime onnxruntime_gpu + # pip install onnxruntime-gpu # Should make it so this can be included maybe through a mountable requirements.txt or yaml? COPY --chown=comfy:comfy . . diff --git a/services/comfy/extra_model_paths.yaml b/services/comfy/extra_model_paths.yaml index 5ce0e3a..c470f0b 100644 --- a/services/comfy/extra_model_paths.yaml +++ b/services/comfy/extra_model_paths.yaml @@ -28,3 +28,8 @@ comfyui: # clip_vision: data/config/comfy/clip_vision # diffusers: data/config/comfy/diffusers # download_model_base: data/models + +# Need this file to be loaded dynamically maybe as a vol? +# - `ultralytics_bbox` - Specifies the paths for bbox YOLO models. +# - `ultralytics_segm` - Specifies the paths for segm YOLO models. +# - `ultralytics` - Allows the presence of `bbox/` and `segm/` subdirectories. \ No newline at end of file From 024d49ba75171df21ba1c8f91189183c92bd4e9a Mon Sep 17 00:00:00 2001 From: Brian Gebel Date: Mon, 28 Apr 2025 20:49:56 -0700 Subject: [PATCH 4/5] record some bugs --- TASK.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/TASK.md b/TASK.md index 353fa84..fd1a6e4 100644 --- a/TASK.md +++ b/TASK.md @@ -9,4 +9,27 @@ - [] generally better workflow vol mappings - [] Update download to use a manifest / mapping. - [] Create a APP for managing manifests, output, etc -- [] Drop docker support for A111 build alternative using ComfyUI wtih preset workflows in rep \ No newline at end of file +- [] Drop docker support for A111 build alternative using ComfyUI wtih preset workflows in rep + +``` + WAS Node Suite: Image file saved to: /data/output/2025-04-29/1745898150_character_refined_0001.png +comfy-1 | Failed to find /data/config/comfy/custom_nodes/comfyui_controlnet_aux/ckpts/lllyasviel/Annotators/body_pose_model.pth. +comfy-1 | Downloading from huggingface.co +comfy-1 | cacher folder is /tmp, you can change it by custom_tmp_path in config.yaml +comfy-1 | /home/comfy/.local/lib/python3.11/site-packages/huggingface_hub/file_download.py:896: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`. +comfy-1 | warnings.warn( +comfy-1 | /home/comfy/.local/lib/python3.11/site-packages/huggingface_hub/file_download.py:933: UserWarning: `local_dir_use_symlinks` parameter is deprecated and will be ignored. The process to download files to a local folder has been updated and do not rely on symlinks anymore. You only need to pass a destination folder as`local_dir`. +comfy-1 | For more details, check out https://huggingface.co/docs/huggingface_hub/main/en/guides/download#download-files-to-local-folder. +comfy-1 | warnings.warn( +comfy-1 | [Errno 2] No such file or directory: '/tmp/ckpts' +comfy-1 | model_path is /data/config/comfy/custom_nodes/comfyui_controlnet_aux/ckpts/lllyasviel/Annotators/body_pose_model.pth +comfy-1 | Failed to find /data/config/comfy/custom_nodes/comfyui_controlnet_aux/ckpts/lllyasviel/Annotators/hand_pose_model.pth. +comfy-1 | Downloading from huggingface.co +comfy-1 | cacher folder is /tmp, you can change it by custom_tmp_path in config.yaml +comfy-1 | [Errno 2] No such file or directory: '/tmp/ckpts' +comfy-1 | model_path is /data/config/comfy/custom_nodes/comfyui_controlnet_aux/ckpts/lllyasviel/Annotators/hand_pose_model.pth +comfy-1 | Failed to find /data/config/comfy/custom_nodes/comfyui_controlnet_aux/ckpts/lllyasviel/Annotators/facenet.pth. +comfy-1 | Downloading from huggingface.co +comfy-1 | cacher folder is /tmp, you can change it by custom_tmp_path in config.yaml +comfy-1 | [Errno 2] No such file or directory: '/tmp/ckpts' +comfy-1 | model_path is /data/config/comfy/custom_nodes/comfyui_controlnet_aux/ckpts/lllyasviel/Annotators/facenet.pth \ No newline at end of file From ce64863be9dfef8d34fbb05b55f3c1e59064ff4f Mon Sep 17 00:00:00 2001 From: Brian Gebel Date: Tue, 29 Apr 2025 07:22:34 -0700 Subject: [PATCH 5/5] add onnx --- services/comfy/Dockerfile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/services/comfy/Dockerfile b/services/comfy/Dockerfile index 0b78143..d349d7a 100644 --- a/services/comfy/Dockerfile +++ b/services/comfy/Dockerfile @@ -3,8 +3,9 @@ FROM pytorch/pytorch:2.7.0-cuda12.8-cudnn9-runtime AS base ENV DEBIAN_FRONTEND=noninteractive ENV PIP_PREFER_BINARY=1 -RUN apt-get update && \ - apt-get install -y git wget curl libgl1-mesa-glx libglib2.0-0 && \ +RUN --mount=type=cache,target=/var/cache/apt \ + apt-get update && \ + apt-get install -y git wget curl jq ffmpeg libgl1-mesa-glx libglib2.0-0 && \ apt-get clean # Explore how we can use the CLI to do this instead @@ -25,10 +26,12 @@ WORKDIR /home/comfy/app # conda create -n comfy-env python=3.11 && \ # conda activate comfy-env && \ # comfy install -RUN git clone --branch v0.3.30 --depth 1 https://github.com/comfyanonymous/ComfyUI.git . && \ +RUN --mount=type=cache,target=/comfy/.cache/pip \ + git clone --branch v0.3.30 --depth 1 https://github.com/comfyanonymous/ComfyUI.git . && \ mkdir -p .local/bin && \ pip install -r requirements.txt && \ - # pip install onnxruntime-gpu # Should make it so this can be included maybe through a mountable requirements.txt or yaml? + pip install onnxruntime-gpu +# Should make ONNX optional by moving this into a configuration file that can be alterated at run time COPY --chown=comfy:comfy . .