Skip to content

Commit

Permalink
bake models
Browse files Browse the repository at this point in the history
  • Loading branch information
ValerioB88 committed Nov 21, 2024
1 parent 6097a87 commit 83c122e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 100 deletions.
90 changes: 41 additions & 49 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Stage 1: Base image with common dependencies
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 as base
FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04 as base

# Prevents prompts from packages asking for user input during installation
ENV DEBIAN_FRONTEND=noninteractive
# Prefer binary wheels over source distributions for faster pip installations
ENV PIP_PREFER_BINARY=1
# Ensures output from python is printed immediately to the terminal without buffering
ENV PYTHONUNBUFFERED=1
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive \
PIP_PREFER_BINARY=1 \
PYTHONUNBUFFERED=1

# Install Python, git and other necessary tools
# Install Python, git, wget, and necessary tools in one step and clean up
RUN apt-get update && apt-get install -y \
python3.10 \
python3-pip \
Expand All @@ -18,44 +16,35 @@ RUN apt-get update && apt-get install -y \
# Clean up to reduce image size
RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*

# Clone ComfyUI repository
RUN git clone https://github.com/comfyanonymous/ComfyUI.git /ComfyUI

# Change working directory to ComfyUI
WORKDIR /ComfyUI/custom_nodes
RUN git clone https://github.com/jags111/efficiency-nodes-comfyui
RUN git clone https://github.com/nonnonstop/comfyui-faster-loading.git
RUN git clone https://github.com/cubiq/ComfyUI_IPAdapter_plus.git
RUN git clone https://github.com/liusida/ComfyUI-AutoCropFaces.git
RUN git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack.git
RUN git clone https://github.com/cubiq/ComfyUI_essentials.git
RUN git clone https://github.com/ltdrdata/ComfyUI-Manager.git

WORKDIR /ComfyUI
# Install ComfyUI dependencies
RUN pip3 install --upgrade --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 \
&& pip3 install --upgrade -r requirements.txt
# Clone ComfyUI and custom nodes
RUN git clone https://github.com/comfyanonymous/ComfyUI.git /ComfyUI &&

#RUN cd /ComfyUI/custom_nodes && \
# git clone https://github.com/jags111/efficiency-nodes-comfyui && \
# git clone https://github.com/nonnonstop/comfyui-faster-loading.git && \
# git clone https://github.com/cubiq/ComfyUI_IPAdapter_plus.git && \
# git clone https://github.com/liusida/ComfyUI-AutoCropFaces.git && \
# git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack.git && \
# git clone https://github.com/cubiq/ComfyUI_essentials.git && \
# git clone https://github.com/ltdrdata/ComfyUI-Manager.git

RUN pip3 install runpod requests
# Install ComfyUI dependencies
RUN pip3 install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cu124 && \
pip3 install --no-cache-dir -r /ComfyUI/requirements.txt

# Support for the network volume
# Install additional dependencies
RUN pip3 install --no-cache-dir runpod requests
ADD src/extra_model_paths.yaml /ComfyUI

# Go back to the root
WORKDIR /

# Add the start and the handler
ADD src/start.sh src/rp_handler.py ./
# Add start scripts and handler
ADD src/start.sh src/rp_handler.py /
RUN chmod +x /start.sh
# Stage 2: Download models
FROM base as downloader

ARG HUGGINGFACE_ACCESS_TOKEN
ARG MODEL_TYPE
# Stage 2: Download models and install additional dependencies
FROM base as downloader

# this should be auto installed by comfyUI but since we are using a network-mounted comfyui needs to be installed here
RUN pip install \
# Install additional Python packages and libraries
RUN pip3 install --no-cache-dir \
segment-anything \
scikit-image \
piexif \
Expand All @@ -69,20 +58,23 @@ RUN pip install \
ultralytics \
"insightface==0.7.3" \
onnxruntime
RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg libsm6 libxext6 && \
apt-get clean -y && rm -rf /var/lib/apt/lists/*

WORKDIR /ComfyUI/custom_nodes/ComfyUI-Impact-Pack
RUN python3 install-manual.py
WORKDIR /
# Run manual installation script for Impact Pack
# WORKDIR /ComfyUI/custom_nodes/ComfyUI-Impact-Pack
# RUN python3 install-manual.py

# Download and extract buffalo_l.zip
RUN mkdir -p /ComfyUI/models/insightface/models/buffalo_l && \
wget -q -O /tmp/buffalo_l.zip https://github.com/deepinsight/insightface/releases/download/v0.7/buffalo_l.zip && \
python3 -c "import zipfile; zip_ref = zipfile.ZipFile('/tmp/buffalo_l.zip', 'r'); zip_ref.extractall('/ComfyUI/models/insightface/models/buffalo_l'); zip_ref.close()" && \
rm -rf /tmp/buffalo_l.zip
# Change working directory to ComfyUI
# WORKDIR /ComfyUI
COPY setup.sh /setup.sh
RUN /bin/bash /setup.sh && \
rm /setup.sh

# Start the container
CMD /start.sh
# Download other models using get_models.sh
# COPY src/get_models.sh /get_models.sh
# RUN /bin/bash /get_models.sh && rm /get_models.sh

# Final setup
CMD ["/start.sh"]
51 changes: 0 additions & 51 deletions setup.sh

This file was deleted.

0 comments on commit 83c122e

Please sign in to comment.