From c2b5df181c363ab737322427dd464baa7e0f61f3 Mon Sep 17 00:00:00 2001
From: Tim Pietrusky
Date: Thu, 24 Apr 2025 11:34:39 +0200
Subject: [PATCH 1/7] ci: test self-hosted runner
---
.github/workflows/runner-test.yml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 .github/workflows/runner-test.yml
diff --git a/.github/workflows/runner-test.yml b/.github/workflows/runner-test.yml
new file mode 100644
index 00000000..626c6180
--- /dev/null
+++ b/.github/workflows/runner-test.yml
@@ -0,0 +1,16 @@
+name: Self-Hosted Runner Test
+
+on:
+ push:
+ branches: ["**"]
+
+jobs:
+ test-runner:
+ name: Check Runner Connectivity
+ runs-on: [self-hosted, linux]
+ steps:
+ - name: Check out repository code
+ uses: actions/checkout@v4
+
+ - name: Confirm Runner Connection
+ run: echo "Successfully connected to and ran on self-hosted runner."
From 075c7fcd6300ad5c6fcffde59e4593e67f7af70e Mon Sep 17 00:00:00 2001
From: Tim Pietrusky
Date: Thu, 24 Apr 2025 11:37:11 +0200
Subject: [PATCH 2/7] ci: check the size of the runner
---
.github/workflows/runner-test.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/runner-test.yml b/.github/workflows/runner-test.yml
index 626c6180..9ab0ec36 100644
--- a/.github/workflows/runner-test.yml
+++ b/.github/workflows/runner-test.yml
@@ -14,3 +14,6 @@ jobs:
- name: Confirm Runner Connection
run: echo "Successfully connected to and ran on self-hosted runner."
+
+ - name: Check Disk Space
+ run: df -h
From 5f10dd307065dd010220bbd6aee5b9d389ba842c Mon Sep 17 00:00:00 2001
From: Tim Pietrusky
Date: Thu, 24 Apr 2025 11:41:40 +0200
Subject: [PATCH 3/7] ci: check the size of the docker cache
---
.github/workflows/runner-test.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/runner-test.yml b/.github/workflows/runner-test.yml
index 9ab0ec36..ab5123b5 100644
--- a/.github/workflows/runner-test.yml
+++ b/.github/workflows/runner-test.yml
@@ -17,3 +17,6 @@ jobs:
- name: Check Disk Space
run: df -h
+
+ - name: Check Docker Disk Usage
+ run: docker system df
From dec78457e991c3ec47344a0080690a840d36fb40 Mon Sep 17 00:00:00 2001
From: Tim Pietrusky
Date: Thu, 24 Apr 2025 13:37:43 +0200
Subject: [PATCH 4/7] refactor: renamed "runpod-worker-comfy" to
"worker-comfyui"
---
.github/CODE_OF_CONDUCT.md | 2 +-
.github/FUNDING.yml | 14 ------
.github/workflows/dev.yml | 2 +-
.github/workflows/release.yml | 4 +-
.github/workflows/test.yml | 2 +-
.releaserc | 2 +-
Dockerfile | 16 +++---
README.md | 91 ++++++++++++++++++-----------------
docker-bake.hcl | 4 +-
docker-compose.yml | 2 +-
requirements.txt | 2 +-
src/restore_snapshot.sh | 6 +--
src/rp_handler.py | 28 +++++------
src/start.sh | 8 +--
14 files changed, 83 insertions(+), 100 deletions(-)
delete mode 100644 .github/FUNDING.yml
diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md
index 176db617..e308d40b 100644
--- a/.github/CODE_OF_CONDUCT.md
+++ b/.github/CODE_OF_CONDUCT.md
@@ -59,7 +59,7 @@ representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
-reported to the community leaders responsible for enforcement at Blibla.
+reported to the community leaders responsible for enforcement at RunPod.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
deleted file mode 100644
index fe603bab..00000000
--- a/.github/FUNDING.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-# These are supported funding model platforms
-
-github: [blib-la]
-patreon: Blib_la
-open_collective: blibla
-ko_fi: # Replace with a single Ko-fi username
-tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
-community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
-liberapay: # Replace with a single Liberapay username
-issuehunt: # Replace with a single IssueHunt username
-lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
-polar: # Replace with a single Polar username
-buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
-custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml
index ede8516e..03597943 100644
--- a/.github/workflows/dev.yml
+++ b/.github/workflows/dev.yml
@@ -8,7 +8,7 @@ on:
jobs:
dev:
- runs-on: ubuntu-latest-l
+ runs-on: [self-hosted, linux]
steps:
- name: Checkout
uses: actions/checkout@v3
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 0a1dc2e2..9734a658 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -8,7 +8,7 @@ on:
jobs:
release:
- runs-on: ubuntu-latest-l
+ runs-on: [self-hosted, linux]
if: ${{ !contains(github.event.head_commit.message, 'chore(release)') }}
permissions:
contents: write
@@ -58,7 +58,7 @@ jobs:
additional-packages: |
['@semantic-release/git', '@semantic-release/changelog', '@semantic-release/exec']
env:
- GITHUB_TOKEN: ${{ secrets.BLIBLA_SEMANTIC_RELEASE }}
+ GITHUB_TOKEN: ${{ secrets.GH_PAT }}
- name: Set environment variables
if: steps.semanticrelease.outputs.new-release-published == 'true'
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index cba3c08c..946b49df 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -9,7 +9,7 @@ on:
jobs:
test:
- runs-on: ubuntu-latest
+ runs-on: [self-hosted, linux]
steps:
- name: Checkout
diff --git a/.releaserc b/.releaserc
index c5e5aa02..7a113926 100644
--- a/.releaserc
+++ b/.releaserc
@@ -15,7 +15,7 @@
[
"@semantic-release/exec",
{
- "prepareCmd": "sed -i \"s/timpietruskyblibla\\/runpod-worker-comfy:[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][0-9]*/timpietruskyblibla\\/runpod-worker-comfy:${nextRelease.version}/g\" README.md"
+ "prepareCmd": "sed -i \"s/runpod\\/worker-comfyui:[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][0-9]*/runpod\\/worker-comfyui:${nextRelease.version}/g\" README.md"
}
],
[
diff --git a/Dockerfile b/Dockerfile
index 3496bba2..de02f30a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,5 @@
# Stage 1: Base image with common dependencies
-FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 as base
+FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu22.04 as base
# Prevents prompts from packages asking for user input during installation
ENV DEBIAN_FRONTEND=noninteractive
@@ -23,25 +23,25 @@ RUN apt-get update && apt-get install -y \
# Clean up to reduce image size
RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
-# Install comfy-cli
-RUN pip install comfy-cli
+# Install uv
+RUN pip install uv
+
+# Install dependencies
+RUN uv pip install comfy-cli runpod requests --system
# Install ComfyUI
-RUN /usr/bin/yes | comfy --workspace /comfyui install --cuda-version 11.8 --nvidia --version 0.3.26
+RUN /usr/bin/yes | comfy --workspace /comfyui install --cuda-version 12.6 --nvidia --version 0.3.29
# Change working directory to ComfyUI
WORKDIR /comfyui
-# Install runpod
-RUN pip install runpod requests
-
# Support for the network volume
ADD src/extra_model_paths.yaml ./
# Go back to the root
WORKDIR /
-# Add scripts
+# Add files
ADD src/start.sh src/restore_snapshot.sh src/rp_handler.py test_input.json ./
RUN chmod +x /start.sh /restore_snapshot.sh
diff --git a/README.md b/README.md
index 0b52ca64..8b736784 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# runpod-worker-comfy
+# worker-comfyui
> [ComfyUI](https://github.com/comfyanonymous/ComfyUI) as a serverless API on [RunPod](https://www.runpod.io/)
@@ -6,7 +6,7 @@
-[](https://www.runpod.io/console/hub/blib-la/runpod-worker-comfy)
+[](https://www.runpod.io/console/hub/runpod-workers/worker-comfyui)
[](https://discord.com/invite/m3TBB9XEkb)
@@ -17,33 +17,33 @@
- [Quickstart](#quickstart)
- [Features](#features)
- [Config](#config)
- * [Upload image to AWS S3](#upload-image-to-aws-s3)
+ - [Upload image to AWS S3](#upload-image-to-aws-s3)
- [Use the Docker image on RunPod](#use-the-docker-image-on-runpod)
- * [Create your template (optional)](#create-your-template-optional)
- * [Create your endpoint](#create-your-endpoint)
- * [GPU recommendations](#gpu-recommendations)
+ - [Create your template (optional)](#create-your-template-optional)
+ - [Create your endpoint](#create-your-endpoint)
+ - [GPU recommendations](#gpu-recommendations)
- [API specification](#api-specification)
- * [JSON Request Body](#json-request-body)
- * [Fields](#fields)
- + ["input.images"](#inputimages)
+ - [JSON Request Body](#json-request-body)
+ - [Fields](#fields)
+ - ["input.images"](#inputimages)
- [Interact with your RunPod API](#interact-with-your-runpod-api)
- * [Health status](#health-status)
- * [Generate an image](#generate-an-image)
- + [Example request for SDXL with cURL](#example-request-for-sdxl-with-curl)
+ - [Health status](#health-status)
+ - [Generate an image](#generate-an-image)
+ - [Example request for SDXL with cURL](#example-request-for-sdxl-with-curl)
- [How to get the workflow from ComfyUI?](#how-to-get-the-workflow-from-comfyui)
- [Bring Your Own Models and Nodes](#bring-your-own-models-and-nodes)
- * [Network Volume](#network-volume)
- * [Custom Docker Image](#custom-docker-image)
- + [Adding Custom Models](#adding-custom-models)
- + [Adding Custom Nodes](#adding-custom-nodes)
- + [Building the Image](#building-the-image)
+ - [Network Volume](#network-volume)
+ - [Custom Docker Image](#custom-docker-image)
+ - [Adding Custom Models](#adding-custom-models)
+ - [Adding Custom Nodes](#adding-custom-nodes)
+ - [Building the Image](#building-the-image)
- [Local testing](#local-testing)
- * [Setup](#setup)
- + [Setup for Windows](#setup-for-windows)
- * [Testing the RunPod handler](#testing-the-runpod-handler)
- * [Local API](#local-api)
- + [Access the local Worker API](#access-the-local-worker-api)
- + [Access local ComfyUI](#access-local-comfyui)
+ - [Setup](#setup)
+ - [Setup for Windows](#setup-for-windows)
+ - [Testing the RunPod handler](#testing-the-runpod-handler)
+ - [Local API](#local-api)
+ - [Access the local Worker API](#access-the-local-worker-api)
+ - [Access local ComfyUI](#access-local-comfyui)
- [Automatically deploy to Docker hub with GitHub Actions](#automatically-deploy-to-docker-hub-with-github-actions)
- [Acknowledgments](#acknowledgments)
@@ -54,11 +54,11 @@
## Quickstart
- 🐳 Choose one of the five available images for your serverless endpoint:
- - `timpietruskyblibla/runpod-worker-comfy:3.6.0-base`: doesn't contain anything, just a clean ComfyUI
- - `timpietruskyblibla/runpod-worker-comfy:3.6.0-flux1-schnell`: contains the checkpoint, text encoders and VAE for [FLUX.1 schnell](https://huggingface.co/black-forest-labs/FLUX.1-schnell)
- - `timpietruskyblibla/runpod-worker-comfy:3.6.0-flux1-dev`: contains the checkpoint, text encoders and VAE for [FLUX.1 dev](https://huggingface.co/black-forest-labs/FLUX.1-dev)
- - `timpietruskyblibla/runpod-worker-comfy:3.6.0-sdxl`: contains the checkpoint and VAE for [Stable Diffusion XL](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0)
- - `timpietruskyblibla/runpod-worker-comfy:3.6.0-sd3`: contains the checkpoint for [Stable Diffusion 3 medium](https://huggingface.co/stabilityai/stable-diffusion-3-medium)
+ - `runpod/worker-comfyui:3.6.0-base`: doesn't contain anything, just a clean ComfyUI
+ - `runpod/worker-comfyui:3.6.0-flux1-schnell`: contains the checkpoint, text encoders and VAE for [FLUX.1 schnell](https://huggingface.co/black-forest-labs/FLUX.1-schnell)
+ - `runpod/worker-comfyui:3.6.0-flux1-dev`: contains the checkpoint, text encoders and VAE for [FLUX.1 dev](https://huggingface.co/black-forest-labs/FLUX.1-dev)
+ - `runpod/worker-comfyui:3.6.0-sdxl`: contains the checkpoint and VAE for [Stable Diffusion XL](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0)
+ - `runpod/worker-comfyui:3.6.0-sd3`: contains the checkpoint for [Stable Diffusion 3 medium](https://huggingface.co/stabilityai/stable-diffusion-3-medium)
- ℹ️ [Use the Docker image on RunPod](#use-the-docker-image-on-runpod)
- 🧪 Pick an [example workflow](./test_resources/workflows/) & [send it to your deployed endpoint](#interact-with-your-runpod-api)
@@ -70,14 +70,14 @@
- Returned as base64-encoded string (default)
- Uploaded to AWS S3 ([if AWS S3 is configured](#upload-image-to-aws-s3))
- There are a few different Docker images to choose from:
- - `timpietruskyblibla/runpod-worker-comfy:3.6.0-flux1-schnell`: contains the [flux1-schnell.safetensors](https://huggingface.co/black-forest-labs/FLUX.1-schnell) checkpoint, the [clip_l.safetensors](https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors) + [t5xxl_fp8_e4m3fn.safetensors](https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors) text encoders and [ae.safetensors](https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/ae.safetensors) VAE for FLUX.1-schnell
- - `timpietruskyblibla/runpod-worker-comfy:3.6.0-flux1-dev`: contains the [flux1-dev.safetensors](https://huggingface.co/black-forest-labs/FLUX.1-dev) checkpoint, the [clip_l.safetensors](https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors) + [t5xxl_fp8_e4m3fn.safetensors](https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors) text encoders and [ae.safetensors](https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/ae.safetensors) VAE for FLUX.1-dev
- - `timpietruskyblibla/runpod-worker-comfy:3.6.0-sdxl`: contains the checkpoints and VAE for Stable Diffusion XL
+ - `runpod/worker-comfyui:3.6.0-flux1-schnell`: contains the [flux1-schnell.safetensors](https://huggingface.co/black-forest-labs/FLUX.1-schnell) checkpoint, the [clip_l.safetensors](https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors) + [t5xxl_fp8_e4m3fn.safetensors](https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors) text encoders and [ae.safetensors](https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/ae.safetensors) VAE for FLUX.1-schnell
+ - `runpod/worker-comfyui:3.6.0-flux1-dev`: contains the [flux1-dev.safetensors](https://huggingface.co/black-forest-labs/FLUX.1-dev) checkpoint, the [clip_l.safetensors](https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors) + [t5xxl_fp8_e4m3fn.safetensors](https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors) text encoders and [ae.safetensors](https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/ae.safetensors) VAE for FLUX.1-dev
+ - `runpod/worker-comfyui:3.6.0-sdxl`: contains the checkpoints and VAE for Stable Diffusion XL
- Checkpoint: [sd_xl_base_1.0.safetensors](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0)
- VAEs:
- [sdxl_vae.safetensors](https://huggingface.co/stabilityai/sdxl-vae/)
- [sdxl-vae-fp16-fix](https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/)
- - `timpietruskyblibla/runpod-worker-comfy:3.6.0-sd3`: contains the [sd3_medium_incl_clips_t5xxlfp8.safetensors](https://huggingface.co/stabilityai/stable-diffusion-3-medium) checkpoint for Stable Diffusion 3 medium
+ - `runpod/worker-comfyui:3.6.0-sd3`: contains the [sd3_medium_incl_clips_t5xxlfp8.safetensors](https://huggingface.co/stabilityai/stable-diffusion-3-medium) checkpoint for Stable Diffusion 3 medium
- [Bring your own models](#bring-your-own-models)
- Based on [Ubuntu + NVIDIA CUDA](https://hub.docker.com/r/nvidia/cuda)
@@ -111,13 +111,13 @@ This is only needed if you want to upload the generated picture to AWS S3. If yo
- Create a [new template](https://runpod.io/console/serverless/user/templates) by clicking on `New Template`
- In the dialog, configure:
- - Template Name: `runpod-worker-comfy` (it can be anything you want)
+ - Template Name: `worker-comfyui` (it can be anything you want)
- Template Type: serverless (change template type to "serverless")
- - Container Image: `/:tag`, in this case: `timpietruskyblibla/runpod-worker-comfy:3.6.0-sd3` (or `-base` for a clean image or `-sdxl` for Stable Diffusion XL or `-flex1-schnell` for FLUX.1 schnell)
+ - Container Image: `/:tag`, in this case: `runpod/worker-comfyui:3.6.0-sd3` (or `-base` for a clean image or `-sdxl` for Stable Diffusion XL or `-flex1-schnell` for FLUX.1 schnell)
- Container Registry Credentials: You can leave everything as it is, as this repo is public
- Container Disk: `20 GB`
- (optional) Environment Variables: [Configure S3](#upload-image-to-aws-s3)
- - Note: You can also not configure it, the images will then stay in the worker. In order to have them stored permanently, [we have to add the network volume](https://github.com/blib-la/runpod-worker-comfy/issues/1)
+ - Note: You can also not configure it, the images will then stay in the worker. In order to have them stored permanently, [we have to add the network volume](https://github.com/runpod-workers/worker-comfyui/issues/1)
- Click on `Save Template`
### Create your endpoint
@@ -132,7 +132,7 @@ This is only needed if you want to upload the generated picture to AWS S3. If yo
- GPUs/Worker: `1`
- Idle Timeout: `5` (you can leave the default)
- Flash Boot: `enabled` (doesn't cost more, but provides faster boot of our worker, which is good)
- - Select Template: `runpod-worker-comfy` (or whatever name you gave your template)
+ - Select Template: `worker-comfyui` (or whatever name you gave your template)
- (optional) Advanced: If you are using a Network Volume, select it under `Select Network Volume`. Otherwise leave the defaults.
- Click `deploy`
@@ -331,17 +331,17 @@ Build your customized Docker image locally:
```bash
# Build the base image
-docker build -t /runpod-worker-comfy:dev-base --target base --platform linux/amd64 .
+docker build -t /worker-comfyui:dev-base --target base --platform linux/amd64 .
# Build the SDXL image
-docker build --build-arg MODEL_TYPE=sdxl -t /runpod-worker-comfy:dev-sdxl --platform linux/amd64 .
+docker build --build-arg MODEL_TYPE=sdxl -t /worker-comfyui:dev-sdxl --platform linux/amd64 .
# Build the SD3 image
-docker build --build-arg MODEL_TYPE=sd3 --build-arg HUGGINGFACE_ACCESS_TOKEN= -t /runpod-worker-comfy:dev-sd3 --platform linux/amd64 .
+docker build --build-arg MODEL_TYPE=sd3 --build-arg HUGGINGFACE_ACCESS_TOKEN= -t /worker-comfyui:dev-sd3 --platform linux/amd64 .
```
> [!NOTE]
-> Ensure to specify `--platform linux/amd64` to avoid errors on RunPod, see [issue #13](https://github.com/blib-la/runpod-worker-comfy/issues/13)
+> Ensure to specify `--platform linux/amd64` to avoid errors on RunPod, see [issue #13](https://github.com/runpod-workers/worker-comfyui/issues/13)
## Local testing
@@ -461,14 +461,15 @@ If you want to use this, you should add these **secrets** to your repository:
And also make sure to add these **variables** to your repository:
-| Variable Name | Description | Example Value |
-| ---------------- | ------------------------------------------------------------ | --------------------- |
-| `DOCKERHUB_REPO` | The repository on Docker Hub where the image will be pushed. | `timpietruskyblibla` |
-| `DOCKERHUB_IMG` | The name of the image to be pushed to Docker Hub. | `runpod-worker-comfy` |
+| Variable Name | Description | Example Value |
+| ---------------- | ------------------------------------------------------------ | ---------------- |
+| `DOCKERHUB_REPO` | The repository on Docker Hub where the image will be pushed. | `runpod` |
+| `DOCKERHUB_IMG` | The name of the image to be pushed to Docker Hub. | `worker-comfyui` |
## Acknowledgments
-- Thanks to [all contributors](https://github.com/blib-la/runpod-worker-comfy/graphs/contributors) for your awesome work
+- Thanks to [Blibla](https://github.com/blib-la) for providing the original repo (previously under blib-la/runpod-worker-comfy) to RunPod, to continue the open-source development of this worker
+- Thanks to [all contributors](https://github.com/runpod-workers/worker-comfyui/graphs/contributors) for your awesome work
- Thanks to [Justin Merrell](https://github.com/justinmerrell) from RunPod for [worker-1111](https://github.com/runpod-workers/worker-a1111), which was used to get inspired on how to create this worker
- Thanks to [Ashley Kleynhans](https://github.com/ashleykleynhans) for [runpod-worker-a1111](https://github.com/ashleykleynhans/runpod-worker-a1111), which was used to get inspired on how to create this worker
- Thanks to [comfyanonymous](https://github.com/comfyanonymous) for creating [ComfyUI](https://github.com/comfyanonymous/ComfyUI), which provides such an awesome API to interact with Stable Diffusion and beyond
diff --git a/docker-bake.hcl b/docker-bake.hcl
index 4e3d094a..588a2128 100644
--- a/docker-bake.hcl
+++ b/docker-bake.hcl
@@ -1,9 +1,9 @@
variable "DOCKERHUB_REPO" {
- default = "timpietruskyblibla"
+ default = "runpod"
}
variable "DOCKERHUB_IMG" {
- default = "runpod-worker-comfy"
+ default = "worker-comfyui"
}
variable "RELEASE_VERSION" {
diff --git a/docker-compose.yml b/docker-compose.yml
index 01d42b2b..294f6502 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,6 +1,6 @@
services:
comfyui-worker:
- image: timpietruskyblibla/runpod-worker-comfy:3.4.0-sdxl
+ image: runpod/worker-comfyui:3.4.0-sdxl
deploy:
resources:
reservations:
diff --git a/requirements.txt b/requirements.txt
index 1e4fbbdd..e079d600 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1 +1 @@
-runpod==1.3.6
\ No newline at end of file
+runpod~=1.7.9
\ No newline at end of file
diff --git a/src/restore_snapshot.sh b/src/restore_snapshot.sh
index 73ba0685..3b5c43c6 100644
--- a/src/restore_snapshot.sh
+++ b/src/restore_snapshot.sh
@@ -5,12 +5,12 @@ set -e
SNAPSHOT_FILE=$(ls /*snapshot*.json 2>/dev/null | head -n 1)
if [ -z "$SNAPSHOT_FILE" ]; then
- echo "runpod-worker-comfy: No snapshot file found. Exiting..."
+ echo "worker-comfyui: No snapshot file found. Exiting..."
exit 0
fi
-echo "runpod-worker-comfy: restoring snapshot: $SNAPSHOT_FILE"
+echo "worker-comfyui: restoring snapshot: $SNAPSHOT_FILE"
comfy --workspace /comfyui node restore-snapshot "$SNAPSHOT_FILE" --pip-non-url
-echo "runpod-worker-comfy: restored snapshot file: $SNAPSHOT_FILE"
\ No newline at end of file
+echo "worker-comfyui: restored snapshot file: $SNAPSHOT_FILE"
\ No newline at end of file
diff --git a/src/rp_handler.py b/src/rp_handler.py
index 314b9057..255753a1 100644
--- a/src/rp_handler.py
+++ b/src/rp_handler.py
@@ -85,7 +85,7 @@ def check_server(url, retries=500, delay=50):
# If the response status code is 200, the server is up and running
if response.status_code == 200:
- print(f"runpod-worker-comfy - API is reachable")
+ print(f"worker-comfyui - API is reachable")
return True
except requests.RequestException as e:
# If an exception occurs, the server may not be ready
@@ -95,7 +95,7 @@ def check_server(url, retries=500, delay=50):
time.sleep(delay / 1000)
print(
- f"runpod-worker-comfy - Failed to connect to server at {url} after {retries} attempts."
+ f"worker-comfyui - Failed to connect to server at {url} after {retries} attempts."
)
return False
@@ -117,7 +117,7 @@ def upload_images(images):
responses = []
upload_errors = []
- print(f"runpod-worker-comfy - image(s) upload")
+ print(f"worker-comfyui - image(s) upload")
for image in images:
name = image["name"]
@@ -138,14 +138,14 @@ def upload_images(images):
responses.append(f"Successfully uploaded {name}")
if upload_errors:
- print(f"runpod-worker-comfy - image(s) upload with errors")
+ print(f"worker-comfyui - image(s) upload with errors")
return {
"status": "error",
"message": "Some images failed to upload",
"details": upload_errors,
}
- print(f"runpod-worker-comfy - image(s) upload complete")
+ print(f"worker-comfyui - image(s) upload complete")
return {
"status": "success",
"message": "All images uploaded successfully",
@@ -239,34 +239,30 @@ def process_output_images(outputs, job_id):
for image in node_output["images"]:
output_images = os.path.join(image["subfolder"], image["filename"])
- print(f"runpod-worker-comfy - image generation is done")
+ print(f"worker-comfyui - image generation is done")
# expected image output folder
local_image_path = f"{COMFY_OUTPUT_PATH}/{output_images}"
- print(f"runpod-worker-comfy - {local_image_path}")
+ print(f"worker-comfyui - {local_image_path}")
# The image is in the output folder
if os.path.exists(local_image_path):
if os.environ.get("BUCKET_ENDPOINT_URL", False):
# URL to image in AWS S3
image = rp_upload.upload_image(job_id, local_image_path)
- print(
- "runpod-worker-comfy - the image was generated and uploaded to AWS S3"
- )
+ print("worker-comfyui - the image was generated and uploaded to AWS S3")
else:
# base64 image
image = base64_encode(local_image_path)
- print(
- "runpod-worker-comfy - the image was generated and converted to base64"
- )
+ print("worker-comfyui - the image was generated and converted to base64")
return {
"status": "success",
"message": image,
}
else:
- print("runpod-worker-comfy - the image does not exist in the output folder")
+ print("worker-comfyui - the image does not exist in the output folder")
return {
"status": "error",
"message": f"the image does not exist in the specified output folder: {local_image_path}",
@@ -314,12 +310,12 @@ def handler(job):
try:
queued_workflow = queue_workflow(workflow)
prompt_id = queued_workflow["prompt_id"]
- print(f"runpod-worker-comfy - queued workflow with ID {prompt_id}")
+ print(f"worker-comfyui - queued workflow with ID {prompt_id}")
except Exception as e:
return {"error": f"Error queuing workflow: {str(e)}"}
# Poll for completion
- print(f"runpod-worker-comfy - wait until image generation is complete")
+ print(f"worker-comfyui - wait until image generation is complete")
retries = 0
try:
while retries < COMFY_POLLING_MAX_RETRIES:
diff --git a/src/start.sh b/src/start.sh
index 6cb5cb84..3725ba79 100644
--- a/src/start.sh
+++ b/src/start.sh
@@ -6,15 +6,15 @@ export LD_PRELOAD="${TCMALLOC}"
# Serve the API and don't shutdown the container
if [ "$SERVE_API_LOCALLY" == "true" ]; then
- echo "runpod-worker-comfy: Starting ComfyUI"
+ echo "worker-comfyui: Starting ComfyUI"
python3 /comfyui/main.py --disable-auto-launch --disable-metadata --listen &
- echo "runpod-worker-comfy: Starting RunPod Handler"
+ echo "worker-comfyui: Starting RunPod Handler"
python3 -u /rp_handler.py --rp_serve_api --rp_api_host=0.0.0.0
else
- echo "runpod-worker-comfy: Starting ComfyUI"
+ echo "worker-comfyui: Starting ComfyUI"
python3 /comfyui/main.py --disable-auto-launch --disable-metadata &
- echo "runpod-worker-comfy: Starting RunPod Handler"
+ echo "worker-comfyui: Starting RunPod Handler"
python3 -u /rp_handler.py
fi
\ No newline at end of file
From de6731c8170b4f23213dea841650c0b02bf7e7b8 Mon Sep 17 00:00:00 2001
From: Tim Pietrusky
Date: Fri, 25 Apr 2025 15:44:43 +0200
Subject: [PATCH 5/7] chore: this was just an example, we add a new one later
---
.runpod/hub.json | 35 -----------------------------------
1 file changed, 35 deletions(-)
delete mode 100644 .runpod/hub.json
diff --git a/.runpod/hub.json b/.runpod/hub.json
deleted file mode 100644
index 26698837..00000000
--- a/.runpod/hub.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "title": "RunPod Worker Comfy",
- "description": "run ComfyUI as serverless endpoint",
- "type": "serverless",
- "category": "image",
- "iconUrl": "https://example.com/icon.png",
- "config": {
- "runsOn": "GPU",
- "containerDiskInGb": 20,
- "presets": [
- {
- "name": "Preset 1",
- "defaults": {
- "STATIC_1": "value_1",
- "STRING_1": "default value 1"
- }
- }
- ],
- "env": [
- {
- "key": "STATIC_VAR",
- "value": "static_value"
- },
- {
- "key": "STRING_VAR",
- "input": {
- "name": "String Input",
- "type": "string",
- "description": "A string input test",
- "default": "new default value"
- }
- }
- ]
- }
-}
From f4c9296501af7d1f6d5808e8216362e451a44470 Mon Sep 17 00:00:00 2001
From: Tim Pietrusky
Date: Fri, 25 Apr 2025 15:46:32 +0200
Subject: [PATCH 6/7] feat: use flux.1-dev-fp8 as default model; added
conventions; improved start
---
Dockerfile | 33 +++++++++++++++++++++------------
docker-compose.yml | 2 +-
docs/conventions.md | 45 +++++++++++++++++++++++++++++++++++++++++++++
src/start.sh | 8 ++++----
4 files changed, 71 insertions(+), 17 deletions(-)
create mode 100644 docs/conventions.md
diff --git a/Dockerfile b/Dockerfile
index de02f30a..08cb3e5f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,5 @@
# Stage 1: Base image with common dependencies
-FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu22.04 as base
+FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu22.04 AS base
# Prevents prompts from packages asking for user input during installation
ENV DEBIAN_FRONTEND=noninteractive
@@ -12,12 +12,12 @@ ENV CMAKE_BUILD_PARALLEL_LEVEL=8
# Install Python, git and other necessary tools
RUN apt-get update && apt-get install -y \
- python3.10 \
+ python3.11 \
python3-pip \
git \
wget \
libgl1 \
- && ln -sf /usr/bin/python3.10 /usr/bin/python \
+ && ln -sf /usr/bin/python3.11 /usr/bin/python \
&& ln -sf /usr/bin/pip3 /usr/bin/pip
# Clean up to reduce image size
@@ -26,11 +26,11 @@ RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
# Install uv
RUN pip install uv
-# Install dependencies
-RUN uv pip install comfy-cli runpod requests --system
+# Install comfy-cli
+RUN uv pip install comfy-cli --system
# Install ComfyUI
-RUN /usr/bin/yes | comfy --workspace /comfyui install --cuda-version 12.6 --nvidia --version 0.3.29
+RUN /usr/bin/yes | comfy --workspace /comfyui install --version 0.3.29 --cuda-version 12.6 --nvidia --skip-manager
# Change working directory to ComfyUI
WORKDIR /comfyui
@@ -41,6 +41,10 @@ ADD src/extra_model_paths.yaml ./
# Go back to the root
WORKDIR /
+# install dependencies
+RUN uv pip install runpod requests --system
+
+
# Add files
ADD src/start.sh src/restore_snapshot.sh src/rp_handler.py test_input.json ./
RUN chmod +x /start.sh /restore_snapshot.sh
@@ -55,18 +59,19 @@ RUN /restore_snapshot.sh
CMD ["/start.sh"]
# Stage 2: Download models
-FROM base as downloader
+FROM base AS downloader
ARG HUGGINGFACE_ACCESS_TOKEN
-ARG MODEL_TYPE
+# Set default model type if none is provided
+ARG MODEL_TYPE=flux1-dev-fp8
# Change working directory to ComfyUI
WORKDIR /comfyui
-# Create necessary directories
-RUN mkdir -p models/checkpoints models/vae
+# Create necessary directories upfront
+RUN mkdir -p models/checkpoints models/vae models/unet models/clip
-# Download checkpoints/vae/LoRA to include in image based on model type
+# Download checkpoints/vae/unet/clip models to include in image based on model type
RUN if [ "$MODEL_TYPE" = "sdxl" ]; then \
wget -O models/checkpoints/sd_xl_base_1.0.safetensors https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors && \
wget -O models/vae/sdxl_vae.safetensors https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors && \
@@ -79,14 +84,18 @@ RUN if [ "$MODEL_TYPE" = "sdxl" ]; then \
wget -O models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors && \
wget -O models/vae/ae.safetensors https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/ae.safetensors; \
elif [ "$MODEL_TYPE" = "flux1-dev" ]; then \
+ # Full precision FLUX.1 dev
wget --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/unet/flux1-dev.safetensors https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/flux1-dev.safetensors && \
wget -O models/clip/clip_l.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors && \
wget -O models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors && \
wget --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/vae/ae.safetensors https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/ae.safetensors; \
+ elif [ "$MODEL_TYPE" = "flux1-dev-fp8" ]; then \
+ # Default model if none specified during build
+ wget -O models/checkpoints/flux1-dev-fp8.safetensors https://huggingface.co/Comfy-Org/flux1-dev/resolve/main/flux1-dev-fp8.safetensors; \
fi
# Stage 3: Final image
-FROM base as final
+FROM base AS final
# Copy models from stage 2 to the final image
COPY --from=downloader /comfyui/models /comfyui/models
diff --git a/docker-compose.yml b/docker-compose.yml
index 294f6502..74820f45 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,6 +1,6 @@
services:
comfyui-worker:
- image: runpod/worker-comfyui:3.4.0-sdxl
+ image: runpod/worker-comfyui:dev
deploy:
resources:
reservations:
diff --git a/docs/conventions.md b/docs/conventions.md
new file mode 100644
index 00000000..307d0cb2
--- /dev/null
+++ b/docs/conventions.md
@@ -0,0 +1,45 @@
+# Introduction
+
+This project (`worker-comfyui`) provides a way to run [ComfyUI](https://github.com/comfyanonymous/ComfyUI) as a serverless API worker on the [RunPod](https://www.runpod.io/) platform. Its main purpose is to allow users to submit ComfyUI image generation workflows via a simple API call and receive the resulting images, either directly as base64-encoded strings or via an upload to an AWS S3 bucket.
+
+It packages ComfyUI into Docker images, manages job handling via the `runpod` SDK, and facilitates configuration through environment variables.
+
+# Project Conventions and Rules
+
+This document outlines the key operational and structural conventions for the `worker-comfyui` project. While there are no strict code-style rules enforced by linters currently, following these conventions ensures consistency and smooth development/deployment.
+
+## 1. Configuration
+
+- **Environment Variables:** All external configurations (e.g., AWS S3 credentials, RunPod behavior modifications like `REFRESH_WORKER`, ComfyUI polling settings) **must** be managed via environment variables.
+- Refer to the main `README.md` sections "Config" and "Upload image to AWS S3" for details on available variables.
+
+## 2. Docker Usage
+
+- **Container-Centric:** Development, testing, and deployment are heavily reliant on Docker.
+- **Platform:** When building Docker images intended for RunPod, **always** use the `--platform linux/amd64` flag to ensure compatibility.
+ ```bash
+ # Example build command
+ docker build --platform linux/amd64 -t my-image:tag .
+ ```
+- **Customization:** Follow the methods in the `README.md` for adding custom models/nodes (Network Volume or Dockerfile edits + snapshots).
+
+## 3. API Interaction
+
+- **Input Structure:** API calls to the `/run` or `/runsync` endpoints must adhere to the JSON structure specified in the `README.md` ("API specification"). The primary key is `input`, containing `workflow` (mandatory object) and `images` (optional array).
+- **Image Encoding:** Input images provided in the `input.images` array must be base64 encoded strings.
+- **Workflow Format:** The `input.workflow` object should contain the JSON exported from ComfyUI using the "Save (API Format)" option (requires enabling "Dev mode Options" in ComfyUI settings).
+
+## 4. Testing
+
+- **Unit Tests:** Automated tests are located in the `tests/` directory and should be run using `python -m unittest discover`. Add new tests for new functionality or bug fixes.
+- **Local Environment:** Use `docker-compose up` for local end-to-end testing. This requires a correctly configured Docker environment with NVIDIA GPU support.
+
+## 5. Dependencies
+
+- **Python:** Manage Python dependencies using `pip` and the `requirements.txt` file. Keep this file up-to-date.
+
+## 6. Code Style (General Guidance)
+
+- While not enforced by tooling, aim for code clarity and consistency. Follow general Python best practices (e.g., PEP 8).
+- Use meaningful variable and function names.
+- Add comments where the logic is non-obvious.
diff --git a/src/start.sh b/src/start.sh
index 3725ba79..1c448ed0 100644
--- a/src/start.sh
+++ b/src/start.sh
@@ -7,14 +7,14 @@ export LD_PRELOAD="${TCMALLOC}"
# Serve the API and don't shutdown the container
if [ "$SERVE_API_LOCALLY" == "true" ]; then
echo "worker-comfyui: Starting ComfyUI"
- python3 /comfyui/main.py --disable-auto-launch --disable-metadata --listen &
+ python /comfyui/main.py --disable-auto-launch --disable-metadata --listen &
echo "worker-comfyui: Starting RunPod Handler"
- python3 -u /rp_handler.py --rp_serve_api --rp_api_host=0.0.0.0
+ python -u /rp_handler.py --rp_serve_api --rp_api_host=0.0.0.0
else
echo "worker-comfyui: Starting ComfyUI"
- python3 /comfyui/main.py --disable-auto-launch --disable-metadata &
+ python /comfyui/main.py --disable-auto-launch --disable-metadata &
echo "worker-comfyui: Starting RunPod Handler"
- python3 -u /rp_handler.py
+ python -u /rp_handler.py
fi
\ No newline at end of file
From a64a4873c8d9f757fa54a09d3251710dcaae0c35 Mon Sep 17 00:00:00 2001
From: Tim Pietrusky
Date: Fri, 25 Apr 2025 15:52:10 +0200
Subject: [PATCH 7/7] chore: deactivated workflows as the runner can't be used
currently
---
.github/workflows/dev.yml | 6 +++---
.github/workflows/release.yml | 6 +++---
.github/workflows/runner-test.yml | 22 ----------------------
.github/workflows/test.yml | 11 ++++++-----
4 files changed, 12 insertions(+), 33 deletions(-)
delete mode 100644 .github/workflows/runner-test.yml
diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml
index 03597943..3b63d13f 100644
--- a/.github/workflows/dev.yml
+++ b/.github/workflows/dev.yml
@@ -2,9 +2,9 @@ name: Development
on:
workflow_dispatch:
- push:
- branches-ignore:
- - main
+# push:
+# branches-ignore:
+# - main
jobs:
dev:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 9734a658..45737be9 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -2,9 +2,9 @@ name: Release
on:
workflow_dispatch:
- push:
- branches:
- - "main"
+# push:
+# branches:
+# - "main"
jobs:
release:
diff --git a/.github/workflows/runner-test.yml b/.github/workflows/runner-test.yml
deleted file mode 100644
index ab5123b5..00000000
--- a/.github/workflows/runner-test.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-name: Self-Hosted Runner Test
-
-on:
- push:
- branches: ["**"]
-
-jobs:
- test-runner:
- name: Check Runner Connectivity
- runs-on: [self-hosted, linux]
- steps:
- - name: Check out repository code
- uses: actions/checkout@v4
-
- - name: Confirm Runner Connection
- run: echo "Successfully connected to and ran on self-hosted runner."
-
- - name: Check Disk Space
- run: df -h
-
- - name: Check Docker Disk Usage
- run: docker system df
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 946b49df..72c0444b 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,11 +1,12 @@
name: Tests
on:
- push:
- branches: [main, dev]
- pull_request:
- types: [opened, synchronize]
- branches: [main, dev]
+ workflow_dispatch:
+# push:
+# branches: [main, dev]
+# pull_request:
+# types: [opened, synchronize]
+# branches: [main, dev]
jobs:
test: