Skip to content

Commit 9ff4b39

Browse files
Support for super-resolution node with opencv-cuda (#65)
* added built cv2 from github * add opencv-cuda install to dockerfile --------- Co-authored-by: Elite <[email protected]>
1 parent d7c096f commit 9ff4b39

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ launch.json
2222
nodes/web/static/*
2323
.cursor/
2424
!nodes/web/static/.gitkeep
25+
26+
# opencv files
27+
opencv

docker/Dockerfile.base

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ RUN conda run -n comfystream --no-capture-output --cwd /workspace/comfystream py
5858
# Install additional dependencies
5959
RUN conda run -n comfystream --no-capture-output pip install --upgrade tensorrt-cu12-bindings tensorrt-cu12-libs --root-user-action=ignore
6060

61+
# Setup opencv with CUDA support
62+
RUN conda run -n comfystream --no-capture-output bash /workspace/comfystream/docker/entrypoint.sh --opencv-cuda
63+
6164
# Configure no environment activation by default
6265
RUN conda config --set auto_activate_base false && \
6366
conda init bash

docker/entrypoint.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ show_help() {
2323
echo "Options:"
2424
echo " --download-models Download default models"
2525
echo " --build-engines Build TensorRT engines for default models"
26+
echo " --opencv-cuda Setup OpenCV with CUDA support"
2627
echo " --server Start the Comfystream server, UI and ComfyUI"
2728
echo " --help Show this help message"
2829
echo ""
@@ -70,6 +71,55 @@ if [ "$1" = "--build-engines" ]; then
7071
shift
7172
fi
7273

74+
if [ "$1" = "--opencv-cuda" ]; then
75+
cd /workspace/comfystream
76+
conda activate comfystream
77+
78+
# Check if OpenCV CUDA build already exists
79+
if [ ! -f "/workspace/comfystream/opencv-cuda-release.tar.gz" ]; then
80+
# Download and extract OpenCV CUDA build
81+
DOWNLOAD_NAME="opencv-cuda-release.tar.gz"
82+
wget -q -O "$DOWNLOAD_NAME" https://github.com/JJassonn69/ComfyUI-Stream-Pack/releases/download/v1.0/opencv-cuda-release.tar.gz
83+
tar -xzf "$DOWNLOAD_NAME" -C /workspace/comfystream/
84+
rm "$DOWNLOAD_NAME"
85+
else
86+
echo "OpenCV CUDA build already exists, skipping download."
87+
fi
88+
89+
# Install required libraries
90+
apt-get update && apt-get install -y \
91+
libgflags-dev \
92+
libgoogle-glog-dev \
93+
libjpeg-dev \
94+
libavcodec-dev \
95+
libavformat-dev \
96+
libavutil-dev \
97+
libswscale-dev
98+
99+
# Remove existing cv2 package
100+
SITE_PACKAGES_DIR="/workspace/miniconda3/envs/comfystream/lib/python3.11/site-packages"
101+
rm -rf "${SITE_PACKAGES_DIR}/cv2"*
102+
103+
# Copy new cv2 package
104+
cp -r /workspace/comfystream/cv2 "${SITE_PACKAGES_DIR}/"
105+
106+
# Handle library dependencies
107+
CONDA_ENV_LIB="/workspace/miniconda3/envs/comfystream/lib"
108+
109+
# Remove existing libstdc++ and copy system one
110+
rm -f "${CONDA_ENV_LIB}/libstdc++.so"*
111+
cp /usr/lib/x86_64-linux-gnu/libstdc++.so* "${CONDA_ENV_LIB}/"
112+
113+
# Copy OpenCV libraries
114+
cp /workspace/comfystream/opencv/build/lib/libopencv_* /usr/lib/x86_64-linux-gnu/
115+
116+
# remove the opencv-contrib and cv2 folders
117+
rm -rf /workspace/comfystream/opencv_contrib
118+
rm -rf /workspace/comfystream/cv2
119+
120+
echo "OpenCV CUDA installation completed"
121+
shift
122+
fi
73123

74124
if [ "$1" = "--server" ]; then
75125
/usr/bin/supervisord -c /etc/supervisor/supervisord.conf

0 commit comments

Comments
 (0)