This repo is for Docker images that runs ComfyUI - a Stable Diffusion GUI powering node-based workflow.
-
At first start, a script will download latest ComfyUI, some custom nodes and models.
-
The whole ComfyUI will be stored in a local folder (
./storage/ComfyUI
). -
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. -
You can update ComfyUI & its custom nodes via ComfyUI-Manager (in ComfyUI web page).
-
NVIDIA GPU with ≥6GB VRAM
-
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 NVIDIA Container Toolkit (only on host OS). It will enable containers' GPU access.
-
Windows user could use Docker Desktop with WSL2 enabled.
-
docker compose
git clone https://github.com/YanWenKun/ComfyUI-Docker.git
cd ComfyUI-Docker
docker compose up --detach
# Update image (only when Python components are outdated)
git pull
docker compose pull
docker compose up --detach --remove-orphans
docker image prune
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
# Update image (only when Python components are outdated)
docker rm comfyui
docker pull yanwk/comfyui-boot:latest
# Then re-run 'docker run' above again
Once the app is loaded, visit http://localhost:8188/
Note
|
If you are using WSL2 with AMD/Intel GPU, consider Run ComfyUI on WSL2 with DirectML |
docker compose
git clone https://github.com/YanWenKun/ComfyUI-Docker.git
cd ComfyUI-Docker
docker compose -f docker-compose-rocm.yml up --detach
# Update image (only when Python components are outdated)
git pull
docker compose -f docker-compose-rocm.yml pull
docker compose -f docker-compose-rocm.yml up --detach --remove-orphans
docker image prune
docker run
mkdir -p storage
docker run -it \
--name comfyui \
-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
# Update image (only when Python components are outdated)
docker rm comfyui
docker pull yanwk/comfyui-boot:rocm
# Then re-run 'docker run' above again
Once the app is loaded, visit http://localhost:8188/
Q: My GPU has only 4GB VRAM
A: Add --lowvram
to CLI_ARGS
.
Q: Adding --lowvram
still out-of-memory
A: Use --novram
instead. It will use CPU RAM.
Q: How to run on CPU?
A: Add --cpu
to CLI_ARGS
. It’s pretty slow.
Q: I don’t want to use xFormers, how to use PyTorch’s Cross Attention?
A: Add --use-pytorch-cross-attention
to CLI_ARGS
. It may perform well on WSL2, but significantly slower on Linux hosts.
More CLI_ARGS
available at
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
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
Podman is root-less by default. And it’s tricky to bind-mount volume as non-root user inside rootless container. Options provided by Podman will chown files on host space, which probably is undesirable.
I recommend two different ways to workaround:
Expand details
The straightforward way. By adding sudo
you go from rootless to rootful. And everything else would be the same as using Docker.
Note that Podman will download images to root, not the user.
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
Expand details
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.
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
Install a bunch of custom nodes that may save you some time
Note that most dependencies are bundled in the image, you don’t need to manually install them.
(Except imageio-ffmpeg
which uses FFmpeg4. The image came with FFmpeg6 or newer.)
cd ComfyUI/custom_nodes/
gcs='git clone --depth=1 --no-tags --recurse-submodules --shallow-submodules'
$gcs https://github.com/bash-j/mikey_nodes.git
$gcs https://github.com/chrisgoringe/cg-use-everywhere.git
$gcs https://github.com/crystian/ComfyUI-Crystools.git
$gcs https://github.com/cubiq/ComfyUI_essentials.git
$gcs https://github.com/cubiq/ComfyUI_IPAdapter_plus.git
$gcs https://github.com/Fannovel16/comfyui_controlnet_aux.git
$gcs https://github.com/Fannovel16/ComfyUI-Frame-Interpolation.git
$gcs https://github.com/FizzleDorf/ComfyUI_FizzNodes.git
$gcs https://github.com/jags111/efficiency-nodes-comfyui.git
$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/ltdrdata/ComfyUI-Impact-Pack.git
$gcs https://github.com/ltdrdata/ComfyUI-Inspire-Pack.git
$gcs https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git
$gcs https://github.com/pythongosssss/ComfyUI-WD14-Tagger.git
$gcs https://github.com/rgthree/rgthree-comfy.git
$gcs https://github.com/shiimizu/ComfyUI_smZNodes.git
$gcs https://github.com/SLAPaper/ComfyUI-Image-Selector.git
$gcs https://github.com/twri/sdxl_prompt_styler.git
$gcs https://github.com/ZHO-ZHO-ZHO/ComfyUI-InstantID.git
Another note is this image doesn’t bundled deps for
WAS Node Suite,
because it has some deps version
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.
This open source license is written and valid both in Chinese and English, how good is that!