@@ -86,6 +86,10 @@ DEPTH_ANYTHING_DIR="${TENSORRT_DIR}/depth-anything"
8686DEPTH_ANYTHING_ENGINE=" depth_anything_vitl14-fp16.engine"
8787DEPTH_ANYTHING_ENGINE_LARGE=" depth_anything_v2_vitl-fp16.engine"
8888FASTERLIVEPORTRAIT_DIR=" /workspace/ComfyUI/models/liveportrait_onnx"
89+ DEPTH_ANYTHING_NODE_DIR=" /workspace/ComfyUI/custom_nodes/ComfyUI-Depth-Anything-Tensorrt"
90+ DEPTH_ANYTHING_EXPORT_SCRIPT=" ${DEPTH_ANYTHING_NODE_DIR} /export_trt.py"
91+ FASTERLIVEPORTRAIT_NODE_DIR=" /workspace/ComfyUI/custom_nodes/ComfyUI-FasterLivePortrait"
92+ FASTERLIVEPORTRAIT_BUILD_SCRIPT=" ${FASTERLIVEPORTRAIT_NODE_DIR} /scripts/build_fasterliveportrait_trt.sh"
8993
9094if [ " $1 " = " --build-engines" ]; then
9195 cd /workspace/comfystream
@@ -111,33 +115,42 @@ if [ "$1" = "--build-engines" ]; then
111115 --max-width 448 \
112116 --max-height 704
113117
114- # Build Engine for Depth Anything V2
115- if [ ! -f " $DEPTH_ANYTHING_DIR /$DEPTH_ANYTHING_ENGINE " ]; then
116- if [ ! -d " $DEPTH_ANYTHING_DIR " ]; then
117- mkdir -p " $DEPTH_ANYTHING_DIR "
118+ # Build Engine for Depth Anything V2 (guarded by custom node)
119+ if [ -d " $DEPTH_ANYTHING_NODE_DIR " ] && [ -f " $DEPTH_ANYTHING_EXPORT_SCRIPT " ]; then
120+ if [ ! -f " $DEPTH_ANYTHING_DIR /$DEPTH_ANYTHING_ENGINE " ]; then
121+ if [ ! -d " $DEPTH_ANYTHING_DIR " ]; then
122+ mkdir -p " $DEPTH_ANYTHING_DIR "
123+ fi
124+ cd " $DEPTH_ANYTHING_DIR "
125+ python " $DEPTH_ANYTHING_EXPORT_SCRIPT "
126+ else
127+ echo " Engine for DepthAnything2 already exists at ${DEPTH_ANYTHING_DIR} /${DEPTH_ANYTHING_ENGINE} , skipping..."
118128 fi
119- cd " $DEPTH_ANYTHING_DIR "
120- python /workspace/ComfyUI/custom_nodes/ComfyUI-Depth-Anything-Tensorrt/export_trt.py
121- else
122- echo " Engine for DepthAnything2 already exists at ${DEPTH_ANYTHING_DIR} /${DEPTH_ANYTHING_ENGINE} , skipping..."
123- fi
124129
125- # Build Engine for Depth Anything2 (large)
126- if [ ! -f " $DEPTH_ANYTHING_DIR /$DEPTH_ANYTHING_ENGINE_LARGE " ]; then
127- cd " $DEPTH_ANYTHING_DIR "
128- python /workspace/ComfyUI/custom_nodes/ComfyUI-Depth-Anything-Tensorrt/export_trt.py --trt-path " ${DEPTH_ANYTHING_DIR} /${DEPTH_ANYTHING_ENGINE_LARGE} " --onnx-path " ${DEPTH_ANYTHING_DIR} /depth_anything_v2_vitl.onnx"
130+ # Build Engine for Depth Anything2 (large)
131+ if [ ! -f " $DEPTH_ANYTHING_DIR /$DEPTH_ANYTHING_ENGINE_LARGE " ]; then
132+ cd " $DEPTH_ANYTHING_DIR "
133+ python " $DEPTH_ANYTHING_EXPORT_SCRIPT " --trt-path " ${DEPTH_ANYTHING_DIR} /${DEPTH_ANYTHING_ENGINE_LARGE} " --onnx-path " ${DEPTH_ANYTHING_DIR} /depth_anything_v2_vitl.onnx"
134+ else
135+ echo " Engine for DepthAnything2 (large) already exists at ${DEPTH_ANYTHING_DIR} /${DEPTH_ANYTHING_ENGINE_LARGE} , skipping..."
136+ fi
129137 else
130- echo " Engine for DepthAnything2 (large) already exists at ${DEPTH_ANYTHING_DIR} / ${DEPTH_ANYTHING_ENGINE_LARGE} , skipping.. ."
138+ echo " DepthAnything custom node not found at ${DEPTH_ANYTHING_NODE_DIR} , skipping engine build ."
131139 fi
132140
133- # Build Engines for FasterLivePortrait
134- if [ ! -f " $FASTERLIVEPORTRAIT_DIR /warping_spade-fix.trt" ]; then
135- cd " $FASTERLIVEPORTRAIT_DIR "
136- bash /workspace/ComfyUI/custom_nodes/ComfyUI-FasterLivePortrait/scripts/build_fasterliveportrait_trt.sh " ${FASTERLIVEPORTRAIT_DIR} " " ${FASTERLIVEPORTRAIT_DIR} " " ${FASTERLIVEPORTRAIT_DIR} "
141+ # Build Engines for FasterLivePortrait (guarded by custom node)
142+ if [ -d " $FASTERLIVEPORTRAIT_NODE_DIR " ] && [ -f " $FASTERLIVEPORTRAIT_BUILD_SCRIPT " ]; then
143+ if [ ! -f " $FASTERLIVEPORTRAIT_DIR /warping_spade-fix.trt" ]; then
144+ cd " $FASTERLIVEPORTRAIT_DIR "
145+ bash " $FASTERLIVEPORTRAIT_BUILD_SCRIPT " " ${FASTERLIVEPORTRAIT_DIR} " " ${FASTERLIVEPORTRAIT_DIR} " " ${FASTERLIVEPORTRAIT_DIR} "
146+ else
147+ echo " Engines for FasterLivePortrait already exists, skipping..."
148+ fi
137149 else
138- echo " Engines for FasterLivePortrait already exists , skipping.. ."
150+ echo " ComfyUI-FasterLivePortrait custom node not found at ${FASTERLIVEPORTRAIT_NODE_DIR} , skipping engine build ."
139151 fi
140152
153+
141154 # Build Engine for StreamDiffusion using build_targets.yaml (dynamic, robust)
142155 BUILD_TARGETS_FILE=" /workspace/comfystream/configs/build_targets.yaml"
143156 if [ ! -f " $BUILD_TARGETS_FILE " ]; then
178191if [ " $1 " = " --opencv-cuda" ]; then
179192 cd /workspace/comfystream
180193 conda activate comfystream
181-
194+
182195 # Check if OpenCV CUDA build already exists
183196 if [ ! -f " /workspace/comfystream/opencv-cuda-release.tar.gz" ]; then
184197 # Download and extract OpenCV CUDA build
@@ -200,7 +213,7 @@ if [ "$1" = "--opencv-cuda" ]; then
200213
201214 # Handle library dependencies
202215 CONDA_ENV_LIB=" /workspace/miniconda3/envs/comfystream/lib"
203-
216+
204217 # Remove existing libstdc++ and copy system one
205218 rm -f " ${CONDA_ENV_LIB} /libstdc++.so" *
206219 cp /usr/lib/x86_64-linux-gnu/libstdc++.so* " ${CONDA_ENV_LIB} /"
@@ -223,20 +236,20 @@ if [ "$START_COMFYUI" = true ] || [ "$START_API" = true ] || [ "$START_UI" = tru
223236 # Start supervisord in background
224237 /usr/bin/supervisord -c /etc/supervisor/supervisord.conf &
225238 sleep 2 # Give supervisord time to start
226-
239+
227240 # Start requested services
228241 if [ " $START_COMFYUI " = true ]; then
229242 supervisorctl -c /etc/supervisor/supervisord.conf start comfyui
230243 fi
231-
244+
232245 if [ " $START_API " = true ]; then
233246 supervisorctl -c /etc/supervisor/supervisord.conf start comfystream-api
234247 fi
235-
248+
236249 if [ " $START_UI " = true ]; then
237250 supervisorctl -c /etc/supervisor/supervisord.conf start comfystream-ui
238251 fi
239-
252+
240253 # Keep the script running
241254 tail -f /var/log/supervisord.log
242255fi
0 commit comments