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
105 changes: 59 additions & 46 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,28 @@ RUN apt-get update && \
gfortran && \
# Install necessary CUDA packages
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb -o /tmp/cuda-keyring.deb && \
dpkg -i /tmp/cuda-keyring.deb && rm /tmp/cuda-keyring.deb && \
apt-get update && \
dpkg -i /tmp/cuda-keyring.deb && rm /tmp/cuda-keyring.deb

ARG CUDA_MAJOR_VERSION=12
ARG CUDA_MINOR_VERSION=8

# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install -y -q --no-install-recommends \
cuda-toolkit-12-4 \
libcudnn9-dev-cuda-12 \
libnpp-dev-12-4 \
&& \
cuda-toolkit-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
libcudnn9-dev-cuda-${CUDA_MAJOR_VERSION} && \
rm -rf /var/lib/apt/lists/* && apt-get clean

RUN python3 -m venv ${VIRTUAL_ENV} && \
${VIRTUAL_ENV}/bin/pip install --no-cache-dir \
"pip==26.0.1" \
"pip==26.2.1" \
"torch==2.10.0" \
"torchvision==0.25.0" \
"numpy==1.26.0"
"numpy==1.26.4"

# Ensure paths capture the version dynamically
ENV PATH="/usr/local/cuda/bin:${PATH}"
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"

# OPENCV W/ CUDA SUPPORT
ENV PYTHON_VERSION=3.10
Expand All @@ -74,6 +81,8 @@ RUN git clone --branch ${OPENCV_VERSION} --depth 1 https://github.com/opencv/ope
WORKDIR ${DEPENDENCY_DIR}/opencv/build
RUN ln -s /usr/include/x86_64-linux-gnu/cudnn*.h /usr/local/cuda/include/ && \
ln -s /usr/lib/x86_64-linux-gnu/libcudnn*.so* /usr/local/cuda/lib64/

# hadolint ignore=SC2046
RUN cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX="${VIRTUAL_ENV}" \
-D OPENCV_EXTRA_MODULES_PATH="${DEPENDENCY_DIR}/opencv_contrib/modules" \
Expand All @@ -84,7 +93,7 @@ RUN cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D OPENCV_DNN_CUDA=ON \
-D CUDA_ARCH_BIN=70,75,80,86,89,90 \
-D CUDA_ARCH_BIN=80,86,89,90 \
-D CUDA_FAST_MATH=ON \
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
-D CUDNN_INCLUDE_DIR=/usr/include/x86_64-linux-gnu \
Expand All @@ -93,8 +102,8 @@ RUN cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_opencv_cudaarithm=ON \
-D BUILD_opencv_cudafilters=ON \
-D BUILD_opencv_cudacodec=ON \
-D WITH_NVCUVID=ON \
-D WITH_NVCUVENC=ON \
-D WITH_NVCUVID=OFF \
-D WITH_NVCUVENC=OFF \
-D WITH_VAAPI=ON \
-D WITH_FFMPEG=ON \
-D BUILD_opencv_python3=ON \
Expand All @@ -108,74 +117,78 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN mkdir -p /tmp/cv2_deps && \
PY_CV2_SO=$(find "${VIRTUAL_ENV}" -name "cv2*.so" | head -n 1) && \
ldd "${PY_CV2_SO}" | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /tmp/cv2_deps/ && \
cp -v /usr/local/cuda/lib64/libnpp*.so* /tmp/cv2_deps/ && \
cp -v /usr/local/cuda/lib64/libcudart.so* /tmp/cv2_deps/ && \
cp -P /usr/local/cuda/lib64/libnvrtc.so* /tmp/cv2_deps/ && \
# FIX: Robust fallback copying to grab NPP/CUDA libs regardless of whether they land in /usr/local or system path channels
(cp -v /usr/local/cuda/lib64/libnpp*.so* /tmp/cv2_deps/ || cp -v /usr/lib/x86_64-linux-gnu/libnpp*.so* /tmp/cv2_deps/) && \
(cp -v /usr/local/cuda/lib64/libcudart.so* /tmp/cv2_deps/ || cp -v /usr/lib/x86_64-linux-gnu/libcudart.so* /tmp/cv2_deps/) && \
(cp -P /usr/local/cuda/lib64/libnvrtc.so* /tmp/cv2_deps/ || cp -P /usr/lib/x86_64-linux-gnu/libnvrtc.so* /tmp/cv2_deps/) && \
(cp -v /usr/local/cuda/lib64/libcublas*.so* /tmp/cv2_deps/ || cp -v /usr/lib/x86_64-linux-gnu/libcublas*.so* /tmp/cv2_deps/) && \
cp -v /usr/lib/x86_64-linux-gnu/libnvidia-encode.so* /tmp/cv2_deps/ || true


# Clean up
RUN rm -rf ${DEPENDENCY_DIR}


FROM openvisualcloud/xeon-ubuntu2204-media-nginx:23.1@sha256:d19eb597dc210134063803630ae2ea1ec84dfd4189138f59551e2f5ed047284a

ARG DEBIAN_FRONTEND=noninteractive
ARG CUDA_MAJOR_VERSION=12
ARG CUDA_MINOR_VERSION=8
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="$VIRTUAL_ENV/bin:/usr/local/cuda/bin:${PATH}"

# Install Runtime Libraries, FFmpeg/VA-API headers, and cuDNN
# Includes libva and ffmpeg libraries required for HEVC decoding
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
python3 \
libgl1 \
libglib2.0-0 \
libtbb12 \
# Critical for Hardware Decoding (HEVC)
libva2 \
libva-drm2 \
libva-x11-2 \
libavcodec58 \
libavformat58 \
libswscale5 \
libv4l-0 && \
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
python3 \
libgl1 \
libglib2.0-0 \
libtbb12 \
# Critical for Hardware Decoding (HEVC)
libva2 \
libva-drm2 \
libva-x11-2 \
libavcodec58 \
libavformat58 \
libswscale5 \
libv4l-0 && \
# Install necessary CUDA packages
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb -o /tmp/cuda-keyring.deb && \
dpkg -i /tmp/cuda-keyring.deb && rm /tmp/cuda-keyring.deb && \
dpkg -i /tmp/cuda-keyring.deb && rm /tmp/cuda-keyring.deb && \
apt-get update && \
apt-get install -y -q --no-install-recommends libcudnn9-cuda-12 \
apt-get install -y -q --no-install-recommends \
libcudnn9-cuda-${CUDA_MAJOR_VERSION} \
libavcodec-dev \
libavformat-dev \
libavutil-dev nvidia-cuda-dev && \
libavutil-dev \
cuda-nvcc-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} && \
rm -rf /var/lib/apt/lists/*

# Copy the entire pre-compiled virtual environment from the build stage
COPY --from=build ${VIRTUAL_ENV} ${VIRTUAL_ENV}
# Copy NPP (NVIDIA Performance Primitives) libs - Required for OpenCV CUDA
# COPY --from=build /usr/local/cuda/lib64/libnpp*.so* /usr/local/cuda/lib64/

# Copy additional required CUDA math/parallel libs
RUN mkdir -p /usr/local/cuda/lib64
COPY --from=build /tmp/cv2_deps/* /usr/local/cuda/lib64/

# Tells the host engine to expose all GPUs and utility binaries (like nvidia-smi)
ENV NVIDIA_VISIBLE_DEVICES=all
# FIX: Cleaned duplicate line later in file to ensure capabilities are consistently initialized
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility,video
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${VIRTUAL_ENV}/lib:${LD_LIBRARY_PATH}"
RUN ldconfig

ARG DEVICE="CPU"
ARG DEVICE="GPU"
ENV DEVICE="${DEVICE}"

ARG DEBUG="0"
ENV DEBUG="${DEBUG}"

# Set the working directory in the container
WORKDIR /home
COPY requirements.txt /home/
ENV NVIDIA_DRIVER_CAPABILITIES=all

# RUN pip3 install --no-cache-dir "pytest>=9.0.3" && \
# pip3 install --no-cache-dir --require-hashes -r /home/requirements.CPU.txt --index-url https://download.pytorch.org/whl/cpu --extra-index-url https://pypi.org/simple && \
# pip3 uninstall -y ultralytics opencv-python opencv-contrib-python opencv-python-headless && \
# pip3 install --no-cache-dir --require-hashes -r /home/requirements.GPU.txt && \
# pip3 uninstall -y opencv-python opencv-contrib-python opencv-python-headless


RUN pip3 install --no-cache-dir --require-hashes -r /home/requirements.txt && \
pip3 uninstall -y opencv-python opencv-contrib-python opencv-python-headless
pip3 uninstall -y opencv-python opencv-contrib-python opencv-python-headless
52 changes: 38 additions & 14 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,61 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
{
"name": "Pipeline Dev",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "mcr.microsoft.com/devcontainers/base:bullseye"

"build": {
// Path is relative to the devcontainer.json file.
"dockerfile" : "Dockerfile",
// "context" : "..",
// "dockerfile" : "../fastapi/Dockerfile",
"context" : "../fastapi",
"args":{
"HTTP_PROXY" : "${localEnv:HTTP_PROXY}",
"http_proxy" : "${localEnv:http_proxy}",
"HTTPS_PROXY" : "${localEnv:HTTPS_PROXY}",
"https_proxy" : "${localEnv:https_proxy}",
"NO_PROXY" : "${localEnv:NO_PROXY}",
"no_proxy" : "${localEnv:no_proxy}",
}
"no_proxy" : "${localEnv:no_proxy}"
},
// Forces the build phase to use the host network to fix any Ubuntu timeout
"options": [
"--network=host"
]
},

"containerEnv" : {
"HTTP_PROXY" : "${localEnv:HTTP_PROXY}",
"http_proxy" : "${localEnv:http_proxy}",
"HTTPS_PROXY" : "${localEnv:HTTPS_PROXY}",
"https_proxy" : "${localEnv:https_proxy}",
"NO_PROXY" : "${localEnv:NO_PROXY}",
"no_proxy" : "${localEnv:no_proxy}",
"no_proxy" : "${localEnv:no_proxy}"
},

"runArgs" : [ "--rm", "--gpus", "all", "--ipc=host", "--name", "pipeline_dev", "-p", "8011:8000","--cap-add=SYS_NICE", "--shm-size=8gb"], //, "--net=host", "--privileged", "--shm-size=2gb"],
// Native, modern way to pass GPUs to the Dev Container
// VS Code will automatically append the --gpus all flag if detected
"hostRequirements": {
"gpu": "optional"
},

"runArgs" : [
// "-p", "8011:8000",
// "--rm",
// "--gpus", "all",
"--restart", "unless-stopped",
"--ipc=host",
"--name", "pipeline_dev",
"--cap-add=SYS_NICE",
"--shm-size=8gb",
"--memory=16g", // Limits container RAM consumption ceiling
"--memory-swap=16g", // Prevents toxic swap disk compilation leaks
"--network=host" // Ensures runtime matches the host network
],
//, "--privileged", "--shm-size=2gb"],

// Forwarding ports cleanly via VS Code spec instead of raw "-p"
// "forwardPorts": [],
"overrideCommand": true,

"postStartCommand": "apt-get update -o Acquire::Check-Date=false -y && apt-get install -y gdb sudo && cp -rp /workspace/app/*.md /app/ && cp -rp /workspace/app/.vscode /app/ && cp -rp /workspace/app/.gitignore /app/ && cp -rp /workspace/app/.github /app/",
"postStartCommand": "apt-get update -o Acquire::Check-Date=false -y && apt-get install -y gdb sudo",
// && cp -rp /workspace/app/*.md /home/ && cp -rp /workspace/app/.vscode /home/ && cp -rp /workspace/app/.gitignore /home/ && cp -rp /workspace/app/.github /home/",
// "postAttachCommand": "sudo chown -R ${localEnv:USER} /workspaces",

// Features to add to the dev container. More info: https://containers.dev/features.
Expand All @@ -51,7 +77,7 @@
},

"workspaceFolder": "/home",
"workspaceMount": "source=./,target=/workspace/app,type=bind,consistency=cached",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace/app,type=bind,consistency=cached",

// For training only
// "mounts": [
Expand All @@ -60,10 +86,8 @@

// For fastapi
"mounts": [
"source=./inputs,target=/watch_dir,type=bind",
"source=./fastapi,target=/home,type=bind"
// "source=./fastapi/resources,target=/home/resources,type=bind",
// "source=./fastapi/tests,target=/home/tests,type=bind"
"source=${localWorkspaceFolder}/inputs,target=/watch_dir,type=bind",
"source=${localWorkspaceFolder}/fastapi,target=/home,type=bind"
],

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
Expand Down
16 changes: 7 additions & 9 deletions .github/assets/fastapi/requirements.in
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
av>=17.0.1
cucim>=23.10.0
cupy-cuda12x>=13.6.0
fastapi>=0.135.1
nncf>=2.19.0
numpy>=1.26.4
numpy==1.26.4
nvidia-cuda-runtime-cu12>=12.8.90
nvidia-cudnn-cu12>=9.10.2.21
onnx>=1.21.0
onnx>=1.22.0
onnxruntime-gpu>=1.23.2
onnxslim>=0.1.82
openvino-dev>=2024.6.0
pip>=26.1
pip>=26.2
protobuf>=5.29.6,<6 # For VDMS
pynvvideocodec>=2.1.0
pytest>=9.0.3
requests>=2.33.0
tensorrt_cu12==10.14.1.48.post1
torch==2.10.0
torchvision==0.25.0
ultralytics>=8.4.8
torchvision>=0.25.0
ultralytics>=8.4.34
uvicorn>=0.42.0
vdms>=0.0.23
wheel>=0.46.3

idna>=3.15
pillow>=12.2.0
starlette>=1.0.1
pillow>=12.3.0
starlette>=1.3.1
urllib3>=2.7.0
14 changes: 7 additions & 7 deletions .github/assets/finetune/requirements.in
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
cucim>=23.10.0
cupy-cuda12x>=13.6.0
numpy>=1.26.4
numpy==1.26.4
nvidia-cuda-runtime-cu12>=12.8.90
nvidia-cudnn-cu12>=9.10.2.21
onnx>=1.21.0
onnx>=1.22.0
onnxruntime-gpu>=1.23.2
onnxslim>=0.1.82
pip>=26.1
pip>=26.2
requests>=2.33.0
tensorrt_cu12==10.14.1.48.post1
torch==2.10.0
torchvision==0.25.0
ultralytics>=8.4.8
torchvision>=0.25.0
ultralytics>=8.4.34

idna>=3.15
pillow>=12.2.0
pillow>=12.3.0
protobuf>=5.29.6,<6 # For VDMS
urllib3>=2.7.0

4 changes: 2 additions & 2 deletions .github/assets/frontend/requirements.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pip>=26.1
pip>=26.2
ply>=3.11
protobuf>=5.29.6,<6 # For VDMS
psutil>=5.9.0
requests>=2.33.0
tornado>=6.5.5
tornado>=6.5.8
vdms>=0.0.23

idna>=3.15
Expand Down
6 changes: 3 additions & 3 deletions .github/assets/udf/requirements.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Flask>=3.1.3
inotify>=0.2.12
numpy>=2.2.6
opencv-python-headless>=4.13.0.90
pip>=26.1
numpy==1.26.4
opencv-python-headless<4.12
pip>=26.2
protobuf>=5.29.6,<6 # For VDMS
vdms>=0.0.23
werkzeug>=3.1.6
Expand Down
4 changes: 2 additions & 2 deletions .github/assets/video/requirements.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
inotify>=0.2.12
pip>=26.1
pip>=26.2
pyyaml>=6.0.3
requests>=2.33.0
tornado>=6.5.5
tornado>=6.5.8

idna>=3.15
urllib3>=2.7.0
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
.venv*
.vscode
*.log
**/__pycache__/
**/_*
**/* copy*
**/DockerImageTars/
build/*
fastapi/resources/models/intel
fastapi/resources/models/ultralytics
fastapi/tests/*_data/
fastapi/tests/*_results*
fastapi/tests/*_test_imgs
fastapi/tests/*.mp4
fastapi/tests/run_test_*.*
finetune/.env
finetune/app/*-Results
inputs/camera_config.yaml
Loading