diff --git a/README.adoc b/README.adoc index 0bb01fe..a0697e6 100644 --- a/README.adoc +++ b/README.adoc @@ -32,6 +32,7 @@ a Stable Diffusion GUI powering node-based workflow. ** 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. @@ -166,6 +167,109 @@ docker run -it --rm \ yanwk/comfyui-boot:latest /bin/bash ---- +### 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. + +So I recommend two workaround: + +#### 1. Go "root-ful" as Docker does + +.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. + +[source,sh] +---- +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="" \ + yanwk/comfyui-boot +---- +==== + +#### 2. Run as root inside container + +.Expand details +[%collapsible] +==== +The rootless way. Inside the pod, Podman will mount volume as root, the program will run as root. And from the host side, we see files maintain their original ownership. + +.Create run.sh +[source,sh] +---- +tee storage/run.sh >/dev/null <<'EOF' +#!/bin/bash +set -e +ln -sf /root /home/runner +cd /root +if [ ! -f "/root/bin/activate" ] ; then + python3 -m venv --system-site-packages . +fi ; +source /root/bin/activate +chmod +x /home/scripts/entrypoint.sh +source /home/scripts/entrypoint.sh +EOF +---- + +.Run +[source,sh] +---- +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 \ + -e CLI_ARGS="" \ + yanwk/comfyui-boot /bin/bash /root/run.sh +---- +==== + + +### Some custom nodes + +.Install a bunch of custom nodes that may save you some time +[%collapsible] +==== +[source,sh] +---- +cd ComfyUI/custom_nodes/ + +gcs='git clone --depth=1 --no-tags --recurse-submodules --shallow-submodules' + +$gcs https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet.git +$gcs https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git +$gcs https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git +$gcs https://github.com/FizzleDorf/ComfyUI_FizzNodes.git +$gcs https://github.com/ZHO-ZHO-ZHO/ComfyUI-InstantID.git +$gcs https://github.com/Fannovel16/comfyui_controlnet_aux.git +$gcs https://github.com/ltdrdata/ComfyUI-Impact-Pack.git +$gcs https://github.com/ltdrdata/ComfyUI-Inspire-Pack.git +$gcs https://github.com/shiimizu/ComfyUI_smZNodes.git +$gcs https://github.com/crystian/ComfyUI-Crystools.git +$gcs https://github.com/jags111/efficiency-nodes-comfyui.git +$gcs https://github.com/cubiq/ComfyUI_essentials.git +$gcs https://github.com/chrisgoringe/cg-use-everywhere.git +$gcs https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git +$gcs https://github.com/pythongosssss/ComfyUI-WD14-Tagger.git +$gcs https://github.com/bash-j/mikey_nodes.git +$gcs https://github.com/twri/sdxl_prompt_styler.git +$gcs https://github.com/rgthree/rgthree-comfy.git +$gcs https://github.com/Fannovel16/ComfyUI-Frame-Interpolation.git +$gcs https://github.com/cubiq/ComfyUI_IPAdapter_plus.git +$gcs https://github.com/SLAPaper/ComfyUI-Image-Selector.git +---- +==== + + ### Pre-start script You can create your own pre-start script at diff --git a/README.zh.adoc b/README.zh.adoc index 4cd1ee3..dc660bd 100644 --- a/README.zh.adoc +++ b/README.zh.adoc @@ -31,6 +31,7 @@ ComfyUI 是一个使用节点工作流的 Stable Diffusion 图形界面。 ** 只需要在宿主系统中安装驱动即可,容器中不需要再安装驱动。 * 安装好 Docker +** Linux 用户可能需要安装 https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html[NVIDIA Container Toolkit] (使得容器可以访问宿主机的 GPU)。 ** Windows 用户建议使用 https://www.docker.com/products/docker-desktop/[Docker Desktop] 并在安装时启用 WSL2,并 https://zhuanlan.zhihu.com/p/345645621[限制内存用量] 。 ** 下载过程可能需要科学上网,在 Docker 设置中可以找到代理设置。 @@ -166,6 +167,113 @@ docker run -it --rm \ yanwk/comfyui-boot:latest /bin/bash ---- + +### 使用 Podman 运行 + +Podman 默认是 root-less 的,不需要 sudo,这也 +https://www.tutorialworks.com/podman-rootless-volumes/[给挂载目录带来了限制] +。Podman 默认挂载文件为 root 身份,而想要挂载为容器内非 root 用户, +https://docs.podman.io/en/latest/markdown/podman-run.1.html#mount-type-type-type-specific-option[Podman 提供的选项] +则会把主机上的文件给 chown 掉,变成和容器内一样的 uid 和 gid,这可算不上好操作。 + +这里推荐两种方式绕过: + +#### 1. 像 Docker 一样 "root-ful" + +.展开细节 +[%collapsible] +==== +简单直接的方式,用 "sudo" 来运行 Podman 就是 rootful 了,剩下的基本和 Docker 一样,就是记得后续操作也要用 "sudo"。 + +[source,sh] +---- +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="" \ + yanwk/comfyui-boot +---- +==== + +#### 2. 在容器内改为 root 运行 + +.展开细节 +[%collapsible] +==== +保持 rootless 风格,容器内文件挂载为 root,程序也以 root 执行。而在主机一侧看来,文件还是本来的用户所有权,也不需要 sudo。 + +.初次创建脚本 run.sh +[source,sh] +---- +tee storage/run.sh >/dev/null <<'EOF' +#!/bin/bash +set -e +ln -sf /root /home/runner +cd /root +if [ ! -f "/root/bin/activate" ] ; then + python3 -m venv --system-site-packages . +fi ; +source /root/bin/activate +chmod +x /home/scripts/entrypoint.sh +source /home/scripts/entrypoint.sh +EOF +---- + +.运行启动 +[source,sh] +---- +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 \ + -e CLI_ARGS="" \ + yanwk/comfyui-boot /bin/bash /root/run.sh +---- +==== + + +### 一些自定义节点 + +.安装一大堆节点,也许能帮你节省点时间 +[%collapsible] +==== +[source,sh] +---- +cd ComfyUI/custom_nodes/ + +gcs='git clone --depth=1 --no-tags --recurse-submodules --shallow-submodules' + +$gcs https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet.git +$gcs https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git +$gcs https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git +$gcs https://github.com/FizzleDorf/ComfyUI_FizzNodes.git +$gcs https://github.com/ZHO-ZHO-ZHO/ComfyUI-InstantID.git +$gcs https://github.com/Fannovel16/comfyui_controlnet_aux.git +$gcs https://github.com/ltdrdata/ComfyUI-Impact-Pack.git +$gcs https://github.com/ltdrdata/ComfyUI-Inspire-Pack.git +$gcs https://github.com/shiimizu/ComfyUI_smZNodes.git +$gcs https://github.com/crystian/ComfyUI-Crystools.git +$gcs https://github.com/jags111/efficiency-nodes-comfyui.git +$gcs https://github.com/cubiq/ComfyUI_essentials.git +$gcs https://github.com/chrisgoringe/cg-use-everywhere.git +$gcs https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git +$gcs https://github.com/pythongosssss/ComfyUI-WD14-Tagger.git +$gcs https://github.com/bash-j/mikey_nodes.git +$gcs https://github.com/twri/sdxl_prompt_styler.git +$gcs https://github.com/rgthree/rgthree-comfy.git +$gcs https://github.com/Fannovel16/ComfyUI-Frame-Interpolation.git +$gcs https://github.com/cubiq/ComfyUI_IPAdapter_plus.git +$gcs https://github.com/SLAPaper/ComfyUI-Image-Selector.git +---- +==== + + ### 预启动脚本 如果需要在 ComfyUI 启动前执行脚本,可以创建这个文件: