Skip to content

Commit bf4a218

Browse files
authored
Merge pull request #66 from mmartial/202508wip
20250817
2 parents 3a3b54e + b1d6e49 commit bf4a218

File tree

6 files changed

+268
-78
lines changed

6 files changed

+268
-78
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
FROM nvidia/cuda:13.0.0-cudnn-devel-ubuntu24.04
2+
ARG BASE_DOCKER_FROM=nvidia/cuda:13.0.0-cudnn-devel-ubuntu24.04
3+
##### Base
4+
5+
# Install system packages
6+
ENV DEBIAN_FRONTEND=noninteractive
7+
RUN apt-get update -y --fix-missing\
8+
&& apt-get install -y \
9+
apt-utils \
10+
locales \
11+
ca-certificates \
12+
&& apt-get upgrade -y \
13+
&& apt-get clean
14+
15+
# UTF-8
16+
RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
17+
ENV LANG=en_US.utf8
18+
ENV LC_ALL=C
19+
20+
# Install needed packages
21+
RUN apt-get update -y --fix-missing \
22+
&& apt-get upgrade -y \
23+
&& apt-get install -y \
24+
build-essential \
25+
python3-dev \
26+
unzip \
27+
wget \
28+
zip \
29+
zlib1g \
30+
zlib1g-dev \
31+
gnupg \
32+
rsync \
33+
python3-pip \
34+
python3-venv \
35+
git \
36+
sudo \
37+
libglib2.0-0 \
38+
socat \
39+
&& apt-get clean
40+
41+
# Add libEGL ICD loaders and libraries + Vulkan ICD loaders and libraries
42+
# Per https://github.com/mmartial/ComfyUI-Nvidia-Docker/issues/26
43+
RUN apt install -y libglvnd0 libglvnd-dev libegl1-mesa-dev libvulkan1 libvulkan-dev ffmpeg \
44+
&& apt-get clean \
45+
&& rm -rf /var/lib/apt/lists/* \
46+
&& mkdir -p /usr/share/glvnd/egl_vendor.d \
47+
&& echo '{"file_format_version":"1.0.0","ICD":{"library_path":"libEGL_nvidia.so.0"}}' > /usr/share/glvnd/egl_vendor.d/10_nvidia.json \
48+
&& mkdir -p /usr/share/vulkan/icd.d \
49+
&& echo '{"file_format_version":"1.0.0","ICD":{"library_path":"libGLX_nvidia.so.0","api_version":"1.3"}}' > /usr/share/vulkan/icd.d/nvidia_icd.json
50+
ENV MESA_D3D12_DEFAULT_ADAPTER_NAME="NVIDIA"
51+
52+
ENV BUILD_FILE="/etc/image_base.txt"
53+
ARG BASE_DOCKER_FROM
54+
RUN echo "DOCKER_FROM: ${BASE_DOCKER_FROM}" | tee ${BUILD_FILE}
55+
RUN echo "CUDNN: ${NV_CUDNN_PACKAGE_NAME} (${NV_CUDNN_VERSION})" | tee -a ${BUILD_FILE}
56+
57+
ARG BUILD_BASE="unknown"
58+
LABEL comfyui-nvidia-docker-build-from=${BUILD_BASE}
59+
RUN it="/etc/build_base.txt"; echo ${BUILD_BASE} > $it && chmod 555 $it
60+
61+
# Place the init script and its config in / so it can be found by the entrypoint
62+
COPY --chmod=555 init.bash /comfyui-nvidia_init.bash
63+
COPY --chmod=555 config.sh /comfyui-nvidia_config.sh
64+
65+
##### ComfyUI preparation
66+
# Every sudo group user does not need a password
67+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
68+
69+
# Create a new group for the comfy and comfytoo users
70+
RUN groupadd -g 1024 comfy \
71+
&& groupadd -g 1025 comfytoo
72+
73+
# The comfy (resp. comfytoo) user will have UID 1024 (resp. 1025),
74+
# be part of the comfy (resp. comfytoo) and users groups and be sudo capable (passwordless)
75+
RUN useradd -u 1024 -d /home/comfy -g comfy -s /bin/bash -m comfy \
76+
&& usermod -G users comfy \
77+
&& adduser comfy sudo
78+
RUN useradd -u 1025 -d /home/comfytoo -g comfytoo -s /bin/bash -m comfytoo \
79+
&& usermod -G users comfytoo \
80+
&& adduser comfytoo sudo
81+
82+
ENV COMFYUSER_DIR="/comfy"
83+
RUN mkdir -p ${COMFYUSER_DIR}
84+
RUN it="/etc/comfyuser_dir"; echo ${COMFYUSER_DIR} > $it && chmod 555 $it
85+
86+
ENV NVIDIA_DRIVER_CAPABILITIES="all"
87+
ENV NVIDIA_VISIBLE_DEVICES=all
88+
89+
EXPOSE 8188
90+
91+
ARG COMFYUI_NVIDIA_DOCKER_VERSION="unknown"
92+
LABEL comfyui-nvidia-docker-build=${COMFYUI_NVIDIA_DOCKER_VERSION}
93+
RUN echo "COMFYUI_NVIDIA_DOCKER_VERSION: ${COMFYUI_NVIDIA_DOCKER_VERSION}" | tee -a ${BUILD_FILE}
94+
95+
# We start as comfytoo and will switch to the comfy user AFTER the container is up
96+
# and after having altered the comfy details to match the requested UID/GID
97+
USER comfytoo
98+
99+
# We use ENTRYPOINT to run the init script (from CMD)
100+
ENTRYPOINT [ "/comfyui-nvidia_init.bash" ]

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ DOCKER_CMD=docker
55
DOCKER_PRE="NVIDIA_VISIBLE_DEVICES=all"
66
DOCKER_BUILD_ARGS=
77

8-
COMFYUI_NVIDIA_DOCKER_VERSION=20250713
8+
COMFYUI_NVIDIA_DOCKER_VERSION=20250817
99

1010
COMFYUI_CONTAINER_NAME=comfyui-nvidia-docker
1111

@@ -86,7 +86,9 @@ docker_rmi:
8686
# use the previous to last entry as the candidate: 12.8 is for 50xx series GPUs, not making it the default yet)
8787
#LATEST_ENTRY=$(shell echo ${DOCKER_ALL} | sed -e 's/ /\n/g' | tail -2 | head -1)
8888
# use the 2nd to last entry as the candidate
89-
LATEST_ENTRY=$(shell echo ${DOCKER_ALL} | sed -e 's/ /\n/g' | tail -3 | head -1)
89+
#LATEST_ENTRY=$(shell echo ${DOCKER_ALL} | sed -e 's/ /\n/g' | tail -3 | head -1)
90+
# use the 3nd to last entry as the candidate
91+
LATEST_ENTRY=$(shell echo ${DOCKER_ALL} | sed -e 's/ /\n/g' | tail -4 | head -1)
9092

9193
LATEST_CANDIDATE=$(shell echo ${COMFYUI_CONTAINER_NAME}:${LATEST_ENTRY})
9294

README.md

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ When using RTX 50xx GPUs:
2525
- you must use NVIDIA driver 570 (or above).
2626
- use the `ubuntu24_cuda12.8` container tag (or above).
2727

28+
When using GTX 10xx GPUs:
29+
- use the `ubuntu24_cuda12.6.3` container tag.
30+
- set `PREINSTALL_TORCH=true` to enable the automatic installation of a CUDA 12.6 version of PyTorch.
31+
- (recommended) set `USE_PIPUPGRADE=false` to disable the use of `pip3 --upgrade`.
32+
- (optional) set `DISABLE_UPGRADES=true` to disable any Python package upgrade when starting the container (also disables `USE_PIPUPGRADE`). Use Comfy Manager to upgrade components.
33+
- (optional) set `PREINSTALL_TORCH_CMD="pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126"` to install torch with the `cu126` index-url.
34+
2835
<h2>About "latest" tag</h2>
2936

3037
`latest` now points to the `ubuntu24_cuda12.6.3` tag (as announced in the `20250320` release)
@@ -85,6 +92,7 @@ If this version is incompatible with your container runtime, please see the list
8592
| ubuntu24_cuda12.6.3-latest | `latest` | `latest` as of `20250413` release |
8693
| ubuntu24_cuda12.8-latest | | minimum required for Blackwell (inc RTX 50xx) hardware (see "Blackwell support" section) |
8794
| ubuntu24_cuda12.9-latest | | |
95+
| ubutnu24_cuda13.0-latest | | Untested |
8896

8997
For more details on driver capabilities and how to update those, please see [Setting up NVIDIA docker & podman (Ubuntu 24.04)](https://www.gkr.one/blg-20240523-u24-nvidia-docker-podman).
9098

@@ -140,7 +148,8 @@ It is recommended that a container monitoring tool be available to watch the log
140148
- [5.4.5. USE\_SOCAT](#545-use_socat)
141149
- [5.4.6. FORCE\_CHOWN](#546-force_chown)
142150
- [5.4.7. USE\_PIPUPGRADE](#547-use_pipupgrade)
143-
- [5.4.8. PREINSTALL\_TORCH](#548-preinstall_torch)
151+
- [5.4.8. DISABLE\_UPGRADES](#548-disable_upgrades)
152+
- [5.4.9. PREINSTALL\_TORCH and PREINSTALL\_TORCH\_CMD](#549-preinstall_torch-and-preinstall_torch_cmd)
144153
- [5.5. ComfyUI Manager \& Security levels](#55-comfyui-manager--security-levels)
145154
- [5.6. Shell within the Docker image](#56-shell-within-the-docker-image)
146155
- [5.6.1. Alternate method](#561-alternate-method)
@@ -152,11 +161,12 @@ It is recommended that a container monitoring tool be available to watch the log
152161
- [5.7.4. run/pip\_cache and run/tmp](#574-runpip_cache-and-runtmp)
153162
- [5.7.5. Direct Cloud deployment: GPU Trader](#575-direct-cloud-deployment-gpu-trader)
154163
- [6. Troubleshooting](#6-troubleshooting)
155-
- [6.1. Virtual environment](#61-virtual-environment)
156-
- [6.2. run directory](#62-run-directory)
157-
- [6.3. using BASE\_DIRECTORY with an outdated ComfyUI](#63-using-base_directory-with-an-outdated-comfyui)
158-
- [6.3.1. using a specific ComfyUI version or SHA](#631-using-a-specific-comfyui-version-or-sha)
159-
- [6.3.2. Errors with ComfyUI WebUI -- re-installation method with models migration](#632-errors-with-comfyui-webui----re-installation-method-with-models-migration)
164+
- [6.1. Comfy crash](#61-comfy-crash)
165+
- [6.2. Virtual environment](#62-virtual-environment)
166+
- [6.3. run directory](#63-run-directory)
167+
- [6.4. using BASE\_DIRECTORY with an outdated ComfyUI](#64-using-base_directory-with-an-outdated-comfyui)
168+
- [6.4.1. using a specific ComfyUI version or SHA](#641-using-a-specific-comfyui-version-or-sha)
169+
- [6.4.2. Errors with ComfyUI WebUI -- re-installation method with models migration](#642-errors-with-comfyui-webui----re-installation-method-with-models-migration)
160170
- [7. Changelog](#7-changelog)
161171

162172
# 1. Preamble
@@ -611,22 +621,32 @@ When set, it will "force chown" every sub-folder in the `run` and `basedir` fold
611621

612622
### 5.4.7. USE_PIPUPGRADE
613623

614-
The `USE_PIPUPGRADE` environment variable is used to enable the use of `pip3 install --upgrade` to upgrade ComfyUI and other Python packages to the latest version during startup.
624+
The `USE_PIPUPGRADE` environment variable is used to enable the use of `pip3 install --upgrade` to upgrade ComfyUI and other Python packages to the latest version during startup. If not set, it will use `pip3 install` to install packages.
615625

616-
This option is enabled by default as with the sepratation of the UI from the Core ComfyUI code, it is possible to be off-synced with the latest version of the UI.
626+
This option is enabled by default as with the sepraation of the UI from the Core ComfyUI code, it is possible to be off-synced with the latest version of the UI.
617627

618628
It can be disabled by setting `USE_PIPUPGRADE=false`.
619629

620-
### 5.4.8. PREINSTALL_TORCH
630+
### 5.4.8. DISABLE_UPGRADES
631+
632+
The `DISABLE_UPGRADES` environment variable is used to disable upgrades when starting the container (also disables USE_PIPUPGRADE).
633+
634+
This option is disabled by default (set to `false`) as it is recommended to keep the UI up to date (since it was decoupled from the core code). To enable its features, set `DISABLE_UPGRADES=true`.
635+
636+
It is recommended to only use it on a fresh install of the container, as it will attempt to prevent Comfy and other Python packages from being upgraded outside of the WebUI. Any package update will have to be performed through the WebUI (ComfyUI Manager).
637+
638+
### 5.4.9. PREINSTALL_TORCH and PREINSTALL_TORCH_CMD
621639

622640
The `PREINSTALL_TORCH` environment variable will attempt to automatically install/upgrade `torch` after the virtual environment is created.
623641

624642
It will also check the version of CUDA supported by the container such that for CUDA 12.8, it will install `torch` with the `cu128` index-url.
625643

626-
This should prevent the need to use the `PyTorch2.7-CUDA12.8.sh` script.
627-
628644
This option is enabled by default. It can be disabled by setting `PREINSTALL_TORCH=false`.
629645

646+
The `PREINSTALL_TORCH_CMD` environment variable can be used to override the torch installation command with the one specified in the variable. For example for GTX 1080, try to use `PREINSTALL_TORCH_CMD="pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126"`. It is likely also recommended to not set `USE_PIPUPGRADE=false` in this case.
647+
648+
Please note that the `PREINSTALL_TORCH_CMD` variable is not added to the Unraid template, and must be manually added if used.
649+
630650
## 5.5. ComfyUI Manager & Security levels
631651

632652
[ComfyUI Manager](https://github.com/ltdrdata/ComfyUI-Manager/) is installed and available in the container.
@@ -863,18 +883,25 @@ If you are curious and want to learn more, check [this video](https://supercut.a
863883

864884
# 6. Troubleshooting
865885

866-
## 6.1. Virtual environment
886+
## 6.1. Comfy crash
887+
888+
It is possible that despite the container starting and setting itself up correctly, ComfyUI will crash.
889+
You will recognize this in the Docker log as `!! ERROR: ComfyUI failed or exited with an error`.
890+
The log might contain the reason for the crash, but you can also look up the ComfyUI logs in the container to get more details. Those are in `basedir/user/*.log`.
891+
If Comfy crashes after it succesfully performs its internal checks (starts (`Starting server`) it is likely a Comfy/custom node error and not related to the container itself.
892+
893+
## 6.2. Virtual environment
867894

868895
The `venv` in the "run" directory contains all the Python packages the tool requires.
869896
In case of an issue, it is recommended that you terminate the container, delete (or rename) the `venv` directory, and restart the container.
870897
The virtual environment will be recreated; any `custom_scripts` should re-install their requirements; please see the "Fixing Failed Custom Nodes" section for additional details.
871898

872-
## 6.2. run directory
899+
## 6.3. run directory
873900

874901
It is also possible to rename the entire "run" directory to get a clean installation of ComfyUI and its virtual environment. This method is preferred, compared to deleting the "run" directory—as it will allow us to copy the content of the various downloaded `ComfyUI/models`, `ComfyUI/custom_nodes`, generated `ComfyUI/outputs`, `ComfyUI/user`, added `ComfyUI/inputs`, and other folders present within the old "run" directory.
875902
If using the `BASE_DIRECTORY` environment variable, please note that some of that `run` directory content will be moved to the `BASE_DIRECTORY` specified.
876903

877-
## 6.3. using BASE_DIRECTORY with an outdated ComfyUI
904+
## 6.4. using BASE_DIRECTORY with an outdated ComfyUI
878905

879906
If using the `BASE_DIRECTORY` option and the program exit saying the `--base-directory` option does not exist, this is due to an outdated ComfyUI installation. A possible solution is to disable the option, restart the container and use the ComfyUI-Manager to update ComfyUI. Another option is manually update the code: `cd run/ComfyUI; git pull`
880907
In some case, it is easier to create a simple `user_script.bash` to perform those steps; particularly on Unraid.
@@ -893,7 +920,7 @@ Make sure to change file ownership to the user with the `WANTED_UID` and `WANTED
893920

894921
**After the process complete, you should be presented with the WebUI. Make to delete or rename the script to avoid upgrading ComfyUI at start time, and use ComfyUI Manager instead.**
895922

896-
### 6.3.1. using a specific ComfyUI version or SHA
923+
### 6.4.1. using a specific ComfyUI version or SHA
897924

898925
Following the conversation in https://github.com/mmartial/ComfyUI-Nvidia-Docker/issues/32
899926
Use a `user_script.bash` to install a specific version of ComfyUI
@@ -918,7 +945,7 @@ Make sure to change file ownership to the user with the `WANTED_UID` and `WANTED
918945

919946
**After the process complete, you should be presented with the WebUI. Make sure to delete or rename the script to avoid it being run again.**
920947

921-
### 6.3.2. Errors with ComfyUI WebUI -- re-installation method with models migration
948+
### 6.4.2. Errors with ComfyUI WebUI -- re-installation method with models migration
922949

923950
Sometimes a `custom_nodes` might cause the WebUI to fail to start, or error out with a message (ex: `Loading aborted due to error reloading workflow data`). In such cases, it is recommended to start from a brand new `run` and `basedir` folders, since `run` contains ComfyUI and the `venv` (virtual environment) that is required to run the WebUI, and `basedir` contains the `models` and `custom_nodes`. Because we would prefer to not have to redownload the models, the following describes a method to do so, such that you will be able to copy the content of the `models` folder from a `_old ``run` and `basedir` folders to the new ones.
924951

@@ -938,6 +965,7 @@ Once you are confident that you have migrated content from the old container's f
938965

939966
# 7. Changelog
940967

968+
- 20250817: Added automatic PyTorch selection for `PREINSTALL_TORCH` environment variable based on CUDA version + added `DISABLE_UPGRADES` and `PREINSTALL_TORCH_CMD` environment variables.
941969
- 20250713: Attempting to automatically select the `cu128` index-url when CUDA 12.8 (or above) is detected when using the `PREINSTALL_TORCH` environment variable (enabled by default).
942970
- 20250607: Added `USE_PIPUPGRADE` and `USE_SOCAT` environment variables + added CUDA 12.9 build.
943971
- 20250503: Future proof [extras/PyTorch2.7-CUDA12.8.sh](./extras/PyTorch2.7-CUDA12.8.sh) to use `torch>=2.7` instead of `torch==2.7.0` + added `run/pip_cache` and `run/tmp` folders support
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM nvidia/cuda:13.0.0-cudnn-devel-ubuntu24.04
2+
ARG BASE_DOCKER_FROM=nvidia/cuda:13.0.0-cudnn-devel-ubuntu24.04

config.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export ENV_OBFUSCATE_PART="TOKEN API KEY"
2929
# default is true, value must set to "false" to disable
3030
#export USE_PIPUPGRADE="false"
3131

32+
# Disable upgrades: set to "true" to disable upgrades (also disables USE_PIPUPGRADE)
33+
#export DISABLE_UPGRADES="true"
34+
3235
# Base directory
3336
#export BASE_DIRECTORY="/basedir"
3437

@@ -42,6 +45,8 @@ export ENV_OBFUSCATE_PART="TOKEN API KEY"
4245

4346
# PREINSTALL_TORCH: preinstall torch: default is true, set to "false" to disable
4447
#export PREINSTALL_TORCH="false"
48+
# PREINSTALL_TORCH_CMD: when PREINSTALL_TORCH is set to true, will use the command specified in this variable to install torch
49+
#export PREINSTALL_TORCH_CMD="pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126"
4550

4651
## NVIDIA specific adds
4752
#export NVIDIA_VISIBLE_DEVICES=all

0 commit comments

Comments
 (0)