From e155910dda0c7e5e89335d1861df7a3d070e6068 Mon Sep 17 00:00:00 2001 From: owner Date: Sun, 16 Nov 2025 15:23:19 -0500 Subject: [PATCH] first :) --- README.md | 57 +++++++++++++++++++++++++++++++- docker-compose.yml | 68 ++++++++++++++++++++++++++++++++++++++ services/amd/Dockerfile | 56 +++++++++++++++++++++++++++++++ services/amd/start.sh | 5 +++ services/intel/Dockerfile | 58 ++++++++++++++++++++++++++++++++ services/intel/start.sh | 5 +++ services/nvidia/Dockerfile | 55 ++++++++++++++++++++++++++++++ services/nvidia/start.sh | 5 +++ 8 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 docker-compose.yml create mode 100644 services/amd/Dockerfile create mode 100644 services/amd/start.sh create mode 100644 services/intel/Dockerfile create mode 100644 services/intel/start.sh create mode 100644 services/nvidia/Dockerfile create mode 100644 services/nvidia/start.sh diff --git a/README.md b/README.md index dc75cb9..016fd7f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,57 @@ -# comfyui-docker +# ComfyUI Docker Setup +Hey there! This repository sets up ComfyUI, a powerful node-based interface for Stable Diffusion, using Docker. I've created separate configurations for AMD, Intel, and Nvidia GPUs to hopefully get everyone up and running smoothly. + +## Summary + +This `docker-compose.yml` file defines three ComfyUI services: + +* **comfyui-amd:** Optimized for AMD GPUs. +* **comfyui-intel:** Optimized for Intel GPUs. +* **comfyui-nvidia:** Configured for Nvidia GPUs. + +You'll be able to access ComfyUI through your browser at `http://localhost:8188` (assuming you're running this locally) or `http://:8188`. + +## Dependencies + +Before you start, make sure you have the following installed: + +* **Docker:** You'll need Docker installed and running on your system. [https://docs.docker.com/get-docker/](https://docs.docker.com/get-docker/) +* **Docker Compose:** Docker Compose is used to define and run multi-container Docker applications. It's usually bundled with Docker Desktop, but if not, you can install it separately: [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/) +* **GPU Drivers:** Make sure you have the latest drivers installed for your GPU (AMD, Intel, or Nvidia). +* **Models:** You'll need to download the Stable Diffusion models and place them in the `./models` directory. (This directory will be mounted into the container). + +## Getting Started + +Here's how to get everything up and running: + +1. **Clone the repository:** Clone this repository to your local machine. + +2. **Download Models:** Download your preferred Stable Diffusion models (e.g., checkpoints, VAEs, LoRAs) and place them in the `./models` directory. + +3. **Choose your profile:** Pick the profile corresponding to your GPU: `comfyui-amd`, `comfyui-intel`, or `comfyui-nvidia`. + +4. **Run Docker Compose:** Open your terminal, navigate to the directory where you cloned the repository, and run the following command, specifying the profile: + + ```bash + docker-compose --profile comfyui-amd up -d # For AMD + docker-compose --profile comfyui-intel up -d # For Intel + docker-compose --profile comfyui-nvidia up -d # For Nvidia + ``` + + The `-d` flag runs the containers in detached mode (in the background). + +5. **Access ComfyUI:** Once the containers are running, open your web browser and go to `http://localhost:8188`. You should see the ComfyUI interface. + +**To stop the containers:** + +```bash +docker-compose down +``` + +**Important Notes:** + +* The `CLI_ARGS` environment variables in each service are specific optimizations for each GPU type. You can customize these if you want to experiment with different settings. +* The `./output` and `./user` directories are used for saving generated images and custom workflows, respectively. + +Let me know if you run into any issues or have suggestions for improvements! \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2bd70cb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,68 @@ +version: '3.8' + +services: + comfyui-amd: + container_name: comfyui-amd + build: + context: ./services/amd + profiles: ["comfyui-amd"] + ports: + - "8188:8188" + volumes: + - "./models:/ComfyUI/models" + - "./output:/ComfyUI/output" + - "./user:/ComfyUI/user" + environment: + - CLI_ARGS=--disable-cuda-malloc --disable-smart-memory + - HSA_OVERRIDE_GFX_VERSION=10.3.0 # For AMD Radeon RX 6650 XT + - MIOPEN_FIND_MODE=FAST + devices: + - /dev/dri/renderD128:/dev/dri/renderD128 + - /dev/dri/card0:/dev/dri/card0 + - /dev/kfd:/dev/kfd + restart: unless-stopped + + comfyui-intel: + container_name: comfyui-intel + build: + context: ./services/intel + profiles: ["comfyui-intel"] + ports: + - "8188:8188" + volumes: + - "./models:/ComfyUI/models" + - "./output:/ComfyUI/output" + - "./user:/ComfyUI/user" + environment: + - CLI_ARGS=--disable-ipex-optimize --use-pytorch-cross-attention --reserve-vram 9.5 + - MIOPEN_FIND_MODE=2 + - MIGRAPHX_MLIR_USE_SPECIFIC_OPS="attention" + devices: + - /dev/dri/renderD128:/dev/dri/renderD128 + - /dev/dri/card0:/dev/dri/card0 + restart: unless-stopped + + comfyui-nvidia: + container_name: comfyui-nvidia + build: + context: ./services/nvidia + profiles: ["comfyui-nvidia"] + ports: + - "8188:8188" + volumes: + - "./models:/ComfyUI/models" + - "./output:/ComfyUI/output" + - "./user:/ComfyUI/user" + environment: + - CLI_ARGS="" + restart: unless-stopped + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: all + capabilities: + - gpu + - compute + - utility \ No newline at end of file diff --git a/services/amd/Dockerfile b/services/amd/Dockerfile new file mode 100644 index 0000000..1017158 --- /dev/null +++ b/services/amd/Dockerfile @@ -0,0 +1,56 @@ +FROM rocm/dev-ubuntu-24.04:latest + +# Install system dependencies +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + git \ + libgl1 \ + libglib2.0-0 \ + libglx-mesa0 \ + && rm -rf /var/lib/apt/lists/* + +# Create User Permissions +ARG DOCKER_USER=default_user +RUN useradd -m "$DOCKER_USER" + +# Clone vladmandic's stable diffusion +RUN \ + git clone --depth 1 --depth 1 https://github.com/comfyanonymous/ComfyUI + +WORKDIR /ComfyUI/custom_nodes/ +RUN git clone --depth 1 https://github.com/ltdrdata/ComfyUI-Manager /ComfyUI/custom_nodes/comfyui-manager && \ + git clone --depth 1 https://github.com/SeanScripts/ComfyUI-Unload-Model.git /ComfyUI/custom_nodes/ComfyUI-Unload-Model && \ + git clone --depth 1 https://github.com/ssitu/ComfyUI_UltimateSDUpscale --recursive /ComfyUI/custom_nodes/ComfyUI_UltimateSDUpscale && \ + git clone --depth 1 https://github.com/ltdrdata/ComfyUI-Impact-Pack /ComfyUI/custom_nodes/ComfyUI-Impact-Pack && \ + git clone --depth 1 https://github.com/ltdrdata/ComfyUI-Impact-Subpack /ComfyUI/custom_nodes/ComfyUI-Impact-Subpack && \ + git clone --depth 1 https://github.com/talesofai/comfyui-browser /ComfyUI/custom_nodes/comfyui-browser && \ + git clone --depth 1 https://github.com/SEkINVR/ComfyUI-SaveAs.git /ComfyUI/custom_nodes/ComfyUI-SaveAs + +WORKDIR /ComfyUI + +RUN pip install --no-cache-dir --break-system-packages --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm6.4 +#RUN pip install --no-cache-dir --break-system-packages torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.3 + +# Install Python dependencies +RUN pip install --no-cache-dir --break-system-packages -r requirements.txt && \ + pip install --no-cache-dir --break-system-packages -r /ComfyUI/custom_nodes/comfyui-manager/requirements.txt && \ + pip install --no-cache-dir --break-system-packages -r /ComfyUI/custom_nodes/ComfyUI-Impact-Pack/requirements.txt && \ + pip install --no-cache-dir --break-system-packages -r /ComfyUI/custom_nodes/ComfyUI-Impact-Subpack/requirements.txt && \ + pip install --no-cache-dir --break-system-packages -r /ComfyUI/custom_nodes/comfyui-browser/requirements.txt && \ + pip install --no-cache-dir --break-system-packages -r /ComfyUI/custom_nodes/ComfyUI-SaveAs/requirements.txt && \ + pip install --no-cache-dir --break-system-packages gitpython psutil + +# Set ownership and move models directory +RUN chown -R $DOCKER_USER:$DOCKER_USER /ComfyUI && \ + mv /ComfyUI/models /ComfyUI/models.orig + +# Copy start script +COPY ./start.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/start.sh + +# Switch to non-root user +USER $DOCKER_USER +WORKDIR /ComfyUI + +CMD ["/usr/local/bin/start.sh"] \ No newline at end of file diff --git a/services/amd/start.sh b/services/amd/start.sh new file mode 100644 index 0000000..6520532 --- /dev/null +++ b/services/amd/start.sh @@ -0,0 +1,5 @@ +#!/bin/bash +echo "COPYING" +cp -rf /ComfyUI/models.orig/* /ComfyUI/models/ +echo "START" +python3 main.py --listen --lowvram "${CLI_ARGS}" \ No newline at end of file diff --git a/services/intel/Dockerfile b/services/intel/Dockerfile new file mode 100644 index 0000000..7ebcafd --- /dev/null +++ b/services/intel/Dockerfile @@ -0,0 +1,58 @@ +FROM intel/oneapi-runtime:latest + +ENV PIP_BREAK_SYSTEM_PACKAGES=1 +ENV DEBIAN_FRONTEND=noninteractive + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + ca-certificates \ + git \ + python3 \ + python3-pip \ + libgl1 \ + libglx-mesa0 \ + && rm -rf /var/lib/apt/lists/* + +# Create User Permissions +ARG DOCKER_USER=default_user +RUN useradd -m "$DOCKER_USER" + +# Clone vladmandic's stable diffusion +RUN \ + git clone --depth 1 https://github.com/comfyanonymous/ComfyUI +WORKDIR /ComfyUI + +WORKDIR /ComfyUI/custom_nodes/ +RUN git clone --depth 1 https://github.com/ltdrdata/ComfyUI-Manager /ComfyUI/custom_nodes/comfyui-manager && \ + git clone --depth 1 https://github.com/SeanScripts/ComfyUI-Unload-Model.git /ComfyUI/custom_nodes/ComfyUI-Unload-Model && \ + git clone --depth 1 https://github.com/ssitu/ComfyUI_UltimateSDUpscale --recursive /ComfyUI/custom_nodes/ComfyUI_UltimateSDUpscale && \ + git clone --depth 1 https://github.com/ltdrdata/ComfyUI-Impact-Pack /ComfyUI/custom_nodes/ComfyUI-Impact-Pack && \ + git clone --depth 1 https://github.com/ltdrdata/ComfyUI-Impact-Subpack /ComfyUI/custom_nodes/ComfyUI-Impact-Subpack && \ + git clone --depth 1 https://github.com/talesofai/comfyui-browser /ComfyUI/custom_nodes/comfyui-browser && \ + git clone --depth 1 https://github.com/SEkINVR/ComfyUI-SaveAs.git /ComfyUI/custom_nodes/ComfyUI-SaveAs + +WORKDIR /ComfyUI +RUN pip install --no-cache-dir --break-system-packages torch==2.10.0.dev20250911+xpu torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/xpu + +# Install Python dependencies +RUN pip install --no-cache-dir --break-system-packages -r requirements.txt && \ + pip install --no-cache-dir --break-system-packages -r /ComfyUI/custom_nodes/comfyui-manager/requirements.txt && \ + pip install --no-cache-dir --break-system-packages -r /ComfyUI/custom_nodes/ComfyUI-Impact-Pack/requirements.txt && \ + pip install --no-cache-dir --break-system-packages -r /ComfyUI/custom_nodes/ComfyUI-Impact-Subpack/requirements.txt && \ + pip install --no-cache-dir --break-system-packages -r /ComfyUI/custom_nodes/comfyui-browser/requirements.txt && \ + pip install --no-cache-dir --break-system-packages -r /ComfyUI/custom_nodes/ComfyUI-SaveAs/requirements.txt && \ + pip install --no-cache-dir --break-system-packages gitpython psutil + +# Set ownership and move models directory +RUN chown -R $DOCKER_USER:$DOCKER_USER /ComfyUI && \ + mv /ComfyUI/models /ComfyUI/models.orig + +# Copy start script +COPY ./start.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/start.sh + +# Switch to non-root user +USER $DOCKER_USER +WORKDIR /ComfyUI + +CMD ["/usr/local/bin/start.sh"] diff --git a/services/intel/start.sh b/services/intel/start.sh new file mode 100644 index 0000000..94e8557 --- /dev/null +++ b/services/intel/start.sh @@ -0,0 +1,5 @@ +#!/bin/bash +echo "COPYING" +cp -rf /ComfyUI/models.orig/* /ComfyUI/models/ +echo "START" +python3 main.py --listen "${CLI_ARGS}" \ No newline at end of file diff --git a/services/nvidia/Dockerfile b/services/nvidia/Dockerfile new file mode 100644 index 0000000..98dde51 --- /dev/null +++ b/services/nvidia/Dockerfile @@ -0,0 +1,55 @@ +FROM nvidia/cuda:13.0.2-cudnn-devel-ubuntu24.04 + +ENV PIP_BREAK_SYSTEM_PACKAGES=1 +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + ca-certificates \ + git \ + python3 \ + python3-pip \ + libgl1 \ + libglx-mesa0 \ + libglib2.0-0 \ + && rm -rf /var/lib/apt/lists/* + +# Create User Permissions +ARG DOCKER_USER=default_user +RUN useradd -m "$DOCKER_USER" + +# Clone vladmandic's stable diffusion +RUN git clone --depth 1 https://github.com/comfyanonymous/ComfyUI + +WORKDIR /ComfyUI/custom_nodes/ +RUN \ + git clone --depth 1 https://github.com/ltdrdata/ComfyUI-Manager \ + && git clone --depth 1 https://github.com/SeanScripts/ComfyUI-Unload-Model.git \ + && git clone --depth 1 https://github.com/ssitu/ComfyUI_UltimateSDUpscale --recursive \ + && git clone --depth 1 https://github.com/ltdrdata/ComfyUI-Impact-Pack \ + && git clone --depth 1 https://github.com/ltdrdata/ComfyUI-Impact-Subpack \ + && git clone --depth 1 https://github.com/talesofai/comfyui-browser \ + && git clone --depth 1 https://github.com/SEkINVR/ComfyUI-SaveAs.git + +WORKDIR /ComfyUI + +RUN pip install --break-system-packages -r requirements.txt \ + && pip install --break-system-packages -r /ComfyUI/custom_nodes/comfyui-manager/requirements.txt \ + && pip install --break-system-packages -r /ComfyUI/custom_nodes/ComfyUI-Impact-Pack/requirements.txt \ + && pip install --break-system-packages -r /ComfyUI/custom_nodes/ComfyUI-Impact-Subpack/requirements.txt \ + && pip install --break-system-packages -r /ComfyUI/custom_nodes/comfyui-browser/requirements.txt \ + && pip install --break-system-packages -r /ComfyUI/custom_nodes/ComfyUI-SaveAs/requirements.txt + && pip install --break-system-packages gitpython psutil + +# Set ownership and move models directory +RUN chown -R $DOCKER_USER:$DOCKER_USER /ComfyUI && \ + mv /ComfyUI/models /ComfyUI/models.orig + +# Copy start script +COPY ./start.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/start.sh + +# Switch to non-root user +USER $DOCKER_USER +WORKDIR /ComfyUI + +CMD ["/usr/local/bin/start.sh"] diff --git a/services/nvidia/start.sh b/services/nvidia/start.sh new file mode 100644 index 0000000..a8e018c --- /dev/null +++ b/services/nvidia/start.sh @@ -0,0 +1,5 @@ +#!/bin/bash +echo "COPYING" +cp -rf /ComfyUI/models.orig/* /ComfyUI/models/ +echo "START" +python3 main.py --listen "${CLI_ARGS}"