-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add capi yolov8 docker compose use cases for gst-capi (#22)
* fix: resolve the CAPI build issue on dependency changes intel-onevpl FIXES: #20 Signed-off-by: Jim Wang <[email protected]> * feat: add yolov8 docker-compose for gst_capi use cases Signed-off-by: Jim Wang <[email protected]> * fix: update copyright year Signed-off-by: Jim Wang <[email protected]> * fix: resolve the RENDER_MODE issue setting from make run command Signed-off-by: Jim Wang <[email protected]> --------- Signed-off-by: Jim Wang <[email protected]>
- Loading branch information
1 parent
df0e788
commit 9a848b5
Showing
25 changed files
with
4,808 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# Copyright (C) 2024 Intel Corporation. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
FROM openvino/ubuntu22_dev:2023.0.0 | ||
|
||
USER root | ||
|
||
RUN apt-get update -y || true; DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
wget && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY download_mo_bit_models.sh / | ||
RUN chmod +x /download_mo_bit_models.sh | ||
|
||
RUN mkdir -p /result | ||
|
||
WORKDIR / | ||
|
||
ENTRYPOINT [ "/download_mo_bit_models.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# | ||
# Copyright (C) 2023-2024 Intel Corporation. | ||
# | ||
# | ||
# ----------------------------------------------------------- | ||
|
||
# https://hub.docker.com/r/openvino/model_server | ||
ARG BASE_IMAGE=openvino/model_server:2023.1-gpu | ||
FROM $BASE_IMAGE as release | ||
|
||
USER root | ||
WORKDIR / | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
SHELL ["/bin/bash", "-c"] | ||
|
||
# Install build tools and media UMD | ||
ARG BUILD_DEPENDENCIES="cmake build-essential git-gui python3 python3-pip flex bison clang libgtk2.0-dev libhdf5-serial-dev libvtk9-dev libtbb2 libxml2 curl libpugixml1v5 intel-media-va-driver-non-free libmfx1 libvpl2 libegl-mesa0 libegl1-mesa libegl1-mesa-dev libgbm1 libgl1-mesa-dev libgl1-mesa-dri libglapi-mesa libgles2-mesa-dev libglx-mesa0 libigdgmm12 libxatracker2 mesa-va-drivers mesa-vdpau-drivers mesa-vulkan-drivers va-driver-all vainfo libcanberra-gtk-module jq libopencv-dev python3-opencv gstreamer1.0-plugins-base-apps" | ||
RUN apt -y update && \ | ||
apt install -y ${BUILD_DEPENDENCIES} && \ | ||
rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* | ||
|
||
# Install GStramer | ||
RUN apt update -y; apt install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio && \ | ||
rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* | ||
|
||
# Install MSDK/oneAPI oneVPL libs | ||
ARG GPU_TYPE="client" | ||
RUN apt update -y; apt install -y wget curl vim gpg-agent; wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg; echo "deb [arch=amd64,i386 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy $GPU_TYPE" | tee /etc/apt/sources.list.d/intel-gpu-jammy.list; apt update -y; DEBIAN_FRONTEND=noninteractive apt-get install -y libegl-mesa0 libegl1-mesa libegl1-mesa-dev libgbm1 libgl1-mesa-dev libgl1-mesa-dri libglapi-mesa libgles2-mesa-dev libglx-mesa0 libigdgmm12 libxatracker2 mesa-va-drivers mesa-vulkan-drivers libcanberra-gtk-module libmfx1 libmfxgen1 libvpl2 && \ | ||
rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* | ||
|
||
# Download OVMS C-API runtime | ||
RUN apt update -y; apt install -y wget curl vim && \ | ||
rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* | ||
RUN wget -O ovms.tar.gz https://github.com/openvinotoolkit/model_server/releases/download/v2023.2/ovms_ubuntu22.tar.gz | ||
RUN tar -xf ovms.tar.gz | ||
|
||
# Copy C-API sources | ||
ENV LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:/usr/local/lib/x86_64-linux-gnu/:/usr/local/lib:/ovms/lib:$LD_LIBRARY_PATH | ||
WORKDIR /tmp | ||
RUN mkdir -p /app/gst-ovms/pipelines/ | ||
|
||
COPY capi_yolov8_ensemble /app/gst-ovms/pipelines/yolov8_ensemble | ||
|
||
RUN cd /app/gst-ovms/pipelines/yolov8_ensemble; make build | ||
|
||
USER ovms | ||
WORKDIR /app/gst-ovms/pipelines | ||
|
||
# Enable HWA decoder for OpenCV using GST use cases | ||
ENV OPENCV_FFMPEG_CAPTURE_OPTIONS="hw_decoders_any;vaapi" | ||
ENTRYPOINT ["/bin/bash", "-c"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# | ||
# Copyright (C) 2024 Intel Corporation. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
version: '3.7' | ||
services: | ||
CapiYolov8Ensemble: | ||
image: openvino/model_server-capi-gst-ovms-capi_yolov8_ensemble:latest | ||
deploy: | ||
mode: replicated | ||
replicas: ${PIPELINE_COUNT} | ||
network_mode: "host" | ||
user: root | ||
privileged: true | ||
entrypoint: /app/gst-ovms/pipelines/yolov8_ensemble/yolo_efficientnet.sh | ||
env_file: | ||
- ./res/capi_yolov8_ensemble.env | ||
environment: | ||
- CONTAINER_NAME="capi_yolov8_ensemble" | ||
- INPUTSRC=rtsp://localhost:8554/camera_1 | ||
- DEVICE=CPU | ||
- BARCODE=0 | ||
- RENDER_MODE=${RENDER_MODE} #RENDER_MODE=1 will work only after running xhost +local:docker | ||
- DISPLAY=$DISPLAY | ||
- OVMS_MODEL_CONFIG_JSON=/ovms_server/config-yolov8.json | ||
- PIPELINE_PROFILE=capi_yolov8_ensemble | ||
depends_on: | ||
- camera-simulator1 | ||
volumes: | ||
- ${RESULTS_DIR}:/tmp/results | ||
- ~/.Xauthority:/home/dlstreamer/.Xauthority | ||
- /tmp/.X11-unix | ||
- ~/.cl-cache:/home/pipeline-server/.cl-cache | ||
- ./res/:/home/pipeline-server/envs | ||
- ${RETAIL_USE_CASE_ROOT}/models:/models | ||
- ${RETAIL_USE_CASE_ROOT}/use-cases/gst_capi/res/yolov8:/ovms_server |
28 changes: 28 additions & 0 deletions
28
use-cases/gst_capi/pipelines/capi_yolov8_ensemble/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# Copyright (c) 2024 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
CV_LIBS = -L/usr/lib/x86_64-linux-gnu/ -L/usr/local/lib/x86_64-linux-gnu/ -L/ovms/lib/ | ||
CV_INCLUDES = -I/usr/include/opencv4 -I/usr/include/gstreamer-1.0 | ||
CUSTOM_NODE_FLAGS = -fpic -O2 -U_FORTIFY_SOURCE -fstack-protector -fno-omit-frame-pointer -D_FORTIFY_SOURCE=1 -fno-strict-overflow -Wall -Wno-unknown-pragmas -Wno-error=sign-compare -fno-delete-null-pointer-checks -fwrapv -fstack-clash-protection -Wformat -Wformat-security | ||
|
||
build: | ||
g++ -c -std=c++17 efficientnetb0_node.cpp ${CUSTOM_NODE_FLAGS} ${CV_INCLUDES} | ||
|
||
g++ -std=c++17 -shared ${CUSTOM_NODE_FLAGS} -o libcustom_node_efficientnetb0-yolov8.so efficientnetb0_node.o ${CV_LIBS} ${CV_INCLUDES} -lopencv_core -lopencv_dnn -lopencv_imgproc -lopencv_imgcodecs | ||
cp libcustom_node_efficientnetb0-yolov8.so /ovms/lib/ | ||
|
||
g++ -std=c++17 main.cpp -I/usr/include/gstreamer-1.0/usr/lib/x86_64-linux-gnu/ -I/usr/local/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/ovms/include $(CV_INCLUDES) $(CV_LIBS) -L/usr/lib/x86_64-linux-gnu/gstreamer-1.0 -lgstbase-1.0 -lgobject-2.0 -lglib-2.0 -lgstreamer-1.0 -lgstapp-1.0 -lopencv_imgcodecs -lopencv_imgproc -lopencv_core -lovms_shared -lopencv_highgui -lopencv_dnn -lpthread -fPIC --std=c++17 -o capi_yolov8_ensemble | ||
|
66 changes: 66 additions & 0 deletions
66
use-cases/gst_capi/pipelines/capi_yolov8_ensemble/buffersqueue.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//***************************************************************************** | ||
// Copyright 2024 Intel Corporation | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
//***************************************************************************** | ||
|
||
#include "buffersqueue.hpp" | ||
|
||
#include <iostream> | ||
|
||
namespace ovms { | ||
namespace custom_nodes_common { | ||
BuffersQueue::BuffersQueue(size_t singleBufferSize, int streamsLength) : | ||
Queue(streamsLength), | ||
singleBufferSize(singleBufferSize), | ||
size(singleBufferSize * streamsLength), | ||
memoryPool(std::make_unique<char[]>(size)) { | ||
for (int i = 0; i < streamsLength; ++i) { | ||
inferRequests.push_back(memoryPool.get() + i * singleBufferSize); | ||
} | ||
} | ||
|
||
BuffersQueue::~BuffersQueue() {} | ||
|
||
void* BuffersQueue::getBuffer() { | ||
// can be easily switched to async version if need arise | ||
auto idleId = tryToGetIdleStream(); | ||
if (idleId.has_value()) { | ||
return getInferRequest(idleId.value()); | ||
} | ||
return nullptr; | ||
} | ||
|
||
bool BuffersQueue::returnBuffer(void* buffer) { | ||
if ((static_cast<char*>(buffer) < memoryPool.get()) || | ||
((memoryPool.get() + size - 1) < buffer) || | ||
((static_cast<char*>(buffer) - memoryPool.get()) % singleBufferSize != 0)) { | ||
return false; | ||
} | ||
returnStream(getBufferId(buffer)); | ||
return true; | ||
} | ||
|
||
int BuffersQueue::getBufferId(void* buffer) { | ||
return (static_cast<char*>(buffer) - memoryPool.get()) / singleBufferSize; | ||
} | ||
|
||
const size_t BuffersQueue::getSize() { | ||
return this->size; | ||
} | ||
|
||
const size_t BuffersQueue::getSingleBufferSize() { | ||
return this->singleBufferSize; | ||
} | ||
} // namespace custom_nodes_common | ||
} // namespace ovms |
Oops, something went wrong.