Skip to content

Commit 3cf3436

Browse files
OVMS update for the 2.21 release
This update continues the LTO patch and add ONNX to the areas getting LTO optimizations. This also adds a patch to allow IPv6 network addresses.
1 parent 9aa7bc0 commit 3cf3436

File tree

4 files changed

+99
-8
lines changed

4 files changed

+99
-8
lines changed

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# Optimizations used for TF Serving release builds.
1818
build:release --copt=-mavx
1919
build:release --copt=-msse4.2
20+
build:linux --copt="-march=haswell"
2021

2122
# Options used to build with CUDA.
2223
build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain

Dockerfile.redhat

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
2626

2727
ARG JOBS=8
2828
ARG VERBOSE_LOGS=OFF
29+
ARG LTO_ENABLE=OFF
30+
ARG LTO_CXX_FLAGS=""
31+
ARG LTO_LD_FLAGS="-Wl,-z,relro"
2932

3033
# hadolint ignore=DL3041
3134
RUN echo -e "max_parallel_downloads=8\nretries=50" >> /etc/dnf/dnf.conf && \
@@ -51,7 +54,10 @@ WORKDIR /boost
5154
RUN wget -nv https://sourceforge.net/projects/boost/files/boost/1.68.0/boost_1_68_0.tar.gz && \
5255
if [ "$VERBOSE_LOGS" == "ON" ] ; then export BVERBOSE="-d+2" ; else export BVERBOSE="" ; fi && \
5356
tar xf boost_1_68_0.tar.gz && cd boost_1_68_0 && ./bootstrap.sh && \
54-
./b2 -j ${JOBS} cxxstd=17 link=static cxxflags='-fPIC' cflags='-fPIC' \
57+
./b2 -j ${JOBS} cxxstd=17 link=static variant=release \
58+
cxxflags="-fPIC $LTO_CXX_FLAGS" \
59+
cflags="-fPIC $LTO_CXX_FLAGS" \
60+
linkflags="$LTO_LD_FLAGS" \
5561
--with-chrono --with-date_time --with-filesystem \
5662
--with-program_options --with-system \
5763
--with-random --with-thread --with-atomic --with-regex \
@@ -65,7 +71,9 @@ COPY third_party/pugixml /ovms/third_party/pugixml
6571
RUN git clone -b v1.13 https://github.com/zeux/pugixml && \
6672
cd pugixml && \
6773
patch -p1 < /ovms/third_party/pugixml/pugixml_v1.13_flags.patch && \
68-
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_VERBOSE_MAKEFILE=${VERBOSE_LOGS} && \
74+
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_VERBOSE_MAKEFILE=${VERBOSE_LOGS} \
75+
-DCMAKE_CXX_FLAGS="${LTO_CXX_FLAGS}" \
76+
-DCMAKE_SHARED_LINKER_FLAGS="${LTO_LD_FLAGS}" && \
6977
make all -j ${JOBS} && \
7078
cp -P libpugixml.so* /usr/lib64/
7179

@@ -79,10 +87,10 @@ RUN git clone --recurse-submodules --depth 1 --branch v2.10.16 https://github.co
7987
patch -d /azure/azure-storage-cpp/ -p1 </ovms/third_party/azure/azure_sdk.patch
8088

8189
WORKDIR /azure/cpprestsdk/Release/build.release
82-
RUN cmake .. -DCMAKE_VERBOSE_MAKEFILE=${VERBOSE_LOGS} -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBoost_USE_STATIC_RUNTIME=ON -DBoost_USE_STATIC_LIBS=ON -DWERROR=OFF -DBUILD_SAMPLES=OFF -DBUILD_TESTS=OFF && make --jobs=$JOBS install
90+
RUN cmake .. -DCMAKE_VERBOSE_MAKEFILE=${VERBOSE_LOGS} -DCMAKE_CXX_FLAGS="-fPIC ${LTO_CXX_FLAGS}" -DCMAKE_SHARED_LINKER_FLAGS="${LTO_LD_FLAGS}" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBoost_USE_STATIC_RUNTIME=ON -DBoost_USE_STATIC_LIBS=ON -DWERROR=OFF -DBUILD_SAMPLES=OFF -DBUILD_TESTS=OFF && make --jobs=$JOBS install
8391

8492
WORKDIR /azure/azure-storage-cpp/Microsoft.WindowsAzure.Storage/build.release
85-
RUN CASABLANCA_DIR=/azure/cpprestsdk cmake .. -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBoost_USE_STATIC_RUNTIME=ON -DBoost_USE_STATIC_LIBS=ON -DCMAKE_VERBOSE_MAKEFILE=${VERBOSE_LOGS} && make --jobs=$JOBS && make --jobs=$JOBS install
93+
RUN CASABLANCA_DIR=/azure/cpprestsdk cmake .. -DCMAKE_CXX_FLAGS="-fPIC ${LTO_CXX_FLAGS}" -DCMAKE_SHARED_LINKER_FLAGS="${LTO_LD_FLAGS}" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBoost_USE_STATIC_RUNTIME=ON -DBoost_USE_STATIC_LIBS=ON -DCMAKE_VERBOSE_MAKEFILE=${VERBOSE_LOGS} && make --jobs=$JOBS && make --jobs=$JOBS install
8694
####### End of Azure SDK
8795

8896
####### Build OpenCV
@@ -99,6 +107,7 @@ SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
99107

100108
ARG JOBS=40
101109
ARG VERBOSE_LOGS=OFF
110+
ARG LTO_ENABLE=OFF
102111

103112
# hadolint ignore=DL3041
104113
RUN dnf install -y https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/opencl-headers-3.0-6.20201007gitd65bcc5.el9.noarch.rpm && \
@@ -165,9 +174,12 @@ RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.n
165174
# hadolint ignore=DL3003
166175
RUN if [ "$ov_use_binary" == "0" ] ; then true ; else exit 0 ; fi ; git clone https://github.com/$ov_source_org/openvino.git /openvino && cd /openvino && git checkout $ov_source_branch && git submodule update --init --recursive
167176
RUN if [ "$ov_use_binary" == "0" ]; then true ; else exit 0 ; fi ; if ! [[ $debug_bazel_flags == *"py_off"* ]]; then true ; else exit 0 ; fi ; pip3 install --no-cache-dir -r /openvino/src/bindings/python/wheel/requirements-dev.txt
177+
WORKDIR /openvino
178+
COPY openvino-lto.patch .
179+
RUN if [ "$ov_use_binary" == "0" ]; then patch -p1 < openvino-lto.patch ; rm -f openvino-lto.patch ; fi
168180
WORKDIR /openvino/build
169-
RUN if [ "$ov_use_binary" == "0" ] && [[ $debug_bazel_flags == *"PYTHON_DISABLE=1"* ]]; then true ; else exit 0 ; fi ; if ! [[ $debug_bazel_flags == *"PYTHON_DISABLE=1"* ]]; then true ; else exit 0 ; fi ; cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE="${VERBOSE_LOGS}" -DENABLE_PYTHON=ON -DENABLE_INTEL_NPU=OFF -DENABLE_SAMPLES=0 -DCMAKE_CXX_FLAGS=" -Wno-error=parentheses " ..
170-
RUN if [ "$ov_use_binary" == "0" ] ; then true ; else exit 0 ; fi ; cmake -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" -DCMAKE_VERBOSE_MAKEFILE="${VERBOSE_LOGS}" -DENABLE_SAMPLES=0 -DENABLE_INTEL_NPU=OFF -DCMAKE_CXX_FLAGS=" -Wno-error=parentheses " ..
181+
RUN if [ "$ov_use_binary" == "0" ] && [[ $debug_bazel_flags == *"PYTHON_DISABLE=1"* ]]; then true ; else exit 0 ; fi ; if ! [[ $debug_bazel_flags == *"PYTHON_DISABLE=1"* ]]; then true ; else exit 0 ; fi ; cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE="${VERBOSE_LOGS}" -DENABLE_LTO=${LTO_ENABLE} -DENABLE_PYTHON=ON -DENABLE_INTEL_NPU=OFF -DENABLE_SAMPLES=0 -DCMAKE_CXX_FLAGS=" -Wno-error=parentheses ${LTO_CXX_FLAGS} " -DCMAKE_SHARED_LINKER_FLAGS="${LTO_LD_FLAGS}" ..
182+
RUN if [ "$ov_use_binary" == "0" ] ; then true ; else exit 0 ; fi ; cmake -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" -DCMAKE_VERBOSE_MAKEFILE="${VERBOSE_LOGS}" -DENABLE_LTO=${LTO_ENABLE} -DENABLE_SAMPLES=0 -DENABLE_INTEL_NPU=OFF -DCMAKE_CXX_FLAGS=" -Wno-error=parentheses ${LTO_CXX_FLAGS} " -DCMAKE_SHARED_LINKER_FLAGS="${LTO_LD_FLAGS}" ..
171183
RUN if [ "$ov_use_binary" == "0" ] ; then true ; else exit 0 ; fi ; make --jobs=$JOBS
172184
RUN if [ "$ov_use_binary" == "0" ] ; then true ; else exit 0 ; fi ; make install
173185
RUN if [ "$ov_use_binary" == "0" ] ; then true ; else exit 0 ; fi ; \
@@ -214,7 +226,7 @@ ARG ov_tokenizers_branch=master
214226
# hadolint ignore=DL3003
215227
RUN git clone https://github.com/openvinotoolkit/openvino_tokenizers.git /openvino_tokenizers && cd /openvino_tokenizers && git checkout $ov_tokenizers_branch && git submodule update --init --recursive
216228
WORKDIR /openvino_tokenizers/build
217-
RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE="${VERBOSE_LOGS}" && cmake --build . --parallel $JOBS ; cp /openvino_tokenizers/build/src/lib*.so /opt/intel/openvino/runtime/lib/intel64/
229+
RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE="${VERBOSE_LOGS}" -DCMAKE_CXX_FLAGS=" ${LTO_CXX_FLAGS} " -DCMAKE_SHARED_LINKER_FLAGS="${LTO_LD_FLAGS}" && cmake --build . --parallel $JOBS ; cp /openvino_tokenizers/build/src/lib*.so /opt/intel/openvino/runtime/lib/intel64/
218230

219231
# Build OpenVINO Model Server
220232
WORKDIR /ovms
@@ -391,5 +403,14 @@ COPY --from=pkg /usr/local/lib64/python3.*/site-packages/MarkupSafe-3.0.2.dist-i
391403
COPY --from=pkg /usr/local/lib64/python3.*/site-packages/markupsafe /ovms/python_deps/markupsafe
392404

393405
COPY --from=pkg /licenses /licenses
406+
407+
# Setup Python Demos Environment
408+
COPY demos/python_demos/requirements.txt .
409+
RUN if [ -f /usr/bin/dnf ] ; then export DNF_TOOL=dnf ; \
410+
else export DNF_TOOL=microdnf ; fi ; \
411+
$DNF_TOOL install -y python3-pip git iproute net-tools ; $DNF_TOOL clean all ; \
412+
pip3 install --no-cache-dir -r requirements.txt ; \
413+
rm -f requirements.txt
414+
394415
USER ovms
395416
ENTRYPOINT ["/ovms/bin/ovms"]

openvino-lto.patch

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 2187deb8e8..ad15a73395 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -65,6 +65,7 @@ if(ENABLE_COVERAGE)
6+
include(cmake/coverage.cmake)
7+
endif()
8+
9+
+set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
10+
if(APPLE AND CMAKE_OSX_DEPLOYMENT_TARGET AND
11+
CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.15)
12+
message(FATAL_ERROR "OpenVINO requires MACOSX_DEPLOYMENT_TARGET at least 10.15, specified ${CMAKE_OSX_DEPLOYMENT_TARGET}")
13+
diff --git a/src/frontends/common/CMakeLists.txt b/src/frontends/common/CMakeLists.txt
14+
index e4d2fe63e1..eace2a5593 100644
15+
--- a/src/frontends/common/CMakeLists.txt
16+
+++ b/src/frontends/common/CMakeLists.txt
17+
@@ -52,7 +52,8 @@ target_link_libraries(${TARGET_NAME}_obj PRIVATE openvino::util openvino::core::
18+
19+
# TODO: fix lto
20+
set_target_properties(${TARGET_NAME}_obj PROPERTIES
21+
- INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF)
22+
+ INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
23+
+ov_add_compiler_flags(-march=haswell)
24+
25+
set(FRONTEND_LIB_SUFFIX "${FRONTEND_NAME_SUFFIX}${OV_BUILD_POSTFIX}")
26+
if(APPLE)
27+
--- a/thirdparty/onnx/CMakeLists.txt
28+
+++ b/thirdparty/onnx/CMakeLists.txt
29+
@@ -21,7 +21,10 @@ endif()
30+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
31+
# 4244 conversion from 'XXX' to 'YYY', possible loss of data
32+
ov_add_compiler_flags(/wd4244)
33+
+else()
34+
+ ov_add_compiler_flags(-march=haswell)
35+
endif()
36+
+set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
37+
38+
set(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}")
39+
set(ONNX_USE_PROTOBUF_SHARED_LIBS OFF CACHE BOOL "Use dynamic protobuf by ONNX library" FORCE)
40+
diff --git a/thirdparty/protobuf/CMakeLists.txt b/thirdparty/protobuf/CMakeLists.txt
41+
index a16bd56d11..2829926e68 100644
42+
--- a/thirdparty/protobuf/CMakeLists.txt
43+
+++ b/thirdparty/protobuf/CMakeLists.txt
44+
@@ -10,6 +10,7 @@ set(BUILD_SHARED_LIBS OFF)
45+
46+
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR (OV_COMPILER_IS_INTEL_LLVM AND UNIX))
47+
ov_add_compiler_flags(-Wno-all)
48+
+ ov_add_compiler_flags(-march=haswell)
49+
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11 AND CMAKE_COMPILER_IS_GNUCXX)
50+
ov_add_compiler_flags(-Wno-stringop-overflow)
51+
endif()
52+
@@ -48,6 +49,7 @@ else()
53+
set(protobuf_dir protobuf/cmake)
54+
endif()
55+
56+
+set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
57+
add_subdirectory(${protobuf_dir} EXCLUDE_FROM_ALL)
58+
get_directory_property(protobuf_VERSION DIRECTORY ${protobuf_dir} DEFINITION protobuf_VERSION)
59+
60+
@@ -63,7 +65,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR OV_COMPILER_IS_INTEL_LLVM
61+
CXX_VISIBILITY_PRESET default
62+
C_VISIBILITY_PRESET default
63+
VISIBILITY_INLINES_HIDDEN OFF
64+
- INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF)
65+
+ INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
66+
endif()
67+
ov_disable_all_warnings(${_protoc_libs} libprotobuf-lite)
68+
set_target_properties(libprotobuf-lite PROPERTIES

third_party/opencv/opencv_cmake_flags.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-D BUILD_LIST=core,improc,imgcodecs,calib3d,features2d,highgui,imgproc,video,videoio,optflow \
22
-D OPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib_repo/modules \
33
-D CMAKE_BUILD_TYPE=Release \
4+
-D ENABLE_LTO=${LTO_ENABLE} \
45
-D CMAKE_INSTALL_PREFIX=/opt/opencv \
56
-D OPENCV_LIB_INSTALL_PATH=lib \
67
-D BUILD_TESTS=OFF \
@@ -39,4 +40,4 @@
3940
-D WITH_JPEG=ON \
4041
-D WITH_PNG=ON \
4142
-D WITH_TIFF=OFF \
42-
-D WITH_OPENEXR=OFF
43+
-D WITH_OPENEXR=OFF

0 commit comments

Comments
 (0)