From b7a6d35c88384ff70c25e4d0bf0975d2ae5d96e4 Mon Sep 17 00:00:00 2001 From: Derek Holloway Date: Mon, 7 Jul 2025 03:53:01 +0000 Subject: [PATCH] Update dockerfile --- dockerfile | 135 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 99 insertions(+), 36 deletions(-) diff --git a/dockerfile b/dockerfile index 5137385..b23f144 100644 --- a/dockerfile +++ b/dockerfile @@ -1,61 +1,124 @@ -FROM nvidia/cuda:12.8.1-cudnn-runtime-oraclelinux8 +# Get cuda version from https://hub.docker.com/r/nvidia/cuda +FROM nvidia/cuda:12.9.1-devel-ubuntu20.04 AS build-deps -# Get release version from https://github.com/comfyanonymous/ComfyUI/releases -ENV ComfyUI_Release=0.3.43 +ENV TZ=Etc/UTC +ENV DEBIAN_FRONTEND=noninteractive # Install build dependencies -RUN dnf update -y && dnf install -y \ - gcc \ - gcc-c++ \ +RUN apt update -y && \ + apt install -y software-properties-common && \ + add-apt-repository ppa:ubuntu-toolchain-r/test && \ + apt update && \ + apt install -y \ + curl \ + gcc-13 \ + g++-13 \ make \ wget \ - libffi-devel \ - openssl-devel \ - bzip2-devel \ - zlib-devel \ - xz-devel \ - readline-devel \ - sqlite-devel && \ - dnf clean all + libffi-dev \ + libssl-dev \ + libbz2-dev \ + zlib1g-dev \ + liblzma-dev \ + libreadline-dev \ + libsqlite3-dev \ + libopenblas-dev \ + libblas-dev \ + libjpeg-dev \ + libpng-dev \ + libavcodec-dev \ + libavformat-dev \ + libswscale-dev \ + libomp-dev \ + libnuma-dev \ + m4 \ + cmake \ + git \ + ninja-build \ + libprotobuf-dev \ + protobuf-compiler \ + libeigen3-dev \ + zip \ + unzip -# Set workdir for python +# Build Python from source +FROM build-deps AS build-python WORKDIR /usr/src -# Download Python 3.11 source code (adjust version as needed) -RUN wget https://www.python.org/ftp/python/3.11.6/Python-3.11.6.tgz && \ - tar xzf Python-3.11.6.tgz +# Get release version from https://www.python.org/downloads/source/ +ARG Python_Release=3.12.11 -# Set new workdir for python -WORKDIR /usr/src/Python-3.11.6 +RUN wget https://www.python.org/ftp/python/${Python_Release}/Python-${Python_Release}.tgz && \ + tar xzf Python-${Python_Release}.tgz + +WORKDIR /usr/src/Python-${Python_Release} -# Build and install Python 3.11 RUN ./configure --enable-optimizations && \ make -j$(nproc) && \ make altinstall -# Set python3.11 as default python and pip -RUN ln -sf /usr/local/bin/python3.11 /usr/bin/python && \ - ln -sf /usr/local/bin/pip3.11 /usr/bin/pip +RUN Python_Version=$(echo "$Python_Release" | cut -d. -f1,2) && \ + ln -sf /usr/local/bin/python$Python_Version /usr/bin/python && \ + ln -sf /usr/local/bin/pip$Python_Version /usr/bin/pip -# Set workdir for application download +# Build pytorch from souce +FROM build-python AS build-pytorch +WORKDIR /usr/src + +# Get release version from https://github.com/pytorch/pytorch/releases +ARG Pytorch_Release=2.7.1 +# Set the number of jobs for the Pytorch_Build -> (Gb of RAM)/17 rounded down to the nearest whole number +ARG Pytorch_Jobs=4 +# Set the CUDA arch to compile for +ARG CUDA_ARCH_LIST="7.5;8.0;8.6;8.9" + +RUN git clone --recursive -b v${Pytorch_Release} https://github.com/pytorch/pytorch.git +WORKDIR /usr/src/pytorch + +ENV USE_CUDA=1 \ + USE_CUDNN=1 \ + BUILD_CAFFE2=0 \ + USE_DISTRIBUTED=0 \ + USE_FBGEMM=0 \ + USE_MKLDNN=0 \ + USE_NCCL=0 \ + USE_QNNPACK=0 \ + USE_XNNPACK=0 \ + USE_OPENMP=0 \ + USE_TENSORPIPE=0 \ + USE_SYSTEM_EIGEN_INSTALL=0 \ + BUILD_TEST=0 \ + CMAKE_PREFIX_PATH="/usr/local/cuda" \ + CUDA_HOME="/usr/local/cuda" \ + USE_NVRTC=1 + +RUN python -m pip install numpy typing_extensions future sympy + +RUN pip install -r requirements.txt + +RUN git submodule sync && \ + git submodule update --init --recursive + +RUN MAX_JOBS=${Pytorch_Jobs} && \ + TORCH_CUDA_ARCH_LIST=${CUDA_ARCH_LIST} && \ + python setup.py install + +# Build ComfyUI from source +FROM build-pytorch AS publish WORKDIR /app -# Pull source and extract -RUN wget https://github.com/comfyanonymous/ComfyUI/archive/refs/tags/v${ComfyUI_Release}.tar.gz && \ - tar xzf v${ComfyUI_Release}.tar.gz && \ - rm v${ComfyUI_Release}.tar.gz && \ - mv /app/ComfyUI-${ComfyUI_Release} /app/comfyui/ +# Get release version from https://github.com/comfyanonymous/ComfyUI/releases +ARG ComfyUI_Release=0.3.43 -# Set workdir for application +RUN wget https://github.com/comfyanonymous/ComfyUI/archive/refs/tags/v${ComfyUI_Release}.tar.gz && \ + tar xzf v${ComfyUI_Release}.tar.gz && \ + rm v${ComfyUI_Release}.tar.gz && \ + mv /app/ComfyUI-${ComfyUI_Release} /app/comfyui/ WORKDIR /app/comfyui -# Upgrade pip and install dependencies RUN python -m pip install --upgrade pip && \ - python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu128 && \ python -m pip install -r requirements.txt -# Expose the port EXPOSE 8188 -# Start CompyUI -CMD ["python", "main.py"] \ No newline at end of file +CMD ["python", "main.py", "--listen", "0.0.0.0"]