Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions configs/build_targets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# build_targets.yaml
# Maps node names to their build scripts and config files.
# Add new nodes as needed.

streamdiffusion:
script: /workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/scripts/build_tensorrt_engines.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is neat, does it support arguments for other scripts like build_trt.py?

We will need to cover the case when an image is built using nodes.yaml, and entrypoint.sh is ran with --build-engines, Just need a basic check to not attempt build if the custom nodes folder or script doesn't exist.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can finalize that in #488 though, will go ahead and merge this one

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can cherry-pick this one to guard the other engine builds or refactor to your script

979fcef

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is neat, does it support arguments for other scripts like build_trt.py?

We will need to cover the case when an image is built using nodes.yaml, and entrypoint.sh is ran with --build-engines, Just need a basic check to not attempt build if the custom nodes folder or script doesn't exist.

The [entrypoint.sh]already checks for the existence of build_targets.yaml, the required folder, and the script before attempting StreamDiffusion engine builds (see lines 142–144 and the Python block around line 150+). It skips the build if any are missing, just like the new logic for other nodes which you referred for cherry picking.

configs:
- /workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/configs/sd15_singlecontrol.yaml
- /workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/configs/sdturbo_multicontrol.yaml
folder: /workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/scripts

# Example for another node:
# depthanything:
# script: /workspace/ComfyUI/custom_nodes/ComfyUI-DepthAnything/scripts/build_depthanything_engine.py
# configs:
# - /workspace/ComfyUI/custom_nodes/ComfyUI-DepthAnything/configs/depthanything.yaml
# folder: /workspace/ComfyUI/custom_nodes/ComfyUI-DepthAnything/scripts
3 changes: 3 additions & 0 deletions docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ RUN apt-get remove --purge -y libcudnn9-cuda-12 libcudnn9-dev-cuda-12 || true &&
# to ensure numpy 2.0 is not installed automatically by another package
RUN conda run -n comfystream --no-capture-output pip install "numpy<2.0.0"

# Ensure modelopt pulls a compatible transformers version for HF support
RUN conda run -n comfystream --no-capture-output pip install 'nvidia-modelopt[hf]'

# Install cuDNN 9.8 via conda to match base system version
# Caution: Mixed versions installed in environment (system/python) can cause CUDNN_STATUS_SUBLIBRARY_VERSION_MISMATCH errors
RUN conda install -n comfystream -y -c nvidia -c conda-forge cudnn=9.8 cuda-version=12.8
Expand Down
47 changes: 36 additions & 11 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,40 @@ if [ "$1" = "--build-engines" ]; then
echo "Engines for FasterLivePortrait already exists, skipping..."
fi

# Build Engine for StreamDiffusion using trt script and config
ENGINE_SCRIPT="/workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/scripts/build_tensorrt_engines.py"
CONFIGS=(
"/workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/configs/sd15_singlecontrol.yaml"
"/workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/configs/sdturbo_multicontrol.yaml"
)
cd /workspace/ComfyUI/custom_nodes/ComfyUI-StreamDiffusion/scripts
for ENGINE_CONFIG in "${CONFIGS[@]}"; do
echo "Building StreamDiffusion TensorRT engines using config: $ENGINE_CONFIG"
python "$ENGINE_SCRIPT" --config "$ENGINE_CONFIG"
done
# Build Engine for StreamDiffusion using build_targets.yaml (dynamic, robust)
BUILD_TARGETS_FILE="/workspace/comfystream/configs/build_targets.yaml"
if [ ! -f "$BUILD_TARGETS_FILE" ]; then
echo "build_targets.yaml not found at $BUILD_TARGETS_FILE. Skipping StreamDiffusion engine builds."
else
python3 - <<'EOF'
import os
import yaml
import subprocess

with open("/workspace/comfystream/configs/build_targets.yaml", "r") as f:
targets = yaml.safe_load(f)

info = targets.get("streamdiffusion")
if info:
folder = info.get("folder")
script = info.get("script")
configs = info.get("configs", [])
if folder and os.path.isdir(folder) and script and os.path.isfile(script):
for config in configs:
if os.path.isfile(config):
print(f"Building streamdiffusion engine with config: {config}")
try:
subprocess.run(["python", script, "--config", config], check=True)
except subprocess.CalledProcessError as e:
print(f"Error building engine for config {config}: {e}")
else:
print(f"Warning: Config {config} for streamdiffusion not found, skipping...")
else:
print(f"Skipping streamdiffusion: required folder or script not found.")
else:
print("streamdiffusion not found in build_targets.yaml, skipping...")
EOF
fi
shift
fi

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



exec "$@"
5 changes: 3 additions & 2 deletions src/comfystream/scripts/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ tensorrt==10.12.0.36
tensorrt-cu12==10.12.0.36
xformers==0.0.32.post2
onnx==1.18.0
onnxruntime==1.22.0
onnxruntime-gpu==1.22.0
onnxruntime>=1.22.0
onnxruntime-gpu>=1.22.0
onnxmltools==1.14.0
cuda-python<13.0
huggingface-hub>=0.20.0
mediapipe==0.10.21