-
初次启动时,启动脚本会下载 ComfyUI、必要的模型以及一些扩展。
-
整个 ComfyUI 会保存在本地 (
./storage/ComfyUI
) 。 -
如果你已经有了现成的 ComfyUI 包,放在上述目录,并新建一个空白文件 (
./storage/.download-complete
),启动脚本会跳过下载。 -
使用 ComfyUI-Manager 即可更新组件、安装模型(在 ComfyUI 页面中找到“Manager”)。
-
NVIDIA 显卡, ≥6GB 显存
-
安装好最新的 NVIDIA 显卡驱动
-
游戏驱动或 Studio 驱动均可。
-
只需要在宿主系统中安装驱动即可,容器中不需要再安装驱动。
-
-
安装好 Docker
-
Windows 用户建议使用 Docker Desktop 并在安装时启用 WSL2,并 限制内存用量 。
-
下载过程可能需要科学上网,在 Docker 设置中可以找到代理设置。
-
方法 A 使用
docker compose
git clone https://github.com/YanWenKun/ComfyUI-Docker.git
cd ComfyUI-Docker
docker compose up --detach
# 更新镜像(仅在 Python 组件版本过期时需要)
git pull
docker compose pull
docker compose up --detach --remove-orphans
docker image prune
方法 B 使用
docker run
mkdir -p storage
docker run -it \
--name comfyui \
--gpus all \
-p 8188:8188 \
-v "$(pwd)"/storage:/home/runner \
--env CLI_ARGS="" \
yanwk/comfyui-boot:latest
# 更新镜像(仅在 Python 组件版本过期时需要)
docker rm comfyui
docker pull yanwk/comfyui-boot:latest
# 接下来再运行一遍上述 'docker run' 即可
启动完成后,访问 http://localhost:8188/
Note
|
AMD/Intel GPU + Win11 可以考虑: 在 WSL2 环境下通过 DirectML 运行 ComfyUI |
方法 C 使用
docker compose
git clone https://github.com/YanWenKun/ComfyUI-Docker.git
cd ComfyUI-Docker
docker compose -f docker-compose-rocm.yml up --detach
# 更新镜像(仅在 Python 组件版本过期时需要)
git pull
docker compose -f docker-compose-rocm.yml pull
docker compose -f docker-compose-rocm.yml up --detach --remove-orphans
docker image prune
方法 D 使用
docker run
mkdir -p storage
docker run -it \
--name comfyui \
--gpus all \
-p 8188:8188 \
-v "$(pwd)"/storage:/home/runner \
--env CLI_ARGS="--use-pytorch-cross-attention" \
--device=/dev/kfd --device=/dev/dri \
--group-add=video --ipc=host --cap-add=SYS_PTRACE \
--security-opt seccomp=unconfined \
yanwk/comfyui-boot:rocm
# 更新镜像(仅在 Python 组件版本过期时需要)
docker rm comfyui
docker pull yanwk/comfyui-boot:rocm
# 接下来再运行一遍上述 'docker run' 即可
启动完成后,访问 http://localhost:8188/
Q: 显存只有 4G 怎么办?
A: 在启动参数 CLI_ARGS
中添加 --lowvram
。
Q: 用了 --lowvram
还是显存不够
A: 参数换成 --novram
(直接用 CPU 内存)。
Q: 能不能直接用 CPU 来跑?
A: 在启动参数 CLI_ARGS
中添加 --cpu
,会很慢。
更多 CLI_ARGS
参考
ComfyUI 。
构建镜像,打印所有日志(不折叠)
docker build . --progress=plain -f Dockerfile -t yanwk/comfyui-boot:latest
运行一个一次性容器
docker run -it --rm \
--gpus all -p 8188:8188 \
--volume "$(pwd)"/storage:/home/runner \
--env CLI_ARGS="" \
yanwk/comfyui-boot:latest
用 root 身份运行 bash
docker run -it --rm \
--gpus all -p 8188:8188 \
--volume "$(pwd)"/storage:/home/runner \
--env CLI_ARGS="" \
--user root \
yanwk/comfyui-boot:latest /bin/bash
代码使用 木兰公共许可证, 第2版 。 中英双语哦!