Skip to content

Commit

Permalink
use localstorage comfy and models
Browse files Browse the repository at this point in the history
  • Loading branch information
MindSetVision committed Dec 26, 2024
1 parent eb6b61c commit 13b7335
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 42 deletions.
79 changes: 40 additions & 39 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,34 @@ ENV DEBIAN_FRONTEND=noninteractive \

# Install Python, git, wget, and necessary tools in one step and clean up
RUN apt-get update && apt-get install -y \
python3.10 \
python3.11 \
python3-pip \
git \
wget

# Clean up to reduce image size
RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
# RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*


# Clone ComfyUI and custom nodes
RUN git clone https://github.com/comfyanonymous/ComfyUI.git /ComfyUI && \
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 git clone https://github.com/comfyanonymous/ComfyUI.git /ComfyUI && \
# 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

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

# Install additional dependencies
RUN pip3 install --no-cache-dir runpod requests
ADD src/extra_model_paths.yaml /ComfyUI
# RUN pip3 install --no-cache-dir runpod requests
# ADD src/extra_model_paths.yaml /ComfyUI
# Add start scripts and handler
ADD src/start.sh src/rp_handler.py /
RUN chmod +x /start.sh
Expand All @@ -43,37 +44,37 @@ RUN chmod +x /start.sh
FROM base as downloader

Check warning on line 44 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

# Install additional Python packages and libraries
RUN pip3 install --no-cache-dir \
segment-anything \
scikit-image \
piexif \
transformers \
opencv-python-headless \
GitPython \
"scipy>=1.11.4" \
"numpy<2" \
dill \
matplotlib \
ultralytics \
"insightface==0.7.3" \
onnxruntime
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg libsm6 libxext6 && \
apt-get clean -y && rm -rf /var/lib/apt/lists/*
# RUN pip3 install --no-cache-dir \
# segment-anything \
# scikit-image \
# piexif \
# transformers \
# opencv-python-headless \
# GitPython \
# "scipy>=1.11.4" \
# "numpy<2" \
# dill \
# matplotlib \
# ultralytics \
# "insightface==0.7.3" \
# onnxruntime
# RUN apt-get update && apt-get install -y --no-install-recommends \
# ffmpeg libsm6 libxext6 && \
# apt-get clean -y && rm -rf /var/lib/apt/lists/*

# Run manual installation script for Impact Pack
WORKDIR /ComfyUI/custom_nodes/ComfyUI-Impact-Pack
RUN python3 install-manual.py
# 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
# 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

# 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"]
CMD ["/start.sh"]
4 changes: 3 additions & 1 deletion src/rp_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ def process_output_images(outputs, job_id):
"""

# The path where ComfyUI stores the generated images
COMFY_OUTPUT_PATH = os.environ.get("COMFY_OUTPUT_PATH", "/ComfyUI/output")
COMFY_OUTPUT_PATH = os.environ.get(
"COMFY_OUTPUT_PATH", "/runpod-volume/ComfyUI/output"
)

output_images = []

Expand Down
4 changes: 2 additions & 2 deletions src/start.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash

export PATH="/runpod-volume/bcomfy/bin:$PATH"
# Use libtcmalloc for better memory management
TCMALLOC="$(ldconfig -p | grep -Po "libtcmalloc.so.\d" | head -n 1)"
export LD_PRELOAD="${TCMALLOC}"
Expand All @@ -13,8 +13,8 @@ if [ "$SERVE_API_LOCALLY" == "true" ]; then
python3 -u /rp_handler.py --rp_serve_api --rp_api_host=0.0.0.0
else
echo "runpod-worker-comfy: Starting ComfyUI"
python3 runpod-volume/ComfyUI/main.py --disable-auto-launch --disable-metadata &
# python3 /ComfyUI/main.py --disable-auto-launch --disable-metadata &
python3 /ComfyUI/main.py --disable-auto-launch --disable-metadata &
echo "runpod-worker-comfy: Starting RunPod Handler"
python3 -u /rp_handler.py
fi

0 comments on commit 13b7335

Please sign in to comment.