Skip to content

Commit

Permalink
New image 'nightly'
Browse files Browse the repository at this point in the history
  • Loading branch information
YanWenKun committed Sep 11, 2024
1 parent f686c49 commit 16ced89
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build-nightlyyml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish 'nightly' to Docker Hub

on:
workflow_dispatch: # Can be manually triggered
schedule: # Runs on every Monday, Wednesday, and Friday, at 00:00 UTC
- cron: '0 0 * * 1,3,5'
push:
branches: [ main ]
paths-ignore:
- '**'
- '!nightly/Dockerfile'
- '!.github/workflows/build-nightly.yml'

jobs:

build-publish-nightly:
environment: Publish to Docker Hub
runs-on: ubuntu-latest
steps:
-
name: Get current commit hash
id: commit
uses: prompt/actions-commit-hash@v3
-
name: Maximize build disk space
uses: easimon/maximize-build-space@master
with:
overprovision-lvm: 'true'
remove-android: 'true'
-
name: Git checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESSTOKEN }}
-
name: Build and push 'nightly'
uses: docker/build-push-action@v6
with:
context: ./nightly
file: ./nightly/Dockerfile
tags: |
yanwk/comfyui-boot:nightly
yanwk/comfyui-boot:nightly-${{ steps.commit.outputs.short }}
push: true
152 changes: 152 additions & 0 deletions nightly/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
################################################################################
# Dockerfile that builds 'yanwk/comfyui-boot:nightly'
# A image with preview (nightly) dependencies for ComfyUI.
# Does not download ComfyUI or any models.
#
# Using image from NVIDIA as base image:
# https://catalog.ngc.nvidia.com/orgs/nvidia/containers/cuda/tags
#
# Ubuntu 24.04 comes with GCC 13, so no additional config here.
#
# Note about env vars: in NVIDIA's image, there's no CUDA_HOME or CUDA_PATH.
# Also, the LD_LIBRARY_PATH is intended to point to a non-existent folder.
# Ref: https://gitlab.com/nvidia/container-images/cuda/-/issues/47
################################################################################

FROM nvcr.io/nvidia/cuda:12.6.1-cudnn-devel-ubuntu24.04

RUN --mount=type=cache,target=/var/cache/apt \
apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
python3.12-full \
python3.12-dev \
libegl1-mesa-dev \
git \
cmake \
ninja-build \
aria2 \
curl \
fish \
fd-find \
less \
vim \
ffmpeg \
x264 \
x265 \
&& rm -rf /var/lib/apt/lists/* \
&& rm /usr/lib/python3.12/EXTERNALLY-MANAGED

# In Ubuntu/Debian, PIP packages installed by APT were locked.
# So here we install PIP in a classic way, make it easier to update.
RUN --mount=type=cache,target=/root/.cache/pip \
aria2c https://bootstrap.pypa.io/get-pip.py \
&& python3 get-pip.py \
&& rm get-pip.py \
&& pip install \
wheel setuptools \
&& pip list \
&& df -h

# PyTorch
# Break down the steps, so we have more but smaller image layers.
RUN --mount=type=cache,target=/root/.cache/pip \
pip install \
--dry-run --pre torch torchvision torchaudio \
--index-url https://download.pytorch.org/whl/nightly/cu124

RUN --mount=type=cache,target=/root/.cache/pip \
pip install \
--no-deps --pre torch torchvision torchaudio \
--index-url https://download.pytorch.org/whl/nightly/cu124

RUN --mount=type=cache,target=/root/.cache/pip \
pip install \
--pre torch torchvision torchaudio \
--index-url https://download.pytorch.org/whl/nightly/cu124

# Dependencies
RUN --mount=type=cache,target=/root/.cache/pip \
pip install \
accelerate \
compel \
cupy-cuda12x \
diffusers \
fairscale \
ftfy \
imageio \
joblib \
kornia \
lark \
matplotlib \
onnxruntime \
opencv-contrib-python-headless \
opencv-python-headless \
pandas \
pilgram \
pillow \
pygit2 \
python-ffmpeg \
regex \
scikit-image \
scikit-learn \
scipy \
timm \
torchdiffeq \
torchmetrics \
transformers

RUN --mount=type=cache,target=/root/.cache/pip \
pip install \
-r https://raw.githubusercontent.com/comfyanonymous/ComfyUI/master/requirements.txt \
-r https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/requirements.txt

RUN --mount=type=cache,target=/root/.cache/pip \
pip install \
-r https://raw.githubusercontent.com/crystian/ComfyUI-Crystools/main/requirements.txt \
-r https://raw.githubusercontent.com/cubiq/ComfyUI_essentials/main/requirements.txt \
-r https://raw.githubusercontent.com/cubiq/ComfyUI_FaceAnalysis/main/requirements.txt \
-r https://raw.githubusercontent.com/cubiq/ComfyUI_InstantID/main/requirements.txt \
-r https://raw.githubusercontent.com/Fannovel16/comfyui_controlnet_aux/main/requirements.txt \
-r https://raw.githubusercontent.com/Fannovel16/ComfyUI-Frame-Interpolation/main/requirements-no-cupy.txt \
-r https://raw.githubusercontent.com/FizzleDorf/ComfyUI_FizzNodes/main/requirements.txt \
-r https://raw.githubusercontent.com/jags111/efficiency-nodes-comfyui/main/requirements.txt \
-r https://raw.githubusercontent.com/kijai/ComfyUI-KJNodes/main/requirements.txt \
-r https://raw.githubusercontent.com/ltdrdata/ComfyUI-Impact-Pack/Main/requirements.txt \
-r https://raw.githubusercontent.com/ltdrdata/ComfyUI-Impact-Subpack/main/requirements.txt \
-r https://raw.githubusercontent.com/ltdrdata/ComfyUI-Inspire-Pack/main/requirements.txt \
-r https://raw.githubusercontent.com/melMass/comfy_mtb/main/requirements.txt \
-r https://raw.githubusercontent.com/MrForExample/ComfyUI-3D-Pack/main/requirements.txt \
-r https://raw.githubusercontent.com/storyicon/comfyui_segment_anything/main/requirements.txt \
-r https://raw.githubusercontent.com/yolain/ComfyUI-Easy-Use/main/requirements.txt \
-r https://raw.githubusercontent.com/ZHO-ZHO-ZHO/ComfyUI-InstantID/main/requirements.txt \
&& pip uninstall --break-system-packages --yes \
onnxruntime-gpu \
&& pip --no-cache-dir install --break-system-packages \
onnxruntime-gpu \
--index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ \
--extra-index-url https://pypi.org/simple \
&& pip install \
mediapipe \
&& pip list

RUN du -ah /root \
&& find /root/ -mindepth 1 -delete \
&& df -h

USER root
VOLUME /root
WORKDIR /root
EXPOSE 8188
ENV CLI_ARGS=""

# Let .pyc files be stored in one place
ENV PYTHONPYCACHEPREFIX="/root/.cache/pycache"
# Let PIP install packages to /root/.local
ENV PIP_USER=true
# Add above to PATH
ENV PATH="${PATH}:/root/.local/bin"
# Suppress [WARNING: Running pip as the 'root' user]
ENV PIP_ROOT_USER_ACTION=ignore

CMD ["python3","./ComfyUI/main.py","--listen","--port 8188","${CLI_ARGS}"]
50 changes: 50 additions & 0 deletions nightly/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Docker Image with Preview (Nightly) Dependencies for ComfyUI

image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-nightly.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-nightly.yml"]

https://hub.docker.com/r/yanwk/comfyui-boot/tags?name=nightly[View on <Docker Hub>]

## Note

* This image won't download ComfyUI or any models. Please prepare your ComfyUI suite before running the container.
* `xFormers` is not installed in this image.
It requires building from source in order to use it with PyTorch nightly. And building xFormers (with comprehensive build targets) on GitHub Actions (unpaid version) would often result in halt. So for now it's not included.
## Running

* Don't forget to put ComfyUI in the `storage` folder.
.Using Docker
[source,sh]
----
docker pull yanwk/comfyui-boot:nightly
docker run -it --rm \
--name comfyui-nightly \
--gpus all \
-p 8188:8188 \
-v "$(pwd)"/storage:/root \
-e CLI_ARGS="--fast --preview-method taesd --front-end-version Comfy-Org/ComfyUI_frontend@latest" \
-e PIP_INDEX_URL="https://pypi.org/simple" \
-e HF_ENDPOINT="https://huggingface.co" \
yanwk/comfyui-boot:nightly
----

.Using Podman
[source,sh]
----
podman pull docker.io/yanwk/comfyui-boot:nightly
podman run -it --rm \
--name comfyui-nightly \
--device nvidia.com/gpu=all \
--security-opt label=disable \
--security-opt seccomp=unconfined \
-p 8188:8188 \
-v "$(pwd)"/storage:/root \
-e CLI_ARGS="--fast --preview-method taesd --front-end-version Comfy-Org/ComfyUI_frontend@latest" \
-e PIP_INDEX_URL="https://pypi.org/simple" \
-e HF_ENDPOINT="https://huggingface.co" \
yanwk/comfyui-boot:nightly
----

0 comments on commit 16ced89

Please sign in to comment.