Skip to content

Commit b0c4727

Browse files
authored
Fix:streamdiffusion custom node build, dependencies conflict issue (#579)
* feat:Add build_targets.yaml and dynamic StreamDiffusion engine build logic to entrypoint.sh
1 parent b00eee8 commit b0c4727

File tree

4 files changed

+59
-13
lines changed

4 files changed

+59
-13
lines changed

configs/build_targets.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# build_targets.yaml
2+
# Maps node names to their build scripts and config files.
3+
# Add new nodes as needed.
4+
5+
streamdiffusion:
6+
script: /workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/scripts/build_tensorrt_engines.py
7+
configs:
8+
- /workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/configs/sd15_singlecontrol.yaml
9+
- /workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/configs/sdturbo_multicontrol.yaml
10+
folder: /workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/scripts
11+
12+
# Example for another node:
13+
# depthanything:
14+
# script: /workspace/ComfyUI/custom_nodes/ComfyUI-DepthAnything/scripts/build_depthanything_engine.py
15+
# configs:
16+
# - /workspace/ComfyUI/custom_nodes/ComfyUI-DepthAnything/configs/depthanything.yaml
17+
# folder: /workspace/ComfyUI/custom_nodes/ComfyUI-DepthAnything/scripts

docker/Dockerfile.base

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ RUN apt-get remove --purge -y libcudnn9-cuda-12 libcudnn9-dev-cuda-12 || true &&
5858
# to ensure numpy 2.0 is not installed automatically by another package
5959
RUN conda run -n comfystream --no-capture-output pip install "numpy<2.0.0"
6060

61+
# Ensure modelopt pulls a compatible transformers version for HF support
62+
RUN conda run -n comfystream --no-capture-output pip install 'nvidia-modelopt[hf]'
63+
6164
# Install cuDNN 9.8 via conda to match base system version
6265
# Caution: Mixed versions installed in environment (system/python) can cause CUDNN_STATUS_SUBLIBRARY_VERSION_MISMATCH errors
6366
RUN conda install -n comfystream -y -c nvidia -c conda-forge cudnn=9.8 cuda-version=12.8

docker/entrypoint.sh

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,40 @@ if [ "$1" = "--build-engines" ]; then
138138
echo "Engines for FasterLivePortrait already exists, skipping..."
139139
fi
140140

141-
# Build Engine for StreamDiffusion using trt script and config
142-
ENGINE_SCRIPT="/workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/scripts/build_tensorrt_engines.py"
143-
CONFIGS=(
144-
"/workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/configs/sd15_singlecontrol.yaml"
145-
"/workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/configs/sdturbo_multicontrol.yaml"
146-
)
147-
cd /workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/scripts
148-
for ENGINE_CONFIG in "${CONFIGS[@]}"; do
149-
echo "Building StreamDiffusion TensorRT engines using config: $ENGINE_CONFIG"
150-
python "$ENGINE_SCRIPT" --config "$ENGINE_CONFIG"
151-
done
141+
# Build Engine for StreamDiffusion using build_targets.yaml (dynamic, robust)
142+
BUILD_TARGETS_FILE="/workspace/comfystream/configs/build_targets.yaml"
143+
if [ ! -f "$BUILD_TARGETS_FILE" ]; then
144+
echo "build_targets.yaml not found at $BUILD_TARGETS_FILE. Skipping StreamDiffusion engine builds."
145+
else
146+
python3 - <<'EOF'
147+
import os
148+
import yaml
149+
import subprocess
150+
151+
with open("/workspace/comfystream/configs/build_targets.yaml", "r") as f:
152+
targets = yaml.safe_load(f)
153+
154+
info = targets.get("streamdiffusion")
155+
if info:
156+
folder = info.get("folder")
157+
script = info.get("script")
158+
configs = info.get("configs", [])
159+
if folder and os.path.isdir(folder) and script and os.path.isfile(script):
160+
for config in configs:
161+
if os.path.isfile(config):
162+
print(f"Building streamdiffusion engine with config: {config}")
163+
try:
164+
subprocess.run(["python", script, "--config", config], check=True)
165+
except subprocess.CalledProcessError as e:
166+
print(f"Error building engine for config {config}: {e}")
167+
else:
168+
print(f"Warning: Config {config} for streamdiffusion not found, skipping...")
169+
else:
170+
print(f"Skipping streamdiffusion: required folder or script not found.")
171+
else:
172+
print("streamdiffusion not found in build_targets.yaml, skipping...")
173+
EOF
174+
fi
152175
shift
153176
fi
154177

@@ -218,4 +241,6 @@ if [ "$START_COMFYUI" = true ] || [ "$START_API" = true ] || [ "$START_UI" = tru
218241
tail -f /var/log/supervisord.log
219242
fi
220243

244+
245+
221246
exec "$@"

src/comfystream/scripts/constraints.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ tensorrt==10.12.0.36
88
tensorrt-cu12==10.12.0.36
99
xformers==0.0.32.post2
1010
onnx==1.18.0
11-
onnxruntime==1.22.0
12-
onnxruntime-gpu==1.22.0
11+
onnxruntime>=1.22.0
12+
onnxruntime-gpu>=1.22.0
1313
onnxmltools==1.14.0
1414
cuda-python<13.0
1515
huggingface-hub>=0.20.0
16+
mediapipe==0.10.21

0 commit comments

Comments
 (0)