Skip to content

Commit 126214e

Browse files
committed
{xpus} Big update
1 parent 0a3ea7c commit 126214e

File tree

13 files changed

+514
-257
lines changed

13 files changed

+514
-257
lines changed

xpu-cn/Dockerfile

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,35 +59,18 @@ make \
5959
ninja \
6060
python3-cmake
6161

62-
# RUN --mount=type=cache,target=/var/cache/dnf \
63-
# dnf install -y \
64-
# python3-matplotlib \
65-
# python3-mpmath \
66-
# python3-numpy \
67-
# python3-onnx
68-
6962
RUN --mount=type=cache,target=/var/cache/dnf \
7063
dnf install -y \
7164
ffmpeg \
7265
x264 \
7366
x265 \
7467
default-fonts-cjk
7568

76-
# RUN --mount=type=cache,target=/var/cache/dnf \
77-
# dnf install -y \
78-
# python3-opencv \
79-
# python3-cairo
80-
8169
RUN --mount=type=cache,target=/var/cache/dnf \
8270
dnf install -y \
8371
mesa-libGL \
8472
mesa-libEGL \
85-
# python3-GitPython \
8673
git \
87-
# python3-pandas \
88-
# python3-scikit-build-core \
89-
# python3-scikit-image \
90-
# python3-scikit-learn \
9174
fish \
9275
aria2 \
9376
fd-find \
@@ -213,7 +196,7 @@ RUN if [ "${USING_GITHUB_ACTIONS}" = "false" ]; then \
213196
RUN --mount=type=cache,target=/root/.cache/pip \
214197
pip install \
215198
-r '/default-comfyui-bundle/ComfyUI/requirements.txt' \
216-
-r '/default-comfyui-bundle/ComfyUI/manager_requirements.txt' \
199+
-r '/default-comfyui-bundle/ComfyUI/custom_nodes/ComfyUI-Manager/requirements.txt' \
217200
-c /builder-scripts/constraints.txt \
218201
&& pip list
219202

@@ -229,6 +212,7 @@ ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
229212

230213
ENV PIP_INDEX_URL="https://mirrors.cernet.edu.cn/pypi/web/simple"
231214
ENV HF_ENDPOINT="https://hf-mirror.com"
215+
ENV GITHUB_ENDPOINT="https://gh-proxy.org/https://github.com"
232216

233217
RUN if [ "${USING_GITHUB_ACTIONS}" = "true" ]; then \
234218
sed -e 's|^metalink=|#metalink=|g' \

xpu-cn/README.adoc

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
# 基于 Intel GPU + XPU 运行 ComfyUI
2+
3+
image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-xpu-cn.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-xpu-cn.yml"]
4+
5+
https://hub.docker.com/r/yanwk/comfyui-boot/tags?name=xpu-cn[View on <Docker Hub>]
6+
7+
## 支持的 Intel GPU 与 CPU
8+
9+
[cols="1,3"]
10+
|===
11+
| Arc Battlemage
12+
| B580, B570, B60, B50
13+
14+
| Arc Alchemist
15+
| A770, A750, A580, A770M, A730M, A550M, Flex 170
16+
17+
| Panther Lake
18+
| 388H, 386H, 368H, 366H, 358H, 356H, 338H, 336H, 365, 355, 335, 332, 325, 322
19+
20+
| Lunar Lake
21+
| 288V, 268V, 266V, 258V, 256V, 238V, 236V, 228V, 226V
22+
23+
| Arrow Lake-H
24+
| 285H, 265H, 255H, 235H, 225H
25+
26+
| Meteor Lake-H
27+
| 185H, 165H, 155H, 135H, 125H, 165HL, 155HL, 135HL, 125HL
28+
29+
| Data Center
30+
| Max 1550, Max 1100
31+
|===
32+
33+
更多兼容性信息参考
34+
https://docs.pytorch.org/docs/stable/notes/get_start_xpu.html[PyTorch 文档] 。
35+
36+
37+
## 检查驱动
38+
39+
确保宿主机已安装 Intel GPU 驱动(内核模块 `xe`):
40+
41+
[source,sh]
42+
----
43+
lsmod | grep -i xe
44+
----
45+
46+
常见桌面发行版通常已自带 `xe`,无需手动安装。
47+
48+
TIP: 最新的 6.18 内核可能会导致 ComfyUI 启动时 PyTorch 报错,如果遇到 `UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY`,建议改用 6.17 版本的内核。
49+
50+
51+
## 运行
52+
53+
TIP: 如连接 Docker Hub 困难,可以尝试先从
54+
https://www.coderjia.cn/archives/dba3f94c-a021-468a-8ac6-e840f85867ea[镜像站点]
55+
拉取镜像,再启动容器。
56+
57+
### 使用 Docker
58+
59+
[source,sh]
60+
----
61+
mkdir -p \
62+
storage \
63+
storage-models/models \
64+
storage-models/hf-hub \
65+
storage-models/torch-hub \
66+
storage-user/input \
67+
storage-user/output \
68+
storage-user/workflows
69+
70+
docker run -it --rm \
71+
--name comfyui-xpu \
72+
--device=/dev/dri \
73+
--ipc=host \
74+
--security-opt label=disable \
75+
-p 8188:8188 \
76+
-v "$(pwd)"/storage:/root \
77+
-v "$(pwd)"/storage-models/models:/root/ComfyUI/models \
78+
-v "$(pwd)"/storage-models/hf-hub:/root/.cache/huggingface/hub \
79+
-v "$(pwd)"/storage-models/torch-hub:/root/.cache/torch/hub \
80+
-v "$(pwd)"/storage-user/input:/root/ComfyUI/input \
81+
-v "$(pwd)"/storage-user/output:/root/ComfyUI/output \
82+
-v "$(pwd)"/storage-user/workflows:/root/ComfyUI/user/default/workflows \
83+
-e CLI_ARGS="--async-offload" \
84+
yanwk/comfyui-boot:xpu-cn
85+
----
86+
87+
### 使用 Podman
88+
89+
[source,sh]
90+
----
91+
mkdir -p \
92+
storage \
93+
storage-models/models \
94+
storage-models/hf-hub \
95+
storage-models/torch-hub \
96+
storage-user/input \
97+
storage-user/output \
98+
storage-user/workflows
99+
100+
podman run -it --rm \
101+
--name comfyui-xpu \
102+
--device=/dev/dri \
103+
--ipc=host \
104+
--security-opt label=disable \
105+
-p 8188:8188 \
106+
-v "$(pwd)"/storage:/root \
107+
-v "$(pwd)"/storage-models/models:/root/ComfyUI/models \
108+
-v "$(pwd)"/storage-models/hf-hub:/root/.cache/huggingface/hub \
109+
-v "$(pwd)"/storage-models/torch-hub:/root/.cache/torch/hub \
110+
-v "$(pwd)"/storage-user/input:/root/ComfyUI/input \
111+
-v "$(pwd)"/storage-user/output:/root/ComfyUI/output \
112+
-v "$(pwd)"/storage-user/workflows:/root/ComfyUI/user/default/workflows \
113+
-e CLI_ARGS="--async-offload" \
114+
docker.io/yanwk/comfyui-boot:xpu-cn
115+
----
116+
117+
启动完成后,访问 http://localhost:8188/
118+
119+
120+
[[cli-args]]
121+
## CLI_ARGS 参考
122+
123+
TIP: 以下大部分参数都关于内存管理。
124+
你可以在宿主机上安装 `nvtop`来监控显存使用情况,该工具也支持 Intel GPU。
125+
126+
[%autowidth,cols=2]
127+
|===
128+
|启动参数 |说明
129+
130+
|--async-offload
131+
|“将模型权重从显存卸载到内存”这一操作从同步变为异步。带来少量性能提升,且无明显副作用。
132+
133+
|--disable-smart-memory
134+
|强制 ComfyUI 不要在显存中缓存模型权重,用完即卸载到内存中以释放显存。有效缓解显存泄漏问题,但会增加模型加载用时,并占用更多内存。
135+
136+
|--lowvram
137+
|强制 ComfyUI 对模型 (UNET) 进行分块加载以减少显存占用,代价是降低速度。仅在显存不足时使用。
138+
139+
|--cpu-vae
140+
|在 VAE 阶段改用 CPU 运行。一些比较极限的情况下,会在采样阶段显存够用而在 VAE 阶段显存不足,可用此参数快速绕过问题,而不必调整其他参数。
141+
142+
|--mmap-torch-files
143+
|“按需”从磁盘加载模型文件。当模型文件较大时,可以避免一次性将整个模型加载到内存中。仅在内存不足时使用。
144+
145+
|--reserve-vram 1
146+
|设置保留给其他程序的显存大小(单位:GB)。例如你希望运行 ComfyUI 时留一部分显存给浏览器,避免显存不足时浏览器直接退出。
147+
148+
|--bf16-unet --bf16-vae --bf16-text-enc
149+
|将扩散模型、VAE 和文本编码器都以 bf16 精度运行。高级优化参数,一般无需指定。
150+
151+
|--novram
152+
|不使用显存,完全使用系统内存,但仍以 GPU 运行计算。非常慢,仅在显存不足时使用。
153+
154+
|--cpu
155+
|使用 CPU 运行。非常慢,适合测试、模型下载转换、图像批处理等场景。
156+
157+
|--enable-manager
158+
|启用 ComfyUI 内置的自定义节点管理器。镜像内已安装 ComfyUI-Manager,通常不需要启用此功能。
159+
160+
|===
161+
162+
更多 `CLI_ARGS` 参考 ComfyUI 的
163+
https://github.com/Comfy-Org/ComfyUI/blob/master/comfy/cli_args.py[cli_args.py] 。
164+
165+
166+
[[env-vars]]
167+
## 环境变量参考
168+
169+
TIP: 以下三个镜像源均已预设,仅在连接不畅时需要手动设置。
170+
171+
[cols="2,2,3"]
172+
|===
173+
|变量名 |样例值 |说明
174+
175+
|PIP_INDEX_URL
176+
|'https://mirrors.cernet.edu.cn/pypi/web/simple'
177+
|设置 PyPI 镜像源以加速 Python 包下载。
178+
179+
|GITHUB_ENDPOINT
180+
|'https://gh-proxy.org/https://github.com'
181+
|为 ComfyUI-Manager 设置 GitHub 镜像站点。
182+
183+
|HF_ENDPOINT
184+
|'https://hf-mirror.com'
185+
|为 HuggingFace Hub 设置镜像站点。
186+
187+
|HTTP_PROXY +
188+
HTTPS_PROXY
189+
|http://localhost:1081 +
190+
http://localhost:1081
191+
|设置 HTTP 代理地址,与 `set-proxy.sh` 脚本功能相同。
192+
193+
|HF_TOKEN
194+
|'hf_your_token'
195+
|设置 HuggingFace 的访问令牌(Access Token)。一些模型需要登录并同意协议后才能下载。
196+
https://huggingface.co/settings/tokens[令牌设置页面]
197+
198+
|HF_XET_HIGH_PERFORMANCE
199+
|1
200+
|启用 HuggingFace Hub 下载器的高性能模式。
201+
该模式会使用更多硬件资源以尽可能吃满网络带宽,仅适合大带宽(>5Gbps)且十分稳定的网络环境。
202+
https://huggingface.co/docs/huggingface_hub/main/en/package_reference/environment_variables#hfxethighperformance[官方文档]
203+
204+
|===
205+
206+
207+
## 技巧
208+
209+
* 建议先试试 Z-Image Turbo, Qwen Image 2512, FLUX.2 Klein 等较新的模型,体验较好,ComfyUI 内置有样例工作流。
210+
211+
* 视频生成极耗显存,目前针对 XPU 优化的手段(量化、分片、缓存等)也有限,
212+
建议使用更轻量的模型、降低分辨率和帧数以避免显存溢出。
213+
214+
* 当显存溢出时,ComfyUI 不一定会崩溃,而可能是 GPU 停止响应,添新任务提示设备丢失 `UR_RESULT_ERROR_DEVICE_LOST`
215+
此时需要重启 ComfyUI。
216+
217+
* 3D 类模型几乎全部基于 CUDA 开发,没有尝试的必要。
218+
219+
220+
## 给 Windows 用户的建议
221+
222+
* 可以尝试 Intel 官方的 AI Playground:
223+
** https://game.intel.com/us/stories/introducing-ai-playground/
224+
225+
* 或者试试我打包的 ComfyUI portable:
226+
** https://github.com/YanWenKun/ComfyUI-WinPortable-XPU

xpu-cn/README.txt

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)