Skip to content

Commit a2c204a

Browse files
committed
fix(DR-1170): fix ComfyUI startup crash (server not reachable)
ComfyUI is installed by comfy-cli into its own /comfyui/.venv, but start.sh launches it with /opt/venv's python. The launch venv was missing ComfyUI's runtime deps (sqlalchemy from the new asset DB, etc.), so ComfyUI crashed at startup — surfacing as the misleading 'ComfyUI server not reachable' error. Nothing in this repo changed; the breakage rode in via COMFYUI_VERSION=latest. - Mirror ComfyUI's full dependency set (core + custom-node requirements) into /opt/venv so the launch venv is complete. - Pin transformers<5 / huggingface-hub<1 (both unbounded upstream). - Add a build-time smoke test (main.py --quick-test-for-ci --cpu) so a startup-breaking dep fails the build instead of a live worker. - start.sh pre-flight now launches a real kernel + prints sm/torch/cuda, so a GPU/kernel mismatch fails loudly at boot instead of as 'not reachable'. Base-image stays cu126; NGC base migration is a separate branch/PR.
1 parent d2a5572 commit a2c204a

2 files changed

Lines changed: 38 additions & 4 deletions

File tree

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,31 @@ RUN if [ "$ENABLE_PYTORCH_UPGRADE" = "true" ]; then \
6262
uv pip install --force-reinstall torch torchvision torchaudio --index-url ${PYTORCH_INDEX_URL}; \
6363
fi
6464

65+
# comfy-cli installs ComfyUI into its own workspace venv (/comfyui/.venv), but
66+
# start.sh launches ComfyUI with /opt/venv's python. That mismatch leaves the
67+
# launch venv missing ComfyUI's runtime deps (e.g. sqlalchemy, pulled in by
68+
# ComfyUI's asset DB), so ComfyUI crashes at startup and surfaces as the
69+
# misleading "ComfyUI server (127.0.0.1:8188) not reachable" error. Mirror
70+
# ComfyUI's full dependency set (core + custom nodes) into /opt/venv so the
71+
# launch venv is complete. Root-cause fix for DR-1170.
72+
RUN uv pip install -r /comfyui/requirements.txt \
73+
&& for r in /comfyui/custom_nodes/*/requirements.txt; do \
74+
[ -f "$r" ] && uv pip install -r "$r" || true; \
75+
done
76+
77+
# Pin ComfyUI's unbounded ML dependencies to their last known-good majors.
78+
# ComfyUI declares transformers>=4.50.3 and huggingface-hub with NO upper bound,
79+
# so a fresh install can pull transformers 5.x / huggingface-hub 1.x whose
80+
# breaking API changes also crash ComfyUI at startup. Keep them on the last
81+
# known-good major.
82+
RUN uv pip install "transformers>=4.50.3,<5" "huggingface-hub<1.0"
83+
84+
# Build-time smoke test: actually start ComfyUI (imports the full node graph) so
85+
# a startup-breaking dependency is caught HERE, at build time, instead of as a
86+
# runtime "server not reachable" failure on a live worker. Runs on CPU — no GPU
87+
# needed to exercise the import graph.
88+
RUN cd /comfyui && timeout 300 python main.py --quick-test-for-ci --cpu
89+
6590
# Change working directory to ComfyUI
6691
WORKDIR /comfyui
6792

src/start.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,24 @@ import torch
3434
try:
3535
torch.cuda.init()
3636
name = torch.cuda.get_device_name(0)
37-
print(f'OK: {name}')
37+
cap = torch.cuda.get_device_capability(0)
38+
# Launch a real kernel. The driver-only calls above succeed even when this
39+
# PyTorch build has no compiled kernels for the GPU architecture (e.g. an
40+
# older torch on a newer GPU). Without this, the worker boots, ComfyUI dies
41+
# on the first GPU op, and it surfaces as the misleading 'server not
42+
# reachable' error instead of a clear cause here.
43+
_ = (torch.zeros(8, device='cuda') + 1).sum().item()
44+
torch.cuda.synchronize()
45+
print(f'OK: {name} (sm_{cap[0]}{cap[1]}), torch {torch.__version__}, cuda {torch.version.cuda}')
3846
except Exception as e:
3947
print(f'FAIL: {e}')
4048
exit(1)
4149
" 2>&1); then
42-
echo "worker-comfyui: GPU is not available. PyTorch CUDA init failed:"
50+
echo "worker-comfyui: GPU is not available or incompatible with this PyTorch build:"
4351
echo "worker-comfyui: $GPU_CHECK"
44-
echo "worker-comfyui: This usually means the GPU on this machine is not properly initialized."
45-
echo "worker-comfyui: Please contact RunPod support and report this machine."
52+
echo "worker-comfyui: A 'no kernel image is available' error means this torch build"
53+
echo "worker-comfyui: lacks kernels for this GPU. Otherwise the GPU may not be"
54+
echo "worker-comfyui: properly initialized — please contact RunPod support."
4655
exit 1
4756
fi
4857
echo "worker-comfyui: GPU available — $GPU_CHECK"

0 commit comments

Comments
 (0)