Skip to content

Commit

Permalink
#43 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tomskikh committed Jan 11, 2023
1 parent d94b612 commit 0dee526
Show file tree
Hide file tree
Showing 5 changed files with 390 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ build-pyds:
--build-arg BASE_IMAGE=$(PYDS_BASE_IMAGE) \
--build-arg PIP_PLATFORM=$(PYDS_PIP_PLATFORM) \
--build-arg PYDS_TAG=v$(PYDS_VERSION)-unmap \
--progress plain \
-f docker/Dockerfile.pyds \
-t savant-pyds$(PLATFORM_SUFFIX):$(SAVANT_VERSION)-$(DEEPSTREAM_VERSION) .
mkdir -p libs/wheels
Expand All @@ -45,6 +46,7 @@ build-pyds:
build: build-pyds
DOCKER_BUILDKIT=1 docker build \
--target base \
--progress plain \
--build-arg DEEPSTREAM_VERSION=$(DEEPSTREAM_VERSION) \
-f docker/$(DOCKER_FILE) \
-t savant-deepstream$(PLATFORM_SUFFIX):$(SAVANT_VERSION)-$(DEEPSTREAM_VERSION)-base .
Expand Down
67 changes: 66 additions & 1 deletion docker/Dockerfile.deepstream
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,67 @@ RUN python setup.py bdist_wheel && \
rm -rf _skbuild


FROM nvcr.io/nvidia/deepstream:$DEEPSTREAM_VERSION-devel AS opencv_build

# python to python3 by default
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10

WORKDIR /opencv
RUN git clone --branch 4.6.0 --depth 1 https://github.com/opencv/opencv
RUN git clone --branch 4.6.0 --depth 1 https://github.com/opencv/opencv_contrib
WORKDIR /opencv/build

RUN pip install --no-cache-dir 'numpy~=1.22.4'

#RUN --mount=type=cache,target=/tmp/opencv-cache \
# cmake \
# -DOPENCV_EXTRA_MODULES_PATH=/opencv/opencv_contrib/modules \
# -DCMAKE_INSTALL_PREFIX=/opencv/dist \
# -DOPENCV_DOWNLOAD_PATH=/tmp/opencv-cache \
# -DPYTHON_DEFAULT_EXECUTABLE=$(which python3) \
# -DOPENCV_FORCE_PYTHON_LIBS=ON \
# -DBUILD_DOCS=OFF \
# -DBUILD_EXAMPLES=OFF \
# -DBUILD_JAVA=OFF \
# -DBUILD_PERF_TESTS=OFF \
# -DBUILD_SHARED_LIBS=ON \
# -DBUILD_TESTS=OFF \
# -DOPENCV_DNN_CUDA=OFF \
# -DWITH_CUBLAS=OFF \
# -DWITH_CUDA=ON \
# -DWITH_CUDNN=OFF \
# -DWITH_GTK=OFF \
# -DWITH_OPENEXR=OFF \
# -DWITH_FFMPEG=OFF \
# -DWITH_V4L=OFF \
# -DWITH_GSTREAMER=OFF \
# -DWITH_1394=OFF \
# -DVIDEOIO_ENABLE_PLUGINS=OFF \
# -DBUILD_opencv_python3=ON \
# /opencv/opencv

RUN --mount=type=cache,target=/tmp/opencv-cache \
cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D OPENCV_EXTRA_MODULES_PATH=/opencv/opencv_contrib/modules \
-D CMAKE_INSTALL_PREFIX=/opencv/dist \
-D OPENCV_DOWNLOAD_PATH=/tmp/opencv-cache \
-D PYTHON_DEFAULT_EXECUTABLE=$(which python3) \
-D OPENCV_PYTHON_INSTALL_PATH=lib/python3.8/dist-packages \
-D OPENCV_FORCE_PYTHON_LIBS=ON \
-D BUILD_LIST=core,python3,cudev,cudaimgproc \
-D BUILD_opencv_apps=OFF \
-D BUILD_DOCS=OFF \
-D BUILD_EXAMPLES=OFF \
-D BUILD_JAVA=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_SHARED_LIBS=ON \
-D WITH_CUDA=ON \
/opencv/opencv

RUN make -j$(nproc) install


FROM nvcr.io/nvidia/deepstream:$DEEPSTREAM_VERSION-devel AS savantboost_build

# Newer cmake ver. needed for "FindCUDAToolkit"
Expand Down Expand Up @@ -62,19 +123,23 @@ ENV LD_LIBRARY_PATH=/opt/nvidia/deepstream/deepstream/lib/:$LD_LIBRARY_PATH
COPY requirements/base.txt requirements-base.txt
COPY requirements/deepstream.txt requirements-deepstream.txt
RUN python -m pip install --no-cache-dir --upgrade pip
COPY libs/wheels libs/wheels
RUN python -m pip install --no-cache-dir \
-r requirements-base.txt \
-r requirements-deepstream.txt \
&& rm requirements-base.txt \
&& rm requirements-deepstream.txt

COPY --from=opencv_build /opencv/dist /usr/local
COPY --from=pygstsavantframemeta_build /libs/gstsavantframemeta/dist /libs/gstsavantframemeta/dist
RUN python -m pip install --no-cache-dir /libs/gstsavantframemeta/dist/*.whl

COPY --from=savantboost_build /libs/savanboost/dist /libs/savanboost/dist
RUN python -m pip install --no-cache-dir /libs/savanboost/dist/*.whl

COPY libs/wheels libs/wheels
RUN python -m pip install --no-cache-dir \
./libs/wheels/pyds-1.1.4-py3-none-linux_x86_64.whl

COPY savant savant
COPY LICENSE savant/
ENV GST_PLUGIN_PATH=$APP_PATH/savant/gst_plugins:$APP_PATH/savant/utils/gst_plugins
Expand Down
9 changes: 7 additions & 2 deletions docker/Dockerfile.pyds
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ RUN ./autogen.sh \

WORKDIR /deepstream_python_apps/bindings/build
ARG PIP_PLATFORM
RUN cmake -DPIP_PLATFORM=$PIP_PLATFORM .. \
&& make \
RUN cmake -DPIP_PLATFORM=$PIP_PLATFORM ..
RUN make -j$(nproc)
RUN cd /deepstream_python_apps \
&& git checkout master \
&& git pull \
&& git checkout dd19a45a
RUN make -j$(nproc) \
&& mkdir /dist \
&& mv *.whl /dist/
Loading

0 comments on commit 0dee526

Please sign in to comment.