Better sync update

This commit is contained in:
Madiator2011 2024-09-12 14:07:03 +02:00 committed by GitHub
parent b10b94fbcb
commit d6186ec00a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 78 additions and 32 deletions

View file

@ -4,14 +4,21 @@ FROM madiator2011/better-base:cuda12.1 as base
ARG PYTHON_VERSION1=3.11 ARG PYTHON_VERSION1=3.11
ARG TORCH=torch==2.3.0+cu121 ARG TORCH=torch==2.3.0+cu121
# Install fpart (which includes fpsync)
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y fpart && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Stage 2: ComfyUI Installation # Stage 2: ComfyUI Installation
FROM base as comfyui-install FROM base as comfyui-install
# Create virtual environment in /workspace/venv # Create virtual environment
RUN python -m venv /workspace/venv RUN mkdir -p /workspace/runpod-venvs && python -m venv /workspace/runpod-venvs/better-comfyui
# Set environment variables for the virtual environment # Set environment variables for the virtual environment
ENV VIRTUAL_ENV="/workspace/venv" ENV VIRTUAL_ENV="/workspace/runpod-venvs/better-comfyui"
ENV PATH="$VIRTUAL_ENV/bin:$PATH" ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Activate the virtual environment and install packages # Activate the virtual environment and install packages
@ -37,7 +44,7 @@ ARG INCLUDE_MODELS=false
# Download each model in a separate layer # Download each model in a separate layer
RUN if [ "${INCLUDE_MODELS}" = "true" ]; then \ RUN if [ "${INCLUDE_MODELS}" = "true" ]; then \
wget -q --show-progress https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors -O /comfy-models/v1-5-pruned-emaonly.safetensors; \ wget -q --show-progress https://huggingface.co/Comfy-Org/stable-diffusion-v1-5-archive/resolve/main/v1-5-pruned-emaonly.safetensors -O /comfy-models/v1-5-pruned-emaonly.safetensors; \
fi fi
RUN if [ "${INCLUDE_MODELS}" = "true" ]; then \ RUN if [ "${INCLUDE_MODELS}" = "true" ]; then \
@ -61,13 +68,13 @@ RUN if [ "${INCLUDE_MODELS}" = "true" ]; then \
FROM comfyui-install as final FROM comfyui-install as final
# Move virtual environment from /workspace/venv to /venv # Move virtual environment from /workspace/venv to /venv
RUN mv /workspace/venv /venv RUN mv /workspace/runpod-venvs/better-comfyui /venv
# Copy models if they were included # Copy models if they were included
COPY --from=model-setup /comfy-models /comfy-models COPY --from=model-setup /comfy-models /comfy-models
# Set environment variables for runtime # Set environment variables for runtime
ENV VIRTUAL_ENV="/workspace/venv" ENV VIRTUAL_ENV="/workspace/runpod-venvs/better-comfyui"
ENV PATH="$VIRTUAL_ENV/bin:$PATH" ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Copy the README.md # Copy the README.md
@ -85,4 +92,4 @@ RUN chmod +x /pre_start.sh
COPY comfyui_extras.ipynb /comfyui_extras.ipynb COPY comfyui_extras.ipynb /comfyui_extras.ipynb
# CMD # CMD
CMD [ "/start.sh" ] CMD [ "/start.sh" ]

View file

@ -1,5 +1,5 @@
group "default" { group "default" {
targets = ["full-version", "light-version", "testing"] targets = ["full-version", "light-version", "dev"]
} }
target "base" { target "base" {
@ -21,11 +21,6 @@ target "full-version" {
args = { args = {
INCLUDE_MODELS = "true" INCLUDE_MODELS = "true"
} }
contexts = {
scripts = "../../container-template"
proxy = "../../container-template/proxy"
logo = "../../container-template"
}
tags = ["madiator2011/better-comfyui:full"] tags = ["madiator2011/better-comfyui:full"]
} }
@ -34,23 +29,13 @@ target "light-version" {
args = { args = {
INCLUDE_MODELS = "false" INCLUDE_MODELS = "false"
} }
contexts = {
scripts = "../../container-template"
proxy = "../../container-template/proxy"
logo = "../../container-template"
}
tags = ["madiator2011/better-comfyui:light"] tags = ["madiator2011/better-comfyui:light"]
} }
target "testing" { target "dev" {
inherits = ["base"] inherits = ["base"]
args = { args = {
INCLUDE_MODELS = "false" INCLUDE_MODELS = "false"
} }
contexts = { tags = ["madiator2011/better-comfyui:dev"]
scripts = "../../container-template" }
proxy = "../../container-template/proxy"
logo = "../../container-template"
}
tags = ["madiator2011/better-comfyui:testing"]
}

View file

@ -1,5 +1,10 @@
#!/bin/bash #!/bin/bash
# Set a default TERM if it's not set
if [ -z "$TERM" ]; then
export TERM=xterm-256color
fi
# Exit immediately if a command exits with a non-zero status # Exit immediately if a command exits with a non-zero status
set -e set -e
@ -38,11 +43,60 @@ fi
print_feedback "Starting ComfyUI setup..." print_feedback "Starting ComfyUI setup..."
print_feedback "Syncing virtual environment..." print_feedback "Syncing virtual environment..."
rsync_with_progress /venv/ /workspace/venv/ VIRTUAL_ENV="/workspace/runpod-venvs/better-comfyui"
SOURCE_VENV="/venv"
NUM_CORES=$(nproc)
if [ ! -d "$VIRTUAL_ENV" ]; then
clear
echo -e "\e[1;33m"
cat << "EOF"
_____________________________________
| |
| !!! ATTENTION - FIRST TIME SYNC !!!|
| |
| This process will take ~10 minutes |
|_____________________________________|
EOF
echo -e "\e[0m"
mkdir -p "$VIRTUAL_ENV"
# Start background process to show progress
(
while true; do
for s in / - \\ \|; do
printf "\r\033[1;31m[%s] \033[1;37mSYNC IN PROGRESS - PLEASE WAIT\033[0m" "$s"
sleep 0.5
done
done
) &
PROGRESS_PID=$!
# Perform the sync
rsync -aHx --info=progress2 --stats --exclude='*.pyc' --exclude='__pycache__' "$SOURCE_VENV/" "$VIRTUAL_ENV/"
# Stop the progress indicator
kill $PROGRESS_PID
wait $PROGRESS_PID 2>/dev/null
clear
echo -e "\e[1;32m"
cat << "EOF"
_____________________________________
| |
| SYNC COMPLETED SUCCESS |
|_____________________________________|
EOF
echo -e "\e[0m"
else
print_feedback "Subsequent sync: Updating venv without overwriting existing files..."
rsync -aHx --info=progress2 --stats --exclude='*.pyc' --exclude='__pycache__' --ignore-existing --update "$SOURCE_VENV/" "$VIRTUAL_ENV/"
fi
print_feedback "Activating virtual environment..." print_feedback "Activating virtual environment..."
export VIRTUAL_ENV="/workspace/venv"
export PATH="$VIRTUAL_ENV/bin:$PATH"
source "$VIRTUAL_ENV/bin/activate" source "$VIRTUAL_ENV/bin/activate"
export PYTHONUNBUFFERED=1 export PYTHONUNBUFFERED=1
@ -61,7 +115,7 @@ print_feedback "ComfyUI will be available at http://0.0.0.0:3000"
# Check if CUSTOM_ARGS is set and not empty # Check if CUSTOM_ARGS is set and not empty
if [ -n "$CUSTOM_ARGS" ]; then if [ -n "$CUSTOM_ARGS" ]; then
exec python main.py --listen --port 3000 $CUSTOM_ARGS 2>&1 | tee -a $LOG_FILE exec python main.py --listen --port 3000 --enable-cors-header $CUSTOM_ARGS 2>&1 | tee -a $LOG_FILE
else else
exec python main.py --listen --port 3000 2>&1 | tee -a $LOG_FILE exec python main.py --listen --port 3000 --enable-cors-header 2>&1 | tee -a $LOG_FILE
fi fi