forked from Kaouthia/ComfyUI-Docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
106 lines (87 loc) · 3.7 KB
/
Dockerfile
File metadata and controls
106 lines (87 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# =============================================================================
# ComfyUI Docker — Elenedeath/ComfyUI-Docker
# Fixes: numpy<2.0 (Reactor ABI), g++ (insightface build), Reactor deps baked in
# =============================================================================
ARG PYTORCH_VERSION=2.6.0
ARG CUDA_VERSION=12.4
ARG CUDNN_VERSION=9
# Allow passing in your host UID/GID (defaults 1000:1000)
ARG UID=1000
ARG GID=1000
FROM pytorch/pytorch:${PYTORCH_VERSION}-cuda${CUDA_VERSION}-cudnn${CUDNN_VERSION}-runtime
# Installs Git + build tools (g++ required for insightface Cython build)
# + OpenCV system libs
RUN apt-get update --assume-yes && \
apt-get install --assume-yes \
git \
sudo \
gcc \
g++ \
build-essential \
libgl1 \
libglx-mesa0 \
libglib2.0-0 \
libgomp1 \
dnsutils && \
rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
# Clone ComfyUI
RUN git clone https://github.com/comfyanonymous/ComfyUI.git /opt/comfyui
# Clone ComfyUI Manager (entrypoint will symlink it into custom_nodes/)
RUN git clone https://github.com/ltdrdata/ComfyUI-Manager.git \
/opt/comfyui/custom_nodes/ComfyUI-Manager
# =============================================================================
# CRITICAL: pin NumPy <2.0 BEFORE everything else.
# cv2 4.9, insightface 0.7.3 and onnxruntime-gpu 1.18 are compiled against
# NumPy 1.x ABI — NumPy 2.x causes "_ARRAY_API not found" at import time.
# This layer must come before any other pip install.
# =============================================================================
# Global pip constraint: forbid NumPy 2.x everywhere
RUN echo "numpy<2.0" > /opt/constraints.txt
ENV PIP_CONSTRAINT=/opt/constraints.txt
RUN pip install --no-cache-dir "numpy==1.26.4"
# Pin PyTorch stack with --no-deps so pip cannot upgrade numpy as a side-effect
RUN pip install --no-deps --no-cache-dir \
torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 \
--index-url https://download.pytorch.org/whl/cu124
# Utility / monitoring deps (Crystools etc.)
# pillow intentionally left unpinned so ComfyUI requirements can resolve it
RUN pip install --no-cache-dir \
deepdiff==8.6.1 \
nvidia-ml-py \
py-cpuinfo \
piexif \
orderly-set \
pillow \
dill \
llama-cpp-python
# ComfyUI + ComfyUI-Manager Python requirements
RUN pip install --no-cache-dir \
-r /opt/comfyui/requirements.txt \
-r /opt/comfyui/custom_nodes/ComfyUI-Manager/requirements.txt
# =============================================================================
# Reactor / InsightFace dependency stack — baked into the image so that
# container recreation never loses them (no more "No module named cv2").
# =============================================================================
RUN pip install --no-cache-dir \
opencv-python==4.9.0.80 \
insightface==0.7.3 \
onnxruntime-gpu==1.18.0 \
segment-anything \
accelerate \
dill \
llama-cpp-python
RUN pip install --no-deps --no-cache-dir ultralytics
RUN pip install --no-cache-dir \
matplotlib scipy pandas tqdm pyyaml requests psutil py-cpuinfo seaborn
RUN pip install --no-cache-dir --force-reinstall "opencv-python==4.9.0.80"
RUN pip install --no-cache-dir --force-reinstall "numpy==1.26.4"
RUN pip uninstall -y pynvml 2>/dev/null || true
# Build-time smoke tests — fail the build early if something is broken
RUN python -c "import numpy; v=numpy.__version__; assert v.startswith('1.'), f'NumPy {v} >=2.0!'; print(v)"
RUN python -c "import cv2, insightface, onnxruntime; print('Reactor deps OK')"
# Run as non-root
USER $UID:$GID
WORKDIR /opt/comfyui
EXPOSE 8188
ADD entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]