Skip to content

Commit

Permalink
Add 'comfy3d-pt22'
Browse files Browse the repository at this point in the history
  • Loading branch information
YanWenKun committed Jul 25, 2024
1 parent de029e3 commit c375863
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build-comfy3d-pt22.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Publish 'comfy3d-pt22' to Docker Hub

on:
workflow_dispatch: # Can be manually triggered

jobs:

build-publish-comfy3d-pt22:
environment: Publish to Docker Hub
runs-on: ubuntu-latest
steps:
-
name: Get current date
id: date
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
-
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 'comfy3d-pt22'
uses: docker/build-push-action@v6
with:
context: ./comfy3d-pt22
file: ./comfy3d-pt22/Dockerfile
tags: |
yanwk/comfyui-boot:comfy3d-pt22
yanwk/comfyui-boot:comfy3d-pt22-${{ steps.date.outputs.date }}
push: true
76 changes: 76 additions & 0 deletions comfy3d-pt22/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
################################################################################
# Dockerfile that builds 'yanwk/comfyui-boot:comfy3d-pt22'
# An environment for running ComfyUI with ComfyUI-3D-Pack.
# Using PyTorch 2.2
# Comfy3D Version: https://github.com/MrForExample/ComfyUI-3D-Pack/tree/3b4e715939376634c68aa4c1c7d4ea4a8665c098
################################################################################

# https://gitlab.com/nvidia/container-images/cuda
# https://catalog.ngc.nvidia.com/orgs/nvidia/containers/cuda/tags
FROM nvcr.io/nvidia/cuda:12.1.1-cudnn8-devel-ubi9

LABEL maintainer="YAN Wenkun <code@yanwk.fun>"

################################################################################
# Python and tools
# GCC 11 & Make is already included in the base image.

RUN --mount=type=cache,target=/var/cache/dnf \
set -eu \
&& dnf upgrade -y --disablerepo cuda \
&& dnf install -y \
python3.11-devel \
python3.11-pip \
python3.11-Cython \
python3.11-numpy \
python3.11-requests \
python3.11-scipy \
python3.11-urllib3 \
git \
git-lfs \
less \
mesa-libGL \
mesa-libEGL \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 100 \
&& update-alternatives --install /usr/bin/pip pip /usr/bin/pip3.11 100

################################################################################
# Python Packages
# Comfy3D doesn't use ONNX Runtime, so this image skipped it.

RUN --mount=type=cache,target=/root/.cache/pip \
pip list \
&& pip install \
--upgrade pip wheel setuptools \
&& pip install \
xformers==0.0.25.post1 torchvision torchaudio \
--index-url https://download.pytorch.org/whl/cu121 \
--extra-index-url https://pypi.org/simple \
&& pip install \
-r https://raw.githubusercontent.com/comfyanonymous/ComfyUI/master/requirements.txt \
-r https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/requirements.txt \
-r https://raw.githubusercontent.com/MrForExample/ComfyUI-3D-Pack/3b4e715939376634c68aa4c1c7d4ea4a8665c098/requirements.txt \
&& pip install \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v2/diff_gaussian_rasterization-0.0.0-cp311-cp311-linux_x86_64.whl \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v2/kiui-0.2.7-py3-none-any.whl \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v2/nvdiffrast-0.3.1-py3-none-any.whl \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v2/pointnet2_ops-3.0.0-cp311-cp311-linux_x86_64.whl \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v2/pytorch3d-0.7.6-cp311-cp311-linux_x86_64.whl \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v2/simple_knn-0.0.0-cp311-cp311-linux_x86_64.whl \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v2/torch_scatter-2.1.2-cp311-cp311-linux_x86_64.whl \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v2/torchmcubes-0.1.0-cp311-cp311-linux_x86_64.whl \
&& pip list

################################################################################

RUN du -ah /root \
&& rm -rf /root/* /root/.*

COPY runner-scripts/. /runner-scripts/

USER root
VOLUME /root
WORKDIR /root
EXPOSE 8188
ENV CLI_ARGS=""
CMD ["bash","/runner-scripts/entrypoint.sh"]
45 changes: 45 additions & 0 deletions comfy3d-pt22/runner-scripts/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

set -euo pipefail

# Regex that matches REPO_NAME
# First from pattern [https://example.com/xyz/REPO_NAME.git] or [git@example.com:xyz/REPO_NAME.git]
# Second from pattern [http(s)://example.com/xyz/REPO_NAME]
# They all extract REPO_NAME to BASH_REMATCH[2]
function clone_or_pull () {
if [[ $1 =~ ^(.*[/:])(.*)(\.git)$ ]] || [[ $1 =~ ^(http.*\/)(.*)$ ]]; then
echo "${BASH_REMATCH[2]}" ;
set +e ;
git clone --depth=1 --no-tags --recurse-submodules --shallow-submodules "$1" \
|| git -C "${BASH_REMATCH[2]}" pull --ff-only ;
set -e ;
else
echo "[ERROR] Invalid URL: $1" ;
return 1 ;
fi ;
}


echo "########################################"
echo "[INFO] Downloading ComfyUI & Manager..."
echo "########################################"

cd /root
clone_or_pull https://github.com/comfyanonymous/ComfyUI.git

cd /root/ComfyUI/custom_nodes
clone_or_pull https://github.com/ltdrdata/ComfyUI-Manager.git


echo "########################################"
echo "[INFO] Downloading Custom Nodes..."
echo "########################################"

cd /root/ComfyUI/custom_nodes

clone_or_pull https://github.com/MrForExample/ComfyUI-3D-Pack.git
git -C ComfyUI-3D-Pack reset --hard 3b4e715939376634c68aa4c1c7d4ea4a8665c098


# Finish
touch /root/.download-complete
52 changes: 52 additions & 0 deletions comfy3d-pt22/runner-scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

set -e

# 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 ;

# Install ComfyUI
cd /root
if [ ! -f "/root/.download-complete" ] ; then
chmod +x /runner-scripts/download.sh
bash /runner-scripts/download.sh
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 "########################################"
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 ${CLI_ARGS}
4 changes: 4 additions & 0 deletions comfy3d-pt22/runner-scripts/pre-start.sh.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -eu

echo "[INFO] Continue without pre-start script."
22 changes: 22 additions & 0 deletions comfy3d-pt22/runner-scripts/set-proxy.sh.example
Original file line number Diff line number Diff line change
@@ -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."

0 comments on commit c375863

Please sign in to comment.