From 32b2a51cdd9372ae01a741fb8ae95b3a18c03d7d Mon Sep 17 00:00:00 2001 From: YAN Wenkun Date: Thu, 14 Nov 2024 06:42:30 +0800 Subject: [PATCH] 'cu121's further break down installation steps --- comfy3d-pt22/Dockerfile | 53 +++++++++++++++++++--------- comfy3d-pt23/Dockerfile | 54 +++++++++++++++++++--------- cu121-megapak/Dockerfile | 76 +++++++++++++++++++++++++++++++++------- cu121/Dockerfile | 43 ++++++++++++++++++----- 4 files changed, 171 insertions(+), 55 deletions(-) diff --git a/comfy3d-pt22/Dockerfile b/comfy3d-pt22/Dockerfile index b42b409..ca07203 100644 --- a/comfy3d-pt22/Dockerfile +++ b/comfy3d-pt22/Dockerfile @@ -50,7 +50,11 @@ libnpp-devel-12-1 RUN --mount=type=cache,target=/var/cache/zypp \ zypper --gpg-auto-import-keys \ install --no-confirm --no-recommends --auto-agree-with-licenses \ -cuda-libraries-12-1 \ +cuda-libraries-12-1 + +RUN --mount=type=cache,target=/var/cache/zypp \ + zypper --gpg-auto-import-keys \ + install --no-confirm --no-recommends --auto-agree-with-licenses \ cuda-libraries-devel-12-1 ENV PATH="${PATH}:/usr/local/cuda-12.1/bin" \ @@ -96,6 +100,12 @@ python311-scikit-learn \ python311-scipy \ python311-svglib \ python311-tqdm \ + && rm /usr/lib64/python3.11/EXTERNALLY-MANAGED \ + && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 100 + +RUN --mount=type=cache,target=/var/cache/zypp \ + zypper --gpg-auto-import-keys \ + install --no-confirm --auto-agree-with-licenses \ Mesa-libGL1 \ Mesa-libEGL-devel \ libgthread-2_0-0 \ @@ -113,9 +123,7 @@ x264 \ x265 \ google-noto-sans-fonts \ google-noto-sans-cjk-fonts \ -google-noto-coloremoji-fonts \ - && rm /usr/lib64/python3.11/EXTERNALLY-MANAGED \ - && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 100 +google-noto-coloremoji-fonts ################################################################################ # GCC 12 @@ -142,28 +150,41 @@ cpp12 \ ################################################################################ # 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 \ - --dry-run xformers==0.0.25.post1 torch==2.2.2 torchvision torchaudio \ - --index-url https://download.pytorch.org/whl/cu121 \ - --extra-index-url https://pypi.org/simple + --upgrade pip wheel setuptools + +ARG PIP_INDEX_URL="https://download.pytorch.org/whl/cu121" +ARG PIP_EXTRA_INDEX_URL="https://pypi.org/simple" RUN --mount=type=cache,target=/root/.cache/pip \ pip install \ - --no-deps xformers==0.0.25.post1 torch==2.2.2 torchvision torchaudio \ - --index-url https://download.pytorch.org/whl/cu121 \ - --extra-index-url https://pypi.org/simple + --dry-run xformers==0.0.25.post1 torch==2.2.2 torchvision torchaudio RUN --mount=type=cache,target=/root/.cache/pip \ pip install \ - xformers==0.0.25.post1 torch==2.2.2 torchvision torchaudio \ - --index-url https://download.pytorch.org/whl/cu121 \ - --extra-index-url https://pypi.org/simple + --no-deps torch==2.2.2 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps xformers==0.0.25.post1 torch==2.2.2 torchvision torchaudio + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps torch==2.2.2 nvidia-cudnn-cu12 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps torch==2.2.2 nvidia-cublas-cu12 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + xformers==0.0.25.post1 torch==2.2.2 torchvision torchaudio + +ARG PIP_INDEX_URL= +ARG PIP_EXTRA_INDEX_URL= RUN --mount=type=cache,target=/root/.cache/pip \ pip install \ diff --git a/comfy3d-pt23/Dockerfile b/comfy3d-pt23/Dockerfile index 2f16435..3221a57 100644 --- a/comfy3d-pt23/Dockerfile +++ b/comfy3d-pt23/Dockerfile @@ -50,7 +50,11 @@ libnpp-devel-12-1 RUN --mount=type=cache,target=/var/cache/zypp \ zypper --gpg-auto-import-keys \ install --no-confirm --no-recommends --auto-agree-with-licenses \ -cuda-libraries-12-1 \ +cuda-libraries-12-1 + +RUN --mount=type=cache,target=/var/cache/zypp \ + zypper --gpg-auto-import-keys \ + install --no-confirm --no-recommends --auto-agree-with-licenses \ cuda-libraries-devel-12-1 ENV PATH="${PATH}:/usr/local/cuda-12.1/bin" \ @@ -96,6 +100,12 @@ python311-scikit-learn \ python311-scipy \ python311-svglib \ python311-tqdm \ + && rm /usr/lib64/python3.11/EXTERNALLY-MANAGED \ + && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 100 + +RUN --mount=type=cache,target=/var/cache/zypp \ + zypper --gpg-auto-import-keys \ + install --no-confirm --auto-agree-with-licenses \ Mesa-libGL1 \ Mesa-libEGL-devel \ libgthread-2_0-0 \ @@ -105,7 +115,6 @@ git \ aria2 \ fish \ fd \ -which \ vim \ opencv \ opencv-devel \ @@ -114,9 +123,7 @@ x264 \ x265 \ google-noto-sans-fonts \ google-noto-sans-cjk-fonts \ -google-noto-coloremoji-fonts \ - && rm /usr/lib64/python3.11/EXTERNALLY-MANAGED \ - && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 100 +google-noto-coloremoji-fonts ################################################################################ # GCC 12 @@ -142,28 +149,41 @@ cpp12 \ ################################################################################ # 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 \ - --dry-run xformers==0.0.26.post1 torch==2.3.0 torchvision torchaudio \ - --index-url https://download.pytorch.org/whl/cu121 \ - --extra-index-url https://pypi.org/simple + --upgrade pip wheel setuptools + +ARG PIP_INDEX_URL="https://download.pytorch.org/whl/cu121" +ARG PIP_EXTRA_INDEX_URL="https://pypi.org/simple" RUN --mount=type=cache,target=/root/.cache/pip \ pip install \ - --no-deps xformers==0.0.26.post1 torch==2.3.0 torchvision torchaudio \ - --index-url https://download.pytorch.org/whl/cu121 \ - --extra-index-url https://pypi.org/simple + --dry-run xformers==0.0.26.post1 torch==2.3.0 torchvision torchaudio RUN --mount=type=cache,target=/root/.cache/pip \ pip install \ - xformers==0.0.26.post1 torch==2.3.0 torchvision torchaudio \ - --index-url https://download.pytorch.org/whl/cu121 \ - --extra-index-url https://pypi.org/simple + --no-deps torch==2.3.0 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps xformers==0.0.26.post1 torch==2.3.0 torchvision torchaudio + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps torch==2.3.0 nvidia-cudnn-cu12 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps torch==2.3.0 nvidia-cublas-cu12 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + xformers==0.0.26.post1 torch==2.3.0 torchvision torchaudio + +ARG PIP_INDEX_URL= +ARG PIP_EXTRA_INDEX_URL= RUN --mount=type=cache,target=/root/.cache/pip \ pip install \ diff --git a/cu121-megapak/Dockerfile b/cu121-megapak/Dockerfile index 29d6b5d..1d14207 100644 --- a/cu121-megapak/Dockerfile +++ b/cu121-megapak/Dockerfile @@ -50,7 +50,11 @@ libnpp-devel-12-1 RUN --mount=type=cache,target=/var/cache/zypp \ zypper --gpg-auto-import-keys \ install --no-confirm --no-recommends --auto-agree-with-licenses \ -cuda-libraries-12-1 \ +cuda-libraries-12-1 + +RUN --mount=type=cache,target=/var/cache/zypp \ + zypper --gpg-auto-import-keys \ + install --no-confirm --no-recommends --auto-agree-with-licenses \ cuda-libraries-devel-12-1 ENV PATH="${PATH}:/usr/local/cuda-12.1/bin" \ @@ -96,6 +100,12 @@ python311-scikit-learn \ python311-scipy \ python311-svglib \ python311-tqdm \ + && rm /usr/lib64/python3.11/EXTERNALLY-MANAGED \ + && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 100 + +RUN --mount=type=cache,target=/var/cache/zypp \ + zypper --gpg-auto-import-keys \ + install --no-confirm --auto-agree-with-licenses \ Mesa-libGL1 \ Mesa-libEGL-devel \ libgthread-2_0-0 \ @@ -113,9 +123,7 @@ x264 \ x265 \ google-noto-sans-fonts \ google-noto-sans-cjk-fonts \ -google-noto-coloremoji-fonts \ - && rm /usr/lib64/python3.11/EXTERNALLY-MANAGED \ - && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 100 +google-noto-coloremoji-fonts ################################################################################ # GCC 12 @@ -146,11 +154,49 @@ cpp12 \ RUN --mount=type=cache,target=/root/.cache/pip \ pip list \ && pip install \ - --upgrade pip wheel setuptools \ - && pip install \ - xformers torchvision torchaudio \ - --index-url https://download.pytorch.org/whl/cu121 \ - --extra-index-url https://pypi.org/simple + --upgrade pip wheel setuptools + +ARG PIP_INDEX_URL="https://download.pytorch.org/whl/cu121" +ARG PIP_EXTRA_INDEX_URL="https://pypi.org/simple" + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --dry-run xformers torchvision torchaudio + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps xformers torchvision torchaudio + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps xformers torch torchvision torchaudio + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps xformers torch nvidia-cudnn-cu12 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps xformers torch nvidia-cublas-cu12 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps xformers torch triton + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps xformers torch nvidia-cusparse-cu12 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps xformers torch nvidia-nccl-cu12 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + xformers torchvision torchaudio + +ARG PIP_INDEX_URL= +ARG PIP_EXTRA_INDEX_URL= # 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. @@ -176,10 +222,14 @@ 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 \ - && pip install \ - -r /builder-scripts/pak5.txt \ - && 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/pak7.txt \ && pip list diff --git a/cu121/Dockerfile b/cu121/Dockerfile index 175955d..cb72a71 100644 --- a/cu121/Dockerfile +++ b/cu121/Dockerfile @@ -35,23 +35,48 @@ RUN --mount=type=cache,target=/root/.cache/pip \ # Install xFormers (stable version, will specify PyTorch version), # and Torchvision + Torchaudio (will downgrade to match xFormers' PyTorch version). # Break down the steps, so we have more but smaller image layers. + +ARG PIP_INDEX_URL="https://download.pytorch.org/whl/cu121" +ARG PIP_EXTRA_INDEX_URL="https://pypi.org/simple" + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --dry-run xformers torchvision torchaudio + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps xformers torchvision torchaudio + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps xformers torch torchvision torchaudio + RUN --mount=type=cache,target=/root/.cache/pip \ pip install \ - --dry-run xformers torchvision torchaudio \ - --index-url https://download.pytorch.org/whl/cu121 \ - --extra-index-url https://pypi.org/simple + --no-deps xformers torch nvidia-cudnn-cu12 RUN --mount=type=cache,target=/root/.cache/pip \ pip install \ - --no-deps xformers torch torchvision torchaudio \ - --index-url https://download.pytorch.org/whl/cu121 \ - --extra-index-url https://pypi.org/simple + --no-deps xformers torch nvidia-cublas-cu12 RUN --mount=type=cache,target=/root/.cache/pip \ pip install \ - xformers torchvision torchaudio \ - --index-url https://download.pytorch.org/whl/cu121 \ - --extra-index-url https://pypi.org/simple + --no-deps xformers torch triton + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps xformers torch nvidia-cusparse-cu12 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + --no-deps xformers torch nvidia-nccl-cu12 + +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install \ + xformers torchvision torchaudio + +ARG PIP_INDEX_URL= +ARG PIP_EXTRA_INDEX_URL= # Dependencies for frequently-used # (Do this firstly so PIP won't be solving too many deps at one time)