diff --git a/README.adoc b/README.adoc index 9f2aec0..0270f1d 100644 --- a/README.adoc +++ b/README.adoc @@ -1,13 +1,7 @@ -# Docker image for ComfyUI - -image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-latest.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions"] -image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-rocm.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/tree/main/rocm"] -image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-megapak.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/tree/main/megapak"] +# Docker images for ComfyUI *link:README.zh.adoc[>💡中文说明点我💡<]* -image::docs/chart-concept.svg["Concept Design"] - This repo is for https://hub.docker.com/r/yanwk/comfyui-boot[Docker images] that runs @@ -15,301 +9,49 @@ https://github.com/comfyanonymous/ComfyUI[ComfyUI] - a Stable Diffusion GUI powering node-based workflow. -## How it works - -1. At first start, a script will download latest ComfyUI, ComfyUI-Manager and some models. -2. The whole ComfyUI will be stored in a local folder (`./storage/ComfyUI`). -3. If you already have a ComfyUI bundle, put it there and make an empty file (`./storage/.download-complete`) so the start script will skip downloading. -4. Use ComfyUI-Manager (in ComfyUI web page) to update ComfyUI, manage custom nodes, and download models. - - -## Prerequisites - -* NVIDIA GPU with ≥6GB VRAM -** For 4GB see <>. -** For AMD GPU see link:rocm/README.adoc[ROCm]. - -* Latest NVIDIA GPU driver -** Either Game or Studio edition will work. -** You don't need to install drivers inside containers. Just make sure it's working on your host OS. +## Major Update July 2024 -* Docker Installed -** Linux user may need to install https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html[NVIDIA Container Toolkit] (only on host OS). It will enable containers' GPU access. -** Windows user could use https://www.docker.com/products/docker-desktop/[Docker Desktop] with WSL2 enabled. -** For Podman users see: <>. +* alias `latest` as `cu121` +* alias `megapak` as `cu121-megapak` +* add `cu124-megapak` +* add `comfy3d-pt22`, `comfy3d-pt23` +* remove support for comfy3d in other images +* More detailed documentation coming soon... -## Usage - NVIDIA GPU -.A. Using `docker run` -[source,sh] ----- -mkdir -p storage +## Image tags -docker run -it \ - --name comfyui \ - --gpus all \ - -p 8188:8188 \ - -v "$(pwd)"/storage:/home/runner \ - -e CLI_ARGS="" \ - yanwk/comfyui-boot:latest ----- +* link:cu121/README.adoc[`cu121`, `latest`] -[source,sh] ----- -# Update image (only when Python components are outdated) -docker rm comfyui -docker pull yanwk/comfyui-boot:latest -# Then re-run above 'docker run' again ----- +** Recommended for most scenarios. Especially for users who are: +*** new to ComfyUI +*** new to Docker +*** using WSL2 Docker +** Not recommended for Podman or rootless users (use tags below). -.B. Using `docker compose` -[source,sh] ----- -git clone https://github.com/YanWenKun/ComfyUI-Docker.git +* link:cu121-megapak/README.adoc[`cu121-megapak`, `megapak`] -cd ComfyUI-Docker +** Big all-in-one, including dev kits. Ideal for "heavy" usage. +** Using CUDA 12.1 + Python 3.11. -docker compose up --detach ----- +* link:cu124-megapak/README.adoc[`cu124-megapak`] -[source,sh] ----- -# Update image (only when Python components are outdated) -git pull -docker compose pull -docker compose up --detach --remove-orphans -docker image prune ----- +** Similar to the above one, but using CUDA 12.4 + Python 3.12. +** May perform better on newer GPUs. -Once the app is loaded, visit http://localhost:8188/ +* link:rocm/README.adoc[`rocm`] +** For AMD GPUs. -## Usage - AMD GPU +* link:comfy3d-pt22/README.adoc[`comfy3d-pt22`] -See link:rocm/README.adoc[ROCm]. - - -## Tip - Comfy3D - -For +** Dedicated for https://github.com/MrForExample/ComfyUI-3D-Pack[ComfyUI-3D-Pack] -and other "heavy" usage, recommend using link:megapak/README.adoc[megapak] image. - - -[[cli-args]] -## CLI_ARGS - -[cols="1,1"] -|=== -|args |description - -|--lowvram -|If your GPU only has 4GB VRAM. - -|--novram -|If adding __--lowvram__ still out-of-memory. - -|--cpu -|Run on CPU. It's pretty slow. - -|--use-pytorch-cross-attention -|If you don't want to use xFormers. This may perform well on WSL2, but significantly slower on Linux hosts. -|=== - -More `CLI_ARGS` available at -https://github.com/comfyanonymous/ComfyUI/blob/master/comfy/cli_args.py[ComfyUI]. - - -## Add some custom nodes - -.Install a bunch of custom nodes that may save your time -[%collapsible] -==== -Note that most dependencies are bundled in the image, you don't need to manually install them. - -[source,sh] ----- -cd ComfyUI/custom_nodes/ - -gcs='git clone --depth=1 --no-tags --recurse-submodules --shallow-submodules' - -# Workspace -$gcs https://github.com/11cafe/comfyui-workspace-manager.git -$gcs https://github.com/AIGODLIKE/AIGODLIKE-ComfyUI-Translation.git -$gcs https://github.com/crystian/ComfyUI-Crystools-save.git -$gcs https://github.com/crystian/ComfyUI-Crystools.git - -# General -$gcs https://github.com/bash-j/mikey_nodes.git -$gcs https://github.com/chrisgoringe/cg-use-everywhere.git -$gcs https://github.com/cubiq/ComfyUI_essentials.git -$gcs https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes.git -$gcs https://github.com/jags111/efficiency-nodes-comfyui.git -$gcs https://github.com/kijai/ComfyUI-KJNodes.git -$gcs https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git -$gcs https://github.com/rgthree/rgthree-comfy.git -$gcs https://github.com/shiimizu/ComfyUI_smZNodes.git -$gcs https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes.git - -# Control -$gcs https://github.com/cubiq/ComfyUI_InstantID.git -$gcs https://github.com/cubiq/ComfyUI_IPAdapter_plus.git -$gcs https://github.com/Fannovel16/comfyui_controlnet_aux.git -$gcs https://github.com/florestefano1975/comfyui-portrait-master.git -$gcs https://github.com/Gourieff/comfyui-reactor-node.git -$gcs https://github.com/huchenlei/ComfyUI-layerdiffuse.git -$gcs https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet.git -$gcs https://github.com/ltdrdata/ComfyUI-Impact-Pack.git -$gcs https://github.com/ltdrdata/ComfyUI-Inspire-Pack.git -$gcs https://github.com/mcmonkeyprojects/sd-dynamic-thresholding.git -$gcs https://github.com/storyicon/comfyui_segment_anything.git -$gcs https://github.com/twri/sdxl_prompt_styler.git - -# Video -$gcs https://github.com/Fannovel16/ComfyUI-Frame-Interpolation.git -$gcs https://github.com/FizzleDorf/ComfyUI_FizzNodes.git -$gcs https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git -$gcs https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git -$gcs https://github.com/melMass/comfy_mtb.git -$gcs https://github.com/MrForExample/ComfyUI-AnimateAnyone-Evolved.git - -# More -$gcs https://github.com/cubiq/ComfyUI_FaceAnalysis.git -$gcs https://github.com/pythongosssss/ComfyUI-WD14-Tagger.git -$gcs https://github.com/SLAPaper/ComfyUI-Image-Selector.git -$gcs https://github.com/ssitu/ComfyUI_UltimateSDUpscale.git ----- - -Another note is this image doesn't bundled deps for -https://github.com/WASasquatch/was-node-suite-comfyui[WAS Node Suite], -because it has some deps version -https://github.com/WASasquatch/was-node-suite-comfyui/blob/main/requirements.txt[fixed], -and is not under active development. + -However, the image's script only install one custom node (ComfyUI-Manager). You can safely install WAS NS via ComfyUI-Manager in a new deployment. + -If anything conflicts, just delete unwanted custom nodes and `.local` (or `local`) folder, and update/try-fix/reinstall custom nodes in ComfyUI-Manager. -==== - - -## Pre-start scripts - -You can create your own pre-start script at ----- -./storage/scripts/pre-start.sh ----- -It will run before ComfyUI starts, handy for debugging. - -Also, if you need to setup proxy, this script will start before `pre-start` and `download` : ----- -./storage/scripts/set-proxy.sh ----- - - -[[podman]] -## Run with Podman - -Podman is root-less by default. And https://www.tutorialworks.com/podman-rootless-volumes/[it's tricky] to bind-mount volume as non-root user inside rootless container. -https://docs.podman.io/en/latest/markdown/podman-run.1.html#mount-type-type-type-specific-option[Options] provided by Podman will chown files on host space, which probably is undesirable. - -Recommend three different ways to workaround: - -### 1. Go "root-ful" just like Docker - -.Expand details -[%collapsible] -==== -The straightforward way. By adding `sudo` you go from rootless to rootful. And everything else would be the same as using Docker. - -Note that sudo Podman will download images to root space. If you already downloaded the image in current user, you can local-copy it: + -`sudo podman image scp username@localhost::docker.io/yanwk/comfyui-boot:latest` - -[source,sh] ----- -mkdir -p storage - -sudo podman run -it --rm \ - --name comfyui-rootful \ - --device nvidia.com/gpu=all \ - --security-opt label=disable \ - -p 8188:8188 \ - -v "$(pwd)"/storage:/home/runner \ - -e CLI_ARGS="" \ - docker.io/yanwk/comfyui-boot ----- -==== - -### 2. Run as root inside container - -.Expand details -[%collapsible] -==== -The rootless way, no sudo needed. Inside the pod, Podman will mount volume as root, scripts will run as root. And from the host side, we see files keep their original ownership. - -[source,sh] ----- -mkdir -p storage - -podman run -it --rm \ - --name comfyui-rootless \ - --device nvidia.com/gpu=all \ - --security-opt label=disable \ - -p 8188:8188 \ - -v "$(pwd)"/storage:/root \ - --user root \ - --workdir /root \ - -e CLI_ARGS="" \ - docker.io/yanwk/comfyui-boot:latest \ - /bin/bash /home/scripts/root-wrapper.sh ----- -==== - -### 3. Use link:megapak/README.adoc[megapak] image - -This image was built for rootless. - - -## Some commands for debugging - -.Build the image, print all logs to STDOUT -[source,sh] ----- -docker build . --progress=plain -f Dockerfile -t yanwk/comfyui-boot:latest ----- - -.Run a one-time container -[source,sh] ----- -docker run -it --rm \ - --gpus all -p 8188:8188 \ - --volume "$(pwd)"/storage:/home/runner \ - --env CLI_ARGS="" \ - yanwk/comfyui-boot:latest ----- - -.Run into a root bash -[source,sh] ----- -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 ----- - -.Clean up cache files -Usually this is not needed. -Some custom nodes will use `huggingface_hub` to download models and store them in `.cache`. -You may need to download them again after cleaning cache. + -But if having issues when updating, it may worth a try: - -[source,sh] ----- -docker exec -it --workdir /home/runner comfyui \ - rm -rf .cache/ .config/ .local/ .nv/ bin/ include/ lib/ lib64 pyvenv.cfg +** Running a classic version of Comfy3D based on PyTorch 2.2 -docker restart comfyui ----- +* link:comfy3d-pt23/README.adoc[`comfy3d-pt23`] +** Running a newer version of Comfy3D based on PyTorch 2.3 ## License diff --git a/README.zh.adoc b/README.zh.adoc index 8d8f455..246dfd4 100644 --- a/README.zh.adoc +++ b/README.zh.adoc @@ -1,10 +1,6 @@ # 用于 ComfyUI 的 Docker 镜像 -image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-latest.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions"] -image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-rocm.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/tree/main/rocm"] -image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-megapak.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/tree/main/megapak"] - -image::docs/chart-concept.zh.svg["布局"] +image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu121.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu121.yml"] https://github.com/comfyanonymous/ComfyUI[ComfyUI] 是一个使用节点工作流的 Stable Diffusion 图形界面。 + @@ -13,334 +9,48 @@ https://hub.docker.com/r/yanwk/comfyui-boot[Docker 镜像] 包含其依赖项,及下载/启动脚本。 -## 工作流程 - -1. 初次启动时,启动脚本会下载 ComfyUI、ComfyUI-Manager 以及一些常用的功能性模型。 -2. 整个 ComfyUI 会保存在本地 (`./storage/ComfyUI`) 。 -3. 如果你已经有了现成的 ComfyUI 包,放在上述目录,并新建一个空白文件 (`./storage/.download-complete`),启动脚本会跳过下载。 -4. 使用 ComfyUI-Manager 即可更新组件、安装模型(在 ComfyUI 页面中找到“Manager”)。 - - -## 运行前提 - -* NVIDIA 显卡, ≥6GB 显存 -** 4GB 显存见 <> -** AMD 显卡见 link:rocm/README.zh.adoc[ROCm]. - -* 安装好最新的 NVIDIA 显卡驱动 -** 游戏驱动或 Studio 驱动均可。 -** 只需要在宿主系统中安装驱动即可,容器中不需要再安装驱动。 - -* 安装好 Docker -** Windows 用户建议使用 https://www.docker.com/products/docker-desktop/[Docker Desktop] 并在安装时启用 WSL2,并 https://zhuanlan.zhihu.com/p/345645621[限制内存用量] 。 -** Linux 用户可能需要安装 https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html[NVIDIA Container Toolkit] (使得容器可以访问宿主机的 GPU)。 -** Podman 用户参见: <>。 - - -* 科学上网 -** 访问 GitHub(下载自定义节点)与 HuggingFace、Civitai(下载模型)大概率需要科学上网,访问 PyPI(安装依赖项)也可能需要加速。 -** Docker Desktop 用户可在设置中找到“代理”(Settings - Resources - Proxies)选项页。 -** Linux 用户可以使用 <>。 - -## 运行方法 - NVIDIA 显卡 - -.方法 A 使用 `docker run` -[source,sh] ----- -mkdir -p storage - -docker run -it \ - --name comfyui \ - --gpus all \ - -p 8188:8188 \ - -v "$(pwd)"/storage:/home/runner \ - -e CLI_ARGS="" \ - yanwk/comfyui-boot:latest ----- - -[source,sh] ----- -# 更新镜像(仅在 Python 组件版本过期时需要) -docker rm comfyui -docker pull yanwk/comfyui-boot:latest -# 接下来再运行一遍上述 'docker run' 即可 ----- - -.方法 B 使用 `docker compose` -[source,sh] ----- -git clone https://github.com/YanWenKun/ComfyUI-Docker.git - -cd ComfyUI-Docker - -docker compose up --detach ----- - -[source,sh] ----- -# 更新镜像(仅在 Python 组件版本过期时需要) -git pull -docker compose pull -docker compose up --detach --remove-orphans -docker image prune ----- - -启动完成后,访问 http://localhost:8188/ - - -## 运行方法 - AMD 显卡 - -参见 link:rocm/README.zh.adoc[ROCm]。 - - -## 提示 - Comfy3D - -对于 -https://github.com/MrForExample/ComfyUI-3D-Pack[ComfyUI-3D-Pack] -和其他“重型”使用场景,请使用 link:megapak/README.zh.adoc[megapak] 镜像。 - - -[[cli-args]] -## CLI_ARGS - -[cols="1,1"] -|=== -|启动参数 |说明 - -|--lowvram -|如果显存只有 4G - -|--novram -|如果用了 __--lowvram__ 还是显存不够,直接改用 CPU 内存 - -|--cpu -|用 CPU 来跑,会很慢 - -|--use-pytorch-cross-attention -|如果不想用 xFormers,而改用 PyTorch 原生交叉注意力机制。在 WSL2 上可能会有更好的速度/显存占用表现,但在 Linux 宿主机上会明显更慢。 -|=== - -更多 `CLI_ARGS` 参考 -https://github.com/comfyanonymous/ComfyUI/blob/master/comfy/cli_args.py[ComfyUI] 。 - - -[[pre-start]] -## 预启动脚本 - -如果需要在 ComfyUI 启动前执行脚本,可以创建这个文件: ----- -./storage/scripts/pre-start.sh ----- - -### 网络代理脚本 - -如果你需要单独设置代理,可以创建这个文件,它会在 `pre-start` 和 `download` 之前运行: ----- -./storage/scripts/set-proxy.sh ----- - -.参考脚本内容: -[%collapsible] -==== -提示:在容器内,不能直接通过 127.0.0.1 访问宿主机,需要走(虚拟)局域网,而容器平台一般都贴心绑定好了宿主机的 IP 地址-主机名: - -* 在 Docker 中是 `host.docker.internal` -* 在 Podman 中是 `host.containers.internal` - -[source,sh] ----- -#!/bin/bash -set -eu -export HTTP_PROXY=http://host.docker.internal:1081 -export HTTPS_PROXY=$HTTP_PROXY -export http_proxy=$HTTP_PROXY -export https_proxy=$HTTP_PROXY -export NO_PROXY="localhost,*.local,*.internal,[::1],fd00::/7, -10.0.0.0/8,127.0.0.0/8,169.254.0.0/16,172.16.0.0/12,192.168.0.0/16, -10.*,127.*,169.254.*,172.16.*,172.17.*,172.18.*,172.19.*,172.20.*, -172.21.*,172.22.*,172.23.*,172.24.*,172.25.*,172.26.*,172.27.*, -172.28.*,172.29.*,172.30.*,172.31.*,172.32.*,192.168.*, -*.cn,ghproxy.com,*.ghproxy.com,ghproxy.org,*.ghproxy.org, -gh-proxy.com,*.gh-proxy.com,ghproxy.net,*.ghproxy.net" -export no_proxy=$NO_PROXY -echo "[INFO] 代理设置为 $HTTP_PROXY" ----- -==== - - -## 一些自定义节点 - -.以下命令会安装一些常用节点,也许能帮你节省点时间 -[%collapsible] -==== -镜像里已经安装好了绝大部分依赖项,不需要手动安装。 - -[source,sh] ----- -cd ComfyUI/custom_nodes/ - -gcs='git clone --depth=1 --no-tags --recurse-submodules --shallow-submodules' - -# 工作空间 -$gcs https://github.com/11cafe/comfyui-workspace-manager.git -$gcs https://github.com/AIGODLIKE/AIGODLIKE-ComfyUI-Translation.git -$gcs https://github.com/crystian/ComfyUI-Crystools-save.git -$gcs https://github.com/crystian/ComfyUI-Crystools.git - -# 综合 -$gcs https://github.com/bash-j/mikey_nodes.git -$gcs https://github.com/chrisgoringe/cg-use-everywhere.git -$gcs https://github.com/cubiq/ComfyUI_essentials.git -$gcs https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes.git -$gcs https://github.com/jags111/efficiency-nodes-comfyui.git -$gcs https://github.com/kijai/ComfyUI-KJNodes.git -$gcs https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git -$gcs https://github.com/rgthree/rgthree-comfy.git -$gcs https://github.com/shiimizu/ComfyUI_smZNodes.git -$gcs https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes.git - -# 控制 -$gcs https://github.com/cubiq/ComfyUI_InstantID.git -$gcs https://github.com/cubiq/ComfyUI_IPAdapter_plus.git -$gcs https://github.com/Fannovel16/comfyui_controlnet_aux.git -$gcs https://github.com/florestefano1975/comfyui-portrait-master.git -$gcs https://github.com/Gourieff/comfyui-reactor-node.git -$gcs https://github.com/huchenlei/ComfyUI-layerdiffuse.git -$gcs https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet.git -$gcs https://github.com/ltdrdata/ComfyUI-Impact-Pack.git -$gcs https://github.com/ltdrdata/ComfyUI-Inspire-Pack.git -$gcs https://github.com/mcmonkeyprojects/sd-dynamic-thresholding.git -$gcs https://github.com/storyicon/comfyui_segment_anything.git -$gcs https://github.com/twri/sdxl_prompt_styler.git - -# 视频 -$gcs https://github.com/Fannovel16/ComfyUI-Frame-Interpolation.git -$gcs https://github.com/FizzleDorf/ComfyUI_FizzNodes.git -$gcs https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git -$gcs https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git -$gcs https://github.com/melMass/comfy_mtb.git -$gcs https://github.com/MrForExample/ComfyUI-AnimateAnyone-Evolved.git - -# 更多 -$gcs https://github.com/cubiq/ComfyUI_FaceAnalysis.git -$gcs https://github.com/pythongosssss/ComfyUI-WD14-Tagger.git -$gcs https://github.com/SLAPaper/ComfyUI-Image-Selector.git -$gcs https://github.com/ssitu/ComfyUI_UltimateSDUpscale.git ----- - -此外,本镜像并未提供 -https://github.com/WASasquatch/was-node-suite-comfyui[WAS Node Suite] -所需依赖项,因为其部分 -https://github.com/WASasquatch/was-node-suite-comfyui/blob/main/requirements.txt[版本固定], -而且已不再活跃开发。 + -但是通过 ComfyUI-Manager 正常安装不受影响,本镜像的脚本只安装 ComfyUI-Manager 这一个自定义节点。在全新部署的情况下,使用 ComfyUI-Manager 安装 WAS NS 不会有版本冲突。 + -如果不同节点间出现冲突,尝试在 `custom_nodes` 下删除对应节点,并删除 `.local` (或 `local`)目录,然后在 ComfyUI-Manager 中更新/尝试修复/重新安装对应节点。 -==== - - -[[podman]] -## 使用 Podman 运行 - -关于文件权限:Podman 默认是 root-less 的,不需要 sudo,这也给挂载目录 -https://www.tutorialworks.com/podman-rootless-volumes/[带来了限制] 。 + -Podman 默认挂载文件为 root 身份,而想要在容器内挂载为非 root 用户,Podman 提供的 -https://docs.podman.io/en/latest/markdown/podman-run.1.html#mount-type-type-type-specific-option[选项] -则会对主机上的文件执行 `chown`,变成和容器内一样的 uid 和 gid,给文件管理带来混乱。 - -这里推荐三种不同的方式绕过: - -### 1. 像 Docker 一样 "root-ful" - -.展开细节 -[%collapsible] -==== -简单直接的方式,用 `sudo` 来运行 Podman 就是 rootful 了,使用体验基本和 Docker 一样,就是记得后续操作也要用 "sudo"。 +## 2024 七月重大更新 -此外镜像文件也是下载到 root 用户名下。如果已经用当前 Linux 用户下载了镜像,可以本地复制: + -`sudo podman image scp username@localhost::docker.io/yanwk/comfyui-boot:latest` +* `latest` 更名 `cu121` (保留原名) +* `megapak` 更名 `cu121-megapak` (保留原名) +* 新增 `cu124-megapak` +* 新增 `comfy3d-pt22`, `comfy3d-pt23` +* 其他镜像移除 comfy3d 支持 -[source,sh] ----- -mkdir -p storage +* 文档细节完善中…… -sudo podman run -it --rm \ - --name comfyui-rootful \ - --device nvidia.com/gpu=all \ - --security-opt label=disable \ - -p 8188:8188 \ - -v "$(pwd)"/storage:/home/runner \ - -e CLI_ARGS="" \ - docker.io/yanwk/comfyui-boot ----- -==== -### 2. 在容器内改为 root 运行 +## 镜像标签 -.展开细节 -[%collapsible] -==== -保持 rootless 风格,不需要 sudo。容器内文件挂载为 root,程序也以 root 执行。而在宿主机一侧看来,文件还是本来的用户所有权。 +* link:cu121/README.zh.adoc[`cu121`, `latest`] -[source,sh] ----- -mkdir -p storage +** 适用于大多数使用场景。适合用户: +*** ComfyUI 新手 +*** Docker 新手 +*** WSL2 Docker 用户 +** 不推荐 Podman 或 rootless 用户使用(推荐用以下 megapak 标签) -podman run -it --rm \ - --name comfyui-rootless \ - --device nvidia.com/gpu=all \ - --security-opt label=disable \ - -p 8188:8188 \ - -v "$(pwd)"/storage:/root \ - --user root \ - --workdir /root \ - -e CLI_ARGS="" \ - docker.io/yanwk/comfyui-boot:latest \ - /bin/bash /home/scripts/root-wrapper.sh ----- -==== +* link:cu121-megapak/README.zh.adoc[`cu121-megapak`, `megapak`] -### 3. 改用 link:megapak/README.zh.adoc[megapak] 镜像 +** 大型整合包,包含开发组件,适用于“重型”使用场景 +** 基于 CUDA 12.1 + Python 3.11. -该镜像一开始就为 rootless 而设计。 +* link:cu124-megapak/README.zh.adoc[`cu124-megapak`] -## 一些方便 Debug 的命令 +** 与上一个标签基本一致,但基于 CUDA 12.4 + Python 3.12. +** 在新 GPU 上可能性能更佳 -.构建镜像,打印所有日志(不折叠) -[source,sh] ----- -docker build . --progress=plain -f Dockerfile -t yanwk/comfyui-boot:latest ----- +* link:rocm/README.zh.adoc[`rocm`] -.运行一个一次性容器 -[source,sh] ----- -docker run -it --rm \ - --gpus all -p 8188:8188 \ - --volume "$(pwd)"/storage:/home/runner \ - --env CLI_ARGS="" \ - yanwk/comfyui-boot:latest ----- +** 适用于 AMD GPU -.用 root 身份运行 bash -[source,sh] ----- -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 ----- +* link:comfy3d-pt22/README.zh.adoc[`comfy3d-pt22`] -.清理缓存文件 -如果在升级时遇到奇怪问题,可以尝试清理缓存文件。平时不需要清理,避免反复下载一些文件(尤其一些节点用 `huggingface_hub` 下载模型,会存在 `.cache` 中)。 -[source,sh] ----- -docker exec -it --workdir /home/runner comfyui \ - rm -rf .cache/ .config/ .local/ .nv/ bin/ include/ lib/ lib64 pyvenv.cfg +** https://github.com/MrForExample/ComfyUI-3D-Pack[ComfyUI-3D-Pack] 专用 +** 基于 PyTorch 2.2,使用经典版本的 Comfy3D -docker restart comfyui ----- +* link:comfy3d-pt23/README.zh.adoc[`comfy3d-pt23`] +** 基于 PyTorch 2.3,使用较新版本的 Comfy3D ## 声明 diff --git a/comfy3d-pt22/README.adoc b/comfy3d-pt22/README.adoc new file mode 100644 index 0000000..53c027d --- /dev/null +++ b/comfy3d-pt22/README.adoc @@ -0,0 +1,55 @@ +# Docker Image for Comfy3D + +image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-comfy3d-pt22.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-comfy3d-pt22.yml"] + +https://hub.docker.com/repository/docker/yanwk/comfyui-boot/tags?name=comfy3d-pt22[View on ] + + +* By default, install only ComfyUI, ComfyUI-Manager, ComfyUI-3D-Pack + +* Based on +https://gitlab.com/nvidia/container-images/cuda/-/blob/master/dist/12.1.1/ubi9/devel/cudnn8/Dockerfile[`nvidia/cuda:12.1.1-cudnn8-devel-ubi9`] + +* Dev kits: +** CUDA dev kit (12.1) +** Python dev package (3.11) +** GCC C++ (11) + +* Key Components: +** torch==2.2.2+cu121 +** xformers==0.0.25.post1 + +* Comfy3D version: +** https://github.com/MrForExample/ComfyUI-3D-Pack/tree/3b4e715939376634c68aa4c1c7d4ea4a8665c098[3b4e715] +(Jun 23, 2024) + +## Usage + +.Run with Docker +[source,sh] +---- +mkdir -p storage + +docker run -it --rm \ + --name comfy3d-pt22 \ + --gpus all \ + -p 8188:8188 \ + -v "$(pwd)"/storage:/root \ + -e CLI_ARGS="" \ + yanwk/comfyui-boot:comfy3d-pt22 +---- + +.Run with Podman +[source,sh] +---- +mkdir -p storage + +podman run -it --rm \ + --name comfy3d-pt22 \ + --device nvidia.com/gpu=all \ + --security-opt label=disable \ + -p 8188:8188 \ + -v "$(pwd)"/storage:/root \ + -e CLI_ARGS="" \ + docker.io/yanwk/comfyui-boot:comfy3d-pt22 +---- diff --git a/comfy3d-pt22/README.zh.adoc b/comfy3d-pt22/README.zh.adoc new file mode 100644 index 0000000..af8a848 --- /dev/null +++ b/comfy3d-pt22/README.zh.adoc @@ -0,0 +1,56 @@ +# Comfy3D 单独镜像 + +image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-comfy3d-pt22.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-comfy3d-pt22.yml"] + +https://hub.docker.com/repository/docker/yanwk/comfyui-boot/tags?name=comfy3d-pt22[在 上查看] + + +* 默认仅安装 ComfyUI, ComfyUI-Manager, ComfyUI-3D-Pack + +* 基于 +https://gitlab.com/nvidia/container-images/cuda/-/blob/master/dist/12.1.1/ubi9/devel/cudnn8/Dockerfile[`nvidia/cuda:12.1.1-cudnn8-devel-ubi9`] + +* 开发组件: +** CUDA dev kit (12.1) +** Python dev package (3.11) +** GCC C++ (11) + +* 关键组件: +** torch==2.2.3+cu121 +** xformers==0.0.25.post1 + +* Comfy3D 版本: +** https://github.com/MrForExample/ComfyUI-3D-Pack/tree/3b4e715939376634c68aa4c1c7d4ea4a8665c098[3b4e715] +(2024/06/23) + +## 用法 + +.使用 Docker +[source,sh] +---- +mkdir -p storage + +docker run -it --rm \ + --name comfy3d-pt22 \ + --gpus all \ + -p 8188:8188 \ + -v "$(pwd)"/storage:/root \ + -e CLI_ARGS="" \ + yanwk/comfyui-boot:comfy3d-pt22 +---- + +.使用 Podman +[source,sh] +---- +mkdir -p storage + +podman run -it --rm \ + --name comfy3d-pt22 \ + --device nvidia.com/gpu=all \ + --security-opt label=disable \ + -p 8188:8188 \ + -v "$(pwd)"/storage:/root \ + -e CLI_ARGS="" \ + docker.io/yanwk/comfyui-boot:comfy3d-pt22 +---- + diff --git a/comfy3d-pt23/README.adoc b/comfy3d-pt23/README.adoc new file mode 100644 index 0000000..ad00d4e --- /dev/null +++ b/comfy3d-pt23/README.adoc @@ -0,0 +1,55 @@ +# Docker Image for Comfy3D + +image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-comfy3d-pt23.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-comfy3d-pt23.yml"] + +https://hub.docker.com/repository/docker/yanwk/comfyui-boot/tags?name=comfy3d-pt23[View on ] + + +* By default, install only ComfyUI, ComfyUI-Manager, ComfyUI-3D-Pack + +* Based on +https://gitlab.com/nvidia/container-images/cuda/-/blob/master/dist/12.1.1/ubi9/devel/cudnn8/Dockerfile[`nvidia/cuda:12.1.1-cudnn8-devel-ubi9`] + +* Dev kits: +** CUDA dev kit (12.1) +** Python dev package (3.11) +** GCC C++ (11) + +* Key Components: +** torch==2.3.0+cu121 +** xformers==0.0.26.post1 + +* Comfy3D version: +** https://github.com/MrForExample/ComfyUI-3D-Pack/tree/30bc061d926f660e7f4822f54778df46326a8fec[30bc061] +(Jul 24, 2024) + +## Usage + +.Run with Docker +[source,sh] +---- +mkdir -p storage + +docker run -it --rm \ + --name comfy3d-pt23 \ + --gpus all \ + -p 8188:8188 \ + -v "$(pwd)"/storage:/root \ + -e CLI_ARGS="" \ + yanwk/comfyui-boot:comfy3d-pt23 +---- + +.Run with Podman +[source,sh] +---- +mkdir -p storage + +podman run -it --rm \ + --name comfy3d-pt23 \ + --device nvidia.com/gpu=all \ + --security-opt label=disable \ + -p 8188:8188 \ + -v "$(pwd)"/storage:/root \ + -e CLI_ARGS="" \ + docker.io/yanwk/comfyui-boot:comfy3d-pt23 +---- diff --git a/comfy3d-pt23/README.zh.adoc b/comfy3d-pt23/README.zh.adoc new file mode 100644 index 0000000..cff31fb --- /dev/null +++ b/comfy3d-pt23/README.zh.adoc @@ -0,0 +1,56 @@ +# Comfy3D 单独镜像 + +image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-comfy3d-pt23.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-comfy3d-pt23.yml"] + +https://hub.docker.com/repository/docker/yanwk/comfyui-boot/tags?name=comfy3d-pt23[在 上查看] + + +* 默认仅安装 ComfyUI, ComfyUI-Manager, ComfyUI-3D-Pack + +* 基于 +https://gitlab.com/nvidia/container-images/cuda/-/blob/master/dist/12.1.1/ubi9/devel/cudnn8/Dockerfile[`nvidia/cuda:12.1.1-cudnn8-devel-ubi9`] + +* 开发组件: +** CUDA dev kit (12.1) +** Python dev package (3.11) +** GCC C++ (11) + +* 关键组件: +** torch==2.3.0+cu121 +** xformers==0.0.26.post1 + +* Comfy3D 版本: +** https://github.com/MrForExample/ComfyUI-3D-Pack/tree/30bc061d926f660e7f4822f54778df46326a8fec[30bc061] +(2024/07/24) + +## 用法 + +.使用 Docker +[source,sh] +---- +mkdir -p storage + +docker run -it --rm \ + --name comfy3d-pt23 \ + --gpus all \ + -p 8188:8188 \ + -v "$(pwd)"/storage:/root \ + -e CLI_ARGS="" \ + yanwk/comfyui-boot:comfy3d-pt23 +---- + +.使用 Podman +[source,sh] +---- +mkdir -p storage + +podman run -it --rm \ + --name comfy3d-pt23 \ + --device nvidia.com/gpu=all \ + --security-opt label=disable \ + -p 8188:8188 \ + -v "$(pwd)"/storage:/root \ + -e CLI_ARGS="" \ + docker.io/yanwk/comfyui-boot:comfy3d-pt23 +---- + diff --git a/cu121-megapak/README.adoc b/cu121-megapak/README.adoc index 296bab9..ac59b04 100644 --- a/cu121-megapak/README.adoc +++ b/cu121-megapak/README.adoc @@ -1,5 +1,10 @@ # You've found MEGAPAK! +image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu121-megapak.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu121-megapak.yml"] + +https://hub.docker.com/repository/docker/yanwk/comfyui-boot/tags?name=cu121-megapak[View on ] + + *link:README.zh.adoc[中文说明]* `megapak` is a big all-in-one Docker image that has: diff --git a/cu121-megapak/README.zh.adoc b/cu121-megapak/README.zh.adoc index 8fa8ba8..46a03e2 100644 --- a/cu121-megapak/README.zh.adoc +++ b/cu121-megapak/README.zh.adoc @@ -1,5 +1,9 @@ # 你发现了 MEGAPAK! +image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu121-megapak.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu121-megapak.yml"] + +https://hub.docker.com/repository/docker/yanwk/comfyui-boot/tags?name=cu121-megapak[在 上查看] + `megapak` 是一个大而全的 Docker 镜像,包含: * 开发组件: diff --git a/cu121/README.adoc b/cu121/README.adoc new file mode 100644 index 0000000..0df8105 --- /dev/null +++ b/cu121/README.adoc @@ -0,0 +1,291 @@ +# Docker image for ComfyUI + +image::../docs/chart-concept.svg["Concept Design"] + +image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu121.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu121.yml"] + +https://hub.docker.com/repository/docker/yanwk/comfyui-boot/tags?name=cu121[View on ] + + +## How it works + +1. At first start, a script will download latest ComfyUI, ComfyUI-Manager and some models. +2. The whole ComfyUI will be stored in a local folder (`./storage/ComfyUI`). +3. If you already have a ComfyUI bundle, put it there and make an empty file (`./storage/.download-complete`) so the start script will skip downloading. +4. Use ComfyUI-Manager (in ComfyUI web page) to update ComfyUI, manage custom nodes, and download models. + + +## Prerequisites + +* NVIDIA GPU with ≥6GB VRAM +** For 4GB see <>. + +* Latest NVIDIA GPU driver +** Either Game or Studio edition will work. +** You don't need to install drivers inside containers. Just make sure it's working on your host OS. + +* Docker Installed +** Linux user may need to install https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html[NVIDIA Container Toolkit] (only on host OS). It will enable containers' GPU access. +** Windows user could use https://www.docker.com/products/docker-desktop/[Docker Desktop] with WSL2 enabled. + + +## Usage - NVIDIA GPU + +.A. Using `docker run` +[source,sh] +---- +mkdir -p storage + +docker run -it \ + --name comfyui \ + --gpus all \ + -p 8188:8188 \ + -v "$(pwd)"/storage:/home/runner \ + -e CLI_ARGS="" \ + yanwk/comfyui-boot:latest +---- + +[source,sh] +---- +# Update image (only when Python components are outdated) +docker rm comfyui +docker pull yanwk/comfyui-boot:latest +# Then re-run above 'docker run' again +---- + +.B. Using `docker compose` +[source,sh] +---- +git clone https://github.com/YanWenKun/ComfyUI-Docker.git + +cd ComfyUI-Docker + +docker compose up --detach +---- + +[source,sh] +---- +# Update image (only when Python components are outdated) +git pull +docker compose pull +docker compose up --detach --remove-orphans +docker image prune +---- + +Once the app is loaded, visit http://localhost:8188/ + + +[[cli-args]] +## CLI_ARGS + +[cols="1,1"] +|=== +|args |description + +|--lowvram +|If your GPU only has 4GB VRAM. + +|--novram +|If adding __--lowvram__ still out-of-memory. + +|--cpu +|Run on CPU. It's pretty slow. + +|--use-pytorch-cross-attention +|If you don't want to use xFormers. This may perform well on WSL2, but significantly slower on Linux hosts. +|=== + +More `CLI_ARGS` available at +https://github.com/comfyanonymous/ComfyUI/blob/master/comfy/cli_args.py[ComfyUI]. + + +## Add some custom nodes + +.Install a bunch of custom nodes that may save your time +[%collapsible] +==== +Note that most dependencies are bundled in the image, you don't need to manually install them. + +[source,sh] +---- +cd ComfyUI/custom_nodes/ + +gcs='git clone --depth=1 --no-tags --recurse-submodules --shallow-submodules' + +# Workspace +$gcs https://github.com/11cafe/comfyui-workspace-manager.git +$gcs https://github.com/AIGODLIKE/AIGODLIKE-ComfyUI-Translation.git +$gcs https://github.com/crystian/ComfyUI-Crystools-save.git +$gcs https://github.com/crystian/ComfyUI-Crystools.git + +# General +$gcs https://github.com/bash-j/mikey_nodes.git +$gcs https://github.com/chrisgoringe/cg-use-everywhere.git +$gcs https://github.com/cubiq/ComfyUI_essentials.git +$gcs https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes.git +$gcs https://github.com/jags111/efficiency-nodes-comfyui.git +$gcs https://github.com/kijai/ComfyUI-KJNodes.git +$gcs https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git +$gcs https://github.com/rgthree/rgthree-comfy.git +$gcs https://github.com/shiimizu/ComfyUI_smZNodes.git +$gcs https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes.git + +# Control +$gcs https://github.com/cubiq/ComfyUI_InstantID.git +$gcs https://github.com/cubiq/ComfyUI_IPAdapter_plus.git +$gcs https://github.com/Fannovel16/comfyui_controlnet_aux.git +$gcs https://github.com/florestefano1975/comfyui-portrait-master.git +$gcs https://github.com/Gourieff/comfyui-reactor-node.git +$gcs https://github.com/huchenlei/ComfyUI-layerdiffuse.git +$gcs https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet.git +$gcs https://github.com/ltdrdata/ComfyUI-Impact-Pack.git +$gcs https://github.com/ltdrdata/ComfyUI-Inspire-Pack.git +$gcs https://github.com/mcmonkeyprojects/sd-dynamic-thresholding.git +$gcs https://github.com/storyicon/comfyui_segment_anything.git +$gcs https://github.com/twri/sdxl_prompt_styler.git + +# Video +$gcs https://github.com/Fannovel16/ComfyUI-Frame-Interpolation.git +$gcs https://github.com/FizzleDorf/ComfyUI_FizzNodes.git +$gcs https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git +$gcs https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git +$gcs https://github.com/melMass/comfy_mtb.git +$gcs https://github.com/MrForExample/ComfyUI-AnimateAnyone-Evolved.git + +# More +$gcs https://github.com/cubiq/ComfyUI_FaceAnalysis.git +$gcs https://github.com/pythongosssss/ComfyUI-WD14-Tagger.git +$gcs https://github.com/SLAPaper/ComfyUI-Image-Selector.git +$gcs https://github.com/ssitu/ComfyUI_UltimateSDUpscale.git +---- + +Another note is this image doesn't bundled deps for +https://github.com/WASasquatch/was-node-suite-comfyui[WAS Node Suite], +because it has some deps version +https://github.com/WASasquatch/was-node-suite-comfyui/blob/main/requirements.txt[fixed], +and is not under active development. + +However, the image's script only install one custom node (ComfyUI-Manager). You can safely install WAS NS via ComfyUI-Manager in a new deployment. + +If anything conflicts, just delete unwanted custom nodes and `.local` (or `local`) folder, and update/try-fix/reinstall custom nodes in ComfyUI-Manager. +==== + + +## Pre-start scripts + +You can create your own pre-start script at +---- +./storage/scripts/pre-start.sh +---- +It will run before ComfyUI starts, handy for debugging. + +Also, if you need to setup proxy, this script will start before `pre-start` and `download` : +---- +./storage/scripts/set-proxy.sh +---- + + +// [[podman]] +// ## Run with Podman + +// Podman is root-less by default. And https://www.tutorialworks.com/podman-rootless-volumes/[it's tricky] to bind-mount volume as non-root user inside rootless container. +// https://docs.podman.io/en/latest/markdown/podman-run.1.html#mount-type-type-type-specific-option[Options] provided by Podman will chown files on host space, which probably is undesirable. + +// Recommend three different ways to workaround: + +// ### 1. Go "root-ful" just like Docker + +// .Expand details +// [%collapsible] +// ==== +// The straightforward way. By adding `sudo` you go from rootless to rootful. And everything else would be the same as using Docker. + +// Note that sudo Podman will download images to root space. If you already downloaded the image in current user, you can local-copy it: + +// `sudo podman image scp username@localhost::docker.io/yanwk/comfyui-boot:latest` + +// [source,sh] +// ---- +// mkdir -p storage + +// sudo podman run -it --rm \ +// --name comfyui-rootful \ +// --device nvidia.com/gpu=all \ +// --security-opt label=disable \ +// -p 8188:8188 \ +// -v "$(pwd)"/storage:/home/runner \ +// -e CLI_ARGS="" \ +// docker.io/yanwk/comfyui-boot +// ---- +// ==== + +// ### 2. Run as root inside container + +// .Expand details +// [%collapsible] +// ==== +// The rootless way, no sudo needed. Inside the pod, Podman will mount volume as root, scripts will run as root. And from the host side, we see files keep their original ownership. + +// [source,sh] +// ---- +// mkdir -p storage + +// podman run -it --rm \ +// --name comfyui-rootless \ +// --device nvidia.com/gpu=all \ +// --security-opt label=disable \ +// -p 8188:8188 \ +// -v "$(pwd)"/storage:/root \ +// --user root \ +// --workdir /root \ +// -e CLI_ARGS="" \ +// docker.io/yanwk/comfyui-boot:latest \ +// /bin/bash /home/scripts/root-wrapper.sh +// ---- +// ==== + +// ### 3. Use link:megapak/README.adoc[megapak] image + +// This image was built for rootless. + + +## Some commands for debugging + +.Build the image, print all logs to STDOUT +[source,sh] +---- +docker build . --progress=plain -f Dockerfile -t yanwk/comfyui-boot:latest +---- + +.Run a one-time container +[source,sh] +---- +docker run -it --rm \ + --gpus all -p 8188:8188 \ + --volume "$(pwd)"/storage:/home/runner \ + --env CLI_ARGS="" \ + yanwk/comfyui-boot:latest +---- + +.Run into a root bash +[source,sh] +---- +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 +---- + +.Clean up cache files +Usually this is not needed. +Some custom nodes will use `huggingface_hub` to download models and store them in `.cache`. +You may need to download them again after cleaning cache. + +But if having issues when updating, it may worth a try: + +[source,sh] +---- +docker exec -it --workdir /home/runner comfyui \ + rm -rf .cache/ .config/ .local/ .nv/ bin/ include/ lib/ lib64 pyvenv.cfg + +docker restart comfyui +---- + diff --git a/cu121/README.zh.adoc b/cu121/README.zh.adoc new file mode 100644 index 0000000..c04d34f --- /dev/null +++ b/cu121/README.zh.adoc @@ -0,0 +1,324 @@ +# 用于 ComfyUI 的 Docker 镜像 + +image::docs/chart-concept.zh.svg["布局"] + +image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu121.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu121.yml"] + +https://hub.docker.com/repository/docker/yanwk/comfyui-boot/tags?name=cu121[在 上查看] + + +## 工作流程 + +1. 初次启动时,启动脚本会下载 ComfyUI、ComfyUI-Manager 以及一些常用的功能性模型。 +2. 整个 ComfyUI 会保存在本地 (`./storage/ComfyUI`) 。 +3. 如果你已经有了现成的 ComfyUI 包,放在上述目录,并新建一个空白文件 (`./storage/.download-complete`),启动脚本会跳过下载。 +4. 使用 ComfyUI-Manager 即可更新组件、安装模型(在 ComfyUI 页面中找到“Manager”)。 + + +## 运行前提 + +* NVIDIA 显卡, ≥6GB 显存 +** 4GB 显存见 <> + +* 安装好最新的 NVIDIA 显卡驱动 +** 游戏驱动或 Studio 驱动均可。 +** 只需要在宿主系统中安装驱动即可,容器中不需要再安装驱动。 + +* 安装好 Docker +** Windows 用户建议使用 https://www.docker.com/products/docker-desktop/[Docker Desktop] 并在安装时启用 WSL2,并 https://zhuanlan.zhihu.com/p/345645621[限制内存用量] 。 +** Linux 用户可能需要安装 https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html[NVIDIA Container Toolkit] (使得容器可以访问宿主机的 GPU)。 + +* 科学上网 +** 访问 GitHub(下载自定义节点)与 HuggingFace、Civitai(下载模型)大概率需要科学上网,访问 PyPI(安装依赖项)也可能需要加速。 +** Docker Desktop 用户可在设置中找到“代理”(Settings - Resources - Proxies)选项页。 +** Linux 用户可以使用 <>。 + + +## 运行方法 - NVIDIA 显卡 + +.方法 A 使用 `docker run` +[source,sh] +---- +mkdir -p storage + +docker run -it \ + --name comfyui \ + --gpus all \ + -p 8188:8188 \ + -v "$(pwd)"/storage:/home/runner \ + -e CLI_ARGS="" \ + yanwk/comfyui-boot:latest +---- + +[source,sh] +---- +# 更新镜像(仅在 Python 组件版本过期时需要) +docker rm comfyui +docker pull yanwk/comfyui-boot:latest +# 接下来再运行一遍上述 'docker run' 即可 +---- + +.方法 B 使用 `docker compose` +[source,sh] +---- +git clone https://github.com/YanWenKun/ComfyUI-Docker.git + +cd ComfyUI-Docker + +docker compose up --detach +---- + +[source,sh] +---- +# 更新镜像(仅在 Python 组件版本过期时需要) +git pull +docker compose pull +docker compose up --detach --remove-orphans +docker image prune +---- + +启动完成后,访问 http://localhost:8188/ + + +[[cli-args]] +## CLI_ARGS + +[cols="1,1"] +|=== +|启动参数 |说明 + +|--lowvram +|如果显存只有 4G + +|--novram +|如果用了 __--lowvram__ 还是显存不够,直接改用 CPU 内存 + +|--cpu +|用 CPU 来跑,会很慢 + +|--use-pytorch-cross-attention +|如果不想用 xFormers,而改用 PyTorch 原生交叉注意力机制。在 WSL2 上可能会有更好的速度/显存占用表现,但在 Linux 宿主机上会明显更慢。 +|=== + +更多 `CLI_ARGS` 参考 +https://github.com/comfyanonymous/ComfyUI/blob/master/comfy/cli_args.py[ComfyUI] 。 + + +[[pre-start]] +## 预启动脚本 + +如果需要在 ComfyUI 启动前执行脚本,可以创建这个文件: +---- +./storage/scripts/pre-start.sh +---- + +### 网络代理脚本 + +如果你需要单独设置代理,可以创建这个文件,它会在 `pre-start` 和 `download` 之前运行: +---- +./storage/scripts/set-proxy.sh +---- + +.参考脚本内容: +[%collapsible] +==== +提示:在容器内,不能直接通过 127.0.0.1 访问宿主机,需要走(虚拟)局域网,而容器平台一般都贴心绑定好了宿主机的 IP 地址-主机名: + +* 在 Docker 中是 `host.docker.internal` +* 在 Podman 中是 `host.containers.internal` + +[source,sh] +---- +#!/bin/bash +set -eu +export HTTP_PROXY=http://host.docker.internal:1081 +export HTTPS_PROXY=$HTTP_PROXY +export http_proxy=$HTTP_PROXY +export https_proxy=$HTTP_PROXY +export NO_PROXY="localhost,*.local,*.internal,[::1],fd00::/7, +10.0.0.0/8,127.0.0.0/8,169.254.0.0/16,172.16.0.0/12,192.168.0.0/16, +10.*,127.*,169.254.*,172.16.*,172.17.*,172.18.*,172.19.*,172.20.*, +172.21.*,172.22.*,172.23.*,172.24.*,172.25.*,172.26.*,172.27.*, +172.28.*,172.29.*,172.30.*,172.31.*,172.32.*,192.168.*, +*.cn,ghproxy.com,*.ghproxy.com,ghproxy.org,*.ghproxy.org, +gh-proxy.com,*.gh-proxy.com,ghproxy.net,*.ghproxy.net" +export no_proxy=$NO_PROXY +echo "[INFO] 代理设置为 $HTTP_PROXY" +---- +==== + + +## 一些自定义节点 + +.以下命令会安装一些常用节点,也许能帮你节省点时间 +[%collapsible] +==== +镜像里已经安装好了绝大部分依赖项,不需要手动安装。 + +[source,sh] +---- +cd ComfyUI/custom_nodes/ + +gcs='git clone --depth=1 --no-tags --recurse-submodules --shallow-submodules' + +# 工作空间 +$gcs https://github.com/11cafe/comfyui-workspace-manager.git +$gcs https://github.com/AIGODLIKE/AIGODLIKE-ComfyUI-Translation.git +$gcs https://github.com/crystian/ComfyUI-Crystools-save.git +$gcs https://github.com/crystian/ComfyUI-Crystools.git + +# 综合 +$gcs https://github.com/bash-j/mikey_nodes.git +$gcs https://github.com/chrisgoringe/cg-use-everywhere.git +$gcs https://github.com/cubiq/ComfyUI_essentials.git +$gcs https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes.git +$gcs https://github.com/jags111/efficiency-nodes-comfyui.git +$gcs https://github.com/kijai/ComfyUI-KJNodes.git +$gcs https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git +$gcs https://github.com/rgthree/rgthree-comfy.git +$gcs https://github.com/shiimizu/ComfyUI_smZNodes.git +$gcs https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes.git + +# 控制 +$gcs https://github.com/cubiq/ComfyUI_InstantID.git +$gcs https://github.com/cubiq/ComfyUI_IPAdapter_plus.git +$gcs https://github.com/Fannovel16/comfyui_controlnet_aux.git +$gcs https://github.com/florestefano1975/comfyui-portrait-master.git +$gcs https://github.com/Gourieff/comfyui-reactor-node.git +$gcs https://github.com/huchenlei/ComfyUI-layerdiffuse.git +$gcs https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet.git +$gcs https://github.com/ltdrdata/ComfyUI-Impact-Pack.git +$gcs https://github.com/ltdrdata/ComfyUI-Inspire-Pack.git +$gcs https://github.com/mcmonkeyprojects/sd-dynamic-thresholding.git +$gcs https://github.com/storyicon/comfyui_segment_anything.git +$gcs https://github.com/twri/sdxl_prompt_styler.git + +# 视频 +$gcs https://github.com/Fannovel16/ComfyUI-Frame-Interpolation.git +$gcs https://github.com/FizzleDorf/ComfyUI_FizzNodes.git +$gcs https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git +$gcs https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git +$gcs https://github.com/melMass/comfy_mtb.git +$gcs https://github.com/MrForExample/ComfyUI-AnimateAnyone-Evolved.git + +# 更多 +$gcs https://github.com/cubiq/ComfyUI_FaceAnalysis.git +$gcs https://github.com/pythongosssss/ComfyUI-WD14-Tagger.git +$gcs https://github.com/SLAPaper/ComfyUI-Image-Selector.git +$gcs https://github.com/ssitu/ComfyUI_UltimateSDUpscale.git +---- + +此外,本镜像并未提供 +https://github.com/WASasquatch/was-node-suite-comfyui[WAS Node Suite] +所需依赖项,因为其部分 +https://github.com/WASasquatch/was-node-suite-comfyui/blob/main/requirements.txt[版本固定], +而且已不再活跃开发。 + +但是通过 ComfyUI-Manager 正常安装不受影响,本镜像的脚本只安装 ComfyUI-Manager 这一个自定义节点。在全新部署的情况下,使用 ComfyUI-Manager 安装 WAS NS 不会有版本冲突。 + +如果不同节点间出现冲突,尝试在 `custom_nodes` 下删除对应节点,并删除 `.local` (或 `local`)目录,然后在 ComfyUI-Manager 中更新/尝试修复/重新安装对应节点。 +==== + + +// [[podman]] +// ## 使用 Podman 运行 + +// 关于文件权限:Podman 默认是 root-less 的,不需要 sudo,这也给挂载目录 +// https://www.tutorialworks.com/podman-rootless-volumes/[带来了限制] 。 + +// Podman 默认挂载文件为 root 身份,而想要在容器内挂载为非 root 用户,Podman 提供的 +// https://docs.podman.io/en/latest/markdown/podman-run.1.html#mount-type-type-type-specific-option[选项] +// 则会对主机上的文件执行 `chown`,变成和容器内一样的 uid 和 gid,给文件管理带来混乱。 + +// 这里推荐三种不同的方式绕过: + +// ### 1. 像 Docker 一样 "root-ful" + +// .展开细节 +// [%collapsible] +// ==== +// 简单直接的方式,用 `sudo` 来运行 Podman 就是 rootful 了,使用体验基本和 Docker 一样,就是记得后续操作也要用 "sudo"。 + +// 此外镜像文件也是下载到 root 用户名下。如果已经用当前 Linux 用户下载了镜像,可以本地复制: + +// `sudo podman image scp username@localhost::docker.io/yanwk/comfyui-boot:latest` + +// [source,sh] +// ---- +// mkdir -p storage + +// sudo podman run -it --rm \ +// --name comfyui-rootful \ +// --device nvidia.com/gpu=all \ +// --security-opt label=disable \ +// -p 8188:8188 \ +// -v "$(pwd)"/storage:/home/runner \ +// -e CLI_ARGS="" \ +// docker.io/yanwk/comfyui-boot +// ---- +// ==== + +// ### 2. 在容器内改为 root 运行 + +// .展开细节 +// [%collapsible] +// ==== +// 保持 rootless 风格,不需要 sudo。容器内文件挂载为 root,程序也以 root 执行。而在宿主机一侧看来,文件还是本来的用户所有权。 + +// [source,sh] +// ---- +// mkdir -p storage + +// podman run -it --rm \ +// --name comfyui-rootless \ +// --device nvidia.com/gpu=all \ +// --security-opt label=disable \ +// -p 8188:8188 \ +// -v "$(pwd)"/storage:/root \ +// --user root \ +// --workdir /root \ +// -e CLI_ARGS="" \ +// docker.io/yanwk/comfyui-boot:latest \ +// /bin/bash /home/scripts/root-wrapper.sh +// ---- +// ==== + +// ### 3. 改用 link:megapak/README.zh.adoc[megapak] 镜像 + +// 该镜像一开始就为 rootless 而设计。 + + +## 一些方便 Debug 的命令 + +.构建镜像,打印所有日志(不折叠) +[source,sh] +---- +docker build . --progress=plain -f Dockerfile -t yanwk/comfyui-boot:latest +---- + +.运行一个一次性容器 +[source,sh] +---- +docker run -it --rm \ + --gpus all -p 8188:8188 \ + --volume "$(pwd)"/storage:/home/runner \ + --env CLI_ARGS="" \ + yanwk/comfyui-boot:latest +---- + +.用 root 身份运行 bash +[source,sh] +---- +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 +---- + +.清理缓存文件 +如果在升级时遇到奇怪问题,可以尝试清理缓存文件。平时不需要清理,避免反复下载一些文件(尤其一些节点用 `huggingface_hub` 下载模型,会存在 `.cache` 中)。 +[source,sh] +---- +docker exec -it --workdir /home/runner comfyui \ + rm -rf .cache/ .config/ .local/ .nv/ bin/ include/ lib/ lib64 pyvenv.cfg + +docker restart comfyui +---- diff --git a/cu124-megapak/README.adoc b/cu124-megapak/README.adoc index 88b4748..3be6e5c 100644 --- a/cu124-megapak/README.adoc +++ b/cu124-megapak/README.adoc @@ -1,4 +1,9 @@ -# Image for CUDA 12.4 (early stage) +# MEGAPAK for CUDA 12.4 (early stage) + +image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu124-megapak.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu124-megapak.yml"] + +https://hub.docker.com/repository/docker/yanwk/comfyui-boot/tags?name=cu124-megapak[View on ] + * Derived from `cu121-megapak` @@ -9,7 +14,7 @@ ** OpenCV-devel ** CMake, Ninja... -* Nightly version of xFormers + PyTorch +* Latest stable version of xFormers + PyTorch * Tools: ** Vim, Fish, fd... diff --git a/cu124-megapak/README.zh.adoc b/cu124-megapak/README.zh.adoc new file mode 100644 index 0000000..6b21174 --- /dev/null +++ b/cu124-megapak/README.zh.adoc @@ -0,0 +1,35 @@ +# MEGAPAK,但是 CUDA 12.4 (早期版本) + +image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu124-megapak.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-cu124-megapak.yml"] + +https://hub.docker.com/repository/docker/yanwk/comfyui-boot/tags?name=cu124-megapak[在 上查看] + + +* 基于 `cu121-megapak` 演进而来 + +* 开发组件: +** CUDA dev kit (12.4) +** Python dev package (3.12) +** GCC C++ (13) +** OpenCV-devel +** CMake, Ninja... + +* 最新稳定版 xFormers + PyTorch + +* 工具: +** Vim, Fish, fd... + +.使用 Podman 运行 +[source,bash] +---- +mkdir -p storage + +podman run -it --rm \ + --name comfyui-cu124-mega \ + --device nvidia.com/gpu=all \ + --security-opt label=disable \ + -p 8188:8188 \ + -v "$(pwd)"/storage:/root \ + -e CLI_ARGS="" \ + docker.io/yanwk/comfyui-boot:cu124-megapak +---- diff --git a/docs/README-DockerHub.md b/docs/README-DockerHub.md index 73378e9..69880ba 100644 --- a/docs/README-DockerHub.md +++ b/docs/README-DockerHub.md @@ -1,16 +1,12 @@ # ComfyUI -[![GitHub Workflow Status](https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-latest.yml/badge.svg)](https://github.com/YanWenKun/ComfyUI-Docker/actions) -[![GitHub Workflow Status](https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-rocm.yml/badge.svg)](https://github.com/YanWenKun/ComfyUI-Docker/tree/main/rocm) -[![GitHub Workflow Status](https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-megapak.yml/badge.svg)](https://github.com/YanWenKun/ComfyUI-Docker/tree/main/megapak) - **[CHECK THE GITHUB REPO](https://github.com/YanWenKun/ComfyUI-Docker)** **[中文文档在 GITHUB 上](https://github.com/YanWenKun/ComfyUI-Docker/blob/main/README.zh.adoc)** Docker images for [ComfyUI](https://github.com/comfyanonymous/ComfyUI) - a Stable Diffusion GUI powering node-based workflow. -## Usage - NVIDIA GPU +## Quick Start - NVIDIA GPU ```sh mkdir -p storage @@ -21,7 +17,7 @@ docker run -it --rm \ -p 8188:8188 \ -v "$(pwd)"/storage:/home/runner \ -e CLI_ARGS="" \ - yanwk/comfyui-boot:latest + yanwk/comfyui-boot:cu121 ``` Once the app is loaded, visit http://localhost:8188/ @@ -30,6 +26,6 @@ Once the app is loaded, visit http://localhost:8188/ - [AMD GPU with ROCm](https://github.com/YanWenKun/ComfyUI-Docker/tree/main/rocm) -- ["Megapak" (all-in-one bundle)](https://github.com/YanWenKun/ComfyUI-Docker/tree/main/megapak) +- ["Megapak" (all-in-one bundle)](https://github.com/YanWenKun/ComfyUI-Docker/tree/main/cu121-megapak) - For docs and image detail, check [GitHub Page](https://github.com/YanWenKun/ComfyUI-Docker). diff --git a/rocm/README.adoc b/rocm/README.adoc index d9a1ff7..3233129 100644 --- a/rocm/README.adoc +++ b/rocm/README.adoc @@ -2,6 +2,10 @@ *link:README.zh.adoc[中文说明]* +image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-rocm.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-rocm.yml"] + +https://hub.docker.com/repository/docker/yanwk/comfyui-boot/tags?name=rocm[View on ] + ## In case of WSL2 If you are using WSL2 with AMD/Intel GPU, try diff --git a/rocm/README.zh.adoc b/rocm/README.zh.adoc index abf9e17..c7b9a77 100644 --- a/rocm/README.zh.adoc +++ b/rocm/README.zh.adoc @@ -1,5 +1,9 @@ # 基于 AMD GPU + ROCm 运行 ComfyUI +image:https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-rocm.yml/badge.svg["GitHub Workflow Status",link="https://github.com/YanWenKun/ComfyUI-Docker/actions/workflows/build-rocm.yml"] + +https://hub.docker.com/repository/docker/yanwk/comfyui-boot/tags?name=rocm[在 上查看] + ## 提醒: WSL2 用户 如果你在用 WSL2 + AMD/Intel GPU, 可以考虑: