Skip to content

Commit 3209c50

Browse files
authored
Ovms windows3 (#2747)
* Windows enabling
1 parent 7b75da2 commit 3209c50

File tree

87 files changed

+1881
-536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1881
-536
lines changed

.bazelrc

+170-11
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ build --define=MEDIAPIPE_DISABLE_GPU=1
5151

5252
build --define=MEDIAPIPE_DISABLE=0
5353

54+
build --define=CLOUD_DISABLE=0
55+
coverage --define=CLOUD_DISABLE=0
56+
test --define=CLOUD_DISABLE=0
57+
5458
build --define=PYTHON_DISABLE=0
5559

5660
# sometimes failed logs exceed this threshold
@@ -66,26 +70,38 @@ build --copt=-DGRPC_BAZEL_BUILD
6670
build --copt=-O2
6771

6872
# LLVM, MLIR and TF require C++14, we use C++17 in project
69-
build --cxxopt=-std=c++17
70-
build --host_cxxopt=-std=c++17
73+
build:linux --cxxopt=-std=c++17
74+
build:linux --host_cxxopt=-std=c++17
75+
76+
build:windows --host_cxxopt=/std:c++17
77+
build:windows --cxxopt=/std:c++17
78+
build:windows --action_env BAZEL_CXXOPTS="/std:c++17"
79+
80+
# Fixing compiler errors:
81+
#build:windows --cxxopt=/translateInclude=no
82+
build:windows --enable_platform_specific_config
7183

7284
# Security options
73-
build --cxxopt=-fno-strict-overflow
74-
build --cxxopt=-fno-delete-null-pointer-checks
75-
build --cxxopt=-fwrapv
76-
build --cxxopt=-fstack-protector
77-
build --cxxopt=-fstack-clash-protection
78-
build --cxxopt=-Wformat
79-
build --cxxopt=-Wformat-security
80-
build --cxxopt=-Werror=format-security
85+
# TODO: Add equivalent windows flag
86+
build:linux --cxxopt=-fno-strict-overflow
87+
build:linux --cxxopt=-fno-delete-null-pointer-checks
88+
build:linux --cxxopt=-fwrapv
89+
build:linux --cxxopt=-fstack-protector
90+
build:linux --cxxopt=-fstack-clash-protection
91+
build:linux --cxxopt=-Wformat
92+
build:linux --cxxopt=-Wformat-security
93+
build:linux --cxxopt=-Werror=format-security
8194

8295
# Adding "--cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0" creates parity with TF
8396
# compilation options. It also addresses memory use due to
8497
# copy-on-write semantics of std::strings of the older ABI.
8598
build --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=1
8699

100+
# TODO Windows: may impact python nodes execution
101+
build:windows --noenable_bzlmod
87102
build --experimental_repo_remote_exec
88-
build --force_pic
103+
# TODO: Add equivalent windows flag
104+
build:linux --force_pic
89105
build --experimental_cc_shared_library
90106

91107
build --check_visibility=true
@@ -96,4 +112,147 @@ build --cxxopt=-DOVMS_DUMP_TO_FILE=0
96112
# envs below are required to succesfully run binaries in bazel as bazel is
97113
# very strict in sandboxing
98114
test --test_env PYTHONPATH=/opt/intel/openvino/python:/ovms/bazel-bin/src/python/binding
115+
116+
# TF bazelrc settings
117+
# TensorFlow Bazel configuration file.
118+
119+
build:windows --define framework_shared_object=true
120+
build:windows --define tsl_protobuf_header_only=true
121+
122+
build:windows --define=use_fast_cpp_protos=true
123+
build:windows --define=allow_oversize_protos=true
124+
125+
build:windows --spawn_strategy=standalone
126+
build:windows -c opt
127+
128+
# Make Bazel print out all options from rc files.
129+
build:windows --announce_rc
130+
131+
# TODO(mihaimaruseac): Document this option or remove if no longer needed
132+
build:windows --define=grpc_no_ares=true
133+
134+
135+
build:windows --noincompatible_remove_legacy_whole_archive
136+
build:windows --features=-force_no_whole_archive
137+
138+
# TODO(mihaimaruseac): Document this option or remove if no longer needed
139+
build:windows --enable_platform_specific_config
140+
141+
# Enable XLA support by default.
142+
build:windows --define=with_xla_support=true
143+
144+
# TODO(mihaimaruseac): Document this option or remove if no longer needed
145+
build:windows --config=short_logs
146+
147+
# TODO(mihaimaruseac): Document this option or remove if no longer needed
148+
build:windows --config=v2
149+
150+
# Disable AWS/HDFS support by default
151+
build:windows --define=no_aws_support=true
152+
build:windows --define=no_hdfs_support=true
153+
154+
# cc_shared_library ensures no library is linked statically more than once.
155+
build:windows --experimental_link_static_libraries_once=false
156+
157+
# Prevent regressions on those two incompatible changes
158+
# TODO: remove those flags when they are flipped in the default Bazel version TF uses.
159+
build:windows --incompatible_enforce_config_setting_visibility
160+
161+
# Config to use a mostly-static build and disable modular op registration
162+
# support (this will revert to loading TensorFlow with RTLD_GLOBAL in Python).
163+
# By default, TensorFlow will build with a dependence on
164+
# //tensorflow:libtensorflow_framework.so.
165+
build:monolithic --define framework_shared_object=false
166+
build:monolithic --define tsl_protobuf_header_only=false
167+
build:monolithic --experimental_link_static_libraries_once=false # b/229868128
168+
169+
build:windows --copt=/W0
170+
build:windows --host_copt=/W0
171+
172+
# On Windows, `__cplusplus` is wrongly defined without this switch
173+
# See https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
174+
build:windows --copt=/Zc:__cplusplus
175+
build:windows --host_copt=/Zc:__cplusplus
176+
177+
# Tensorflow uses M_* math constants that only get defined by MSVC headers if
178+
# _USE_MATH_DEFINES is defined.
179+
build:windows --copt=/D_USE_MATH_DEFINES
180+
build:windows --host_copt=/D_USE_MATH_DEFINES
181+
182+
# Windows has a relatively short command line limit, which TF has begun to hit.
183+
# See https://docs.bazel.build/versions/main/windows.html
184+
build:windows --features=compiler_param_file
185+
build:windows --features=archive_param_file
186+
187+
# Speed Windows compile times. Available in VS 16.4 (we are on 16.11). See
188+
# https://groups.google.com/a/tensorflow.org/d/topic/build/SsW98Eo7l3o/discussion
189+
build:windows --copt=/d2ReducedOptimizeHugeFunctions
190+
build:windows --host_copt=/d2ReducedOptimizeHugeFunctions
191+
192+
build:windows --cxxopt=/std:c++17
193+
build:windows --host_cxxopt=/std:c++17
194+
195+
# On windows, we still link everything into a single DLL.
196+
build:windows --config=monolithic
197+
198+
# Make sure to include as little of windows.h as possible
199+
build:windows --copt=-DWIN32_LEAN_AND_MEAN
200+
build:windows --host_copt=-DWIN32_LEAN_AND_MEAN
201+
build:windows --copt=-DNOGDI
202+
build:windows --host_copt=-DNOGDI
203+
204+
# MSVC (Windows): Standards-conformant preprocessor mode
205+
# See https://docs.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview
206+
build:windows --copt=/Zc:preprocessor
207+
build:windows --host_copt=/Zc:preprocessor
208+
209+
# Misc build options we need for windows.
210+
build:windows --linkopt=/DEBUG
211+
build:windows --host_linkopt=/DEBUG
212+
build:windows --linkopt=/OPT:REF
213+
build:windows --host_linkopt=/OPT:REF
214+
build:windows --linkopt=/OPT:ICF
215+
build:windows --host_linkopt=/OPT:ICF
216+
217+
# Verbose failure logs when something goes wrong
218+
build:windows --verbose_failures
219+
220+
# Work around potential issues with large command lines on windows.
221+
# See: https://github.com/bazelbuild/bazel/issues/5163
222+
build:windows --features=compiler_param_file
223+
224+
# Configure short or long logs
225+
build:short_logs --output_filter=DONT_MATCH_ANYTHING
226+
build:verbose_logs --output_filter=
227+
228+
build:avx_win --copt=/arch=AVX
229+
build:avx2_win --copt=/arch=AVX2
230+
231+
# Options to build TensorFlow 1.x or 2.x.
232+
build:v1 --define=tf_api_version=1 --action_env=TF2_BEHAVIOR=0
233+
build:v2 --define=tf_api_version=2 --action_env=TF2_BEHAVIOR=1
234+
235+
# Flag to enable remote config
236+
build:windows --experimental_repo_remote_exec
237+
238+
# Config-specific options should come above this line.
239+
240+
# Load rc file written by ./configure.
241+
# try-import %workspace%/.tf_configure.bazelrc
242+
build:windows --action_env PYTHON_BIN_PATH="C:/opt/Python39/python.exe"
243+
build:windows --action_env PYTHON_LIB_PATH="C:/opt/Python39/lib/site-packages"
244+
build:windows --python_path="C:/opt/Python39/python.exe"
245+
build:windows:opt --copt=/arch:AVX
246+
build:windows:opt --host_copt=/arch:AVX
247+
build:windows --define=override_eigen_strong_inline=true
248+
249+
# Load rc file with user-specific options.
250+
try-import %workspace%/.bazelrc.user
251+
252+
# Disable TFRT integration for now unless --config=tfrt is specified.
253+
build:windows --deleted_packages=tensorflow/core/tfrt/stubs,tensorflow/compiler/mlir/tfrt,tensorflow/compiler/mlir/tfrt/benchmarks,tensorflow/compiler/mlir/tfrt/ir,tensorflow/compiler/mlir/tfrt/ir/mlrt,tensorflow/compiler/mlir/tfrt/jit/python_binding,tensorflow/compiler/mlir/tfrt/jit/transforms,tensorflow/compiler/mlir/tfrt/python_tests,tensorflow/compiler/mlir/tfrt/tests,tensorflow/compiler/mlir/tfrt/tests/mlrt,tensorflow/compiler/mlir/tfrt/tests/ir,tensorflow/compiler/mlir/tfrt/tests/analysis,tensorflow/compiler/mlir/tfrt/tests/jit,tensorflow/compiler/mlir/tfrt/tests/lhlo_to_tfrt,tensorflow/compiler/mlir/tfrt/tests/lhlo_to_jitrt,tensorflow/compiler/mlir/tfrt/tests/tf_to_corert,tensorflow/compiler/mlir/tfrt/tests/tf_to_tfrt_data,tensorflow/compiler/mlir/tfrt/tests/saved_model,tensorflow/compiler/mlir/tfrt/transforms/lhlo_gpu_to_tfrt_gpu,tensorflow/compiler/mlir/tfrt/transforms/mlrt,tensorflow/core/runtime_fallback,tensorflow/core/runtime_fallback/conversion,tensorflow/core/runtime_fallback/kernel,tensorflow/core/runtime_fallback/opdefs,tensorflow/core/runtime_fallback/runtime,tensorflow/core/runtime_fallback/util,tensorflow/core/tfrt/mlrt,tensorflow/core/tfrt/mlrt/attribute,tensorflow/core/tfrt/mlrt/kernel,tensorflow/core/tfrt/mlrt/bytecode,tensorflow/core/tfrt/mlrt/interpreter,tensorflow/compiler/mlir/tfrt/translate/mlrt,tensorflow/compiler/mlir/tfrt/translate/mlrt/testdata,tensorflow/core/tfrt/gpu,tensorflow/core/tfrt/run_handler_thread_pool,tensorflow/core/tfrt/runtime,tensorflow/core/tfrt/saved_model,tensorflow/core/tfrt/graph_executor,tensorflow/core/tfrt/saved_model/tests,tensorflow/core/tfrt/tpu,tensorflow/core/tfrt/utils,tensorflow/core/tfrt/utils/debug,tensorflow/core/tfrt/saved_model/python,tensorflow/core/tfrt/graph_executor/python
254+
255+
# Windows build ssl headers for GRPC workaround
256+
build:windows --override_repository="boringssl=C:\\opt\\boringSSL-SwiftPM"
257+
99258
test --test_env LD_LIBRARY_PATH=/opt/opencv/lib/:/opt/intel/openvino/runtime/lib/intel64/:/opt/intel/openvino/runtime/3rdparty/tbb/lib/

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@ cppclean_test
2626
tags
2727
.venv-style/
2828
src/test/llm_testing
29+
node_modules/
30+
yarn.*
31+
bazel-openvino-model-server/
32+
bazel-model_server/
2933
out

BUILD.bazel

+20-11
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ exports_files([
2424
load("@bazel_skylib//lib:selects.bzl", "selects")
2525
load("@mediapipe//mediapipe/framework:more_selects.bzl", "more_selects")
2626
load("//:common_settings.bzl",
27-
"COMMON_STATIC_LIBS_COPTS", "COMMON_STATIC_LIBS_LINKOPTS", "COMMON_FUZZER_COPTS", "COMMON_FUZZER_LINKOPTS", "COMMON_LOCAL_DEFINES",
27+
"COMMON_STATIC_LIBS_COPTS_VISIBLE", "COMMON_STATIC_LIBS_COPTS", "COMMON_STATIC_LIBS_LINKOPTS", "COMMON_FUZZER_COPTS", "COMMON_FUZZER_LINKOPTS", "COMMON_LOCAL_DEFINES",
2828
"create_config_settings")
2929
create_config_settings()
3030

31-
#To build without python use flags - bazel build --define PYTHON_DISABLE=1 --cxxopt=-DPYTHON_DISABLE=1 //src:ovms
31+
#To build without python use flags - bazel build --config=linux --define PYTHON_DISABLE=1 --cxxopt=-DPYTHON_DISABLE=1 //src:ovms
3232

3333
cc_library(
3434
name = "ovms_dependencies",
@@ -41,20 +41,23 @@ cc_library(
4141
"@org_tensorflow//tensorflow/core:framework",
4242
"@com_github_gabime_spdlog//:spdlog",
4343
"@com_github_jarro2783_cxxopts//:cxxopts",
44-
"@aws-sdk-cpp//:aws-sdk-cpp",
45-
"@aws-sdk-cpp//:aws-sdk-cpp_cmake",
46-
"@azure//:storage",
47-
"@cpprest//:sdk",
48-
"@boost//:lib",
49-
"@com_github_googleapis_google_cloud_cpp//google/cloud/storage:storage_client",
50-
"@tensorflow_serving//tensorflow_serving/util/net_http/server/public:http_server",
5144
"@tensorflow_serving//tensorflow_serving/util/net_http/server/public:http_server_api",
5245
"@tensorflow_serving//tensorflow_serving/util:threadpool_executor",
5346
"@tensorflow_serving//tensorflow_serving/util:json_tensor",
54-
"@linux_openvino//:openvino",
55-
"@linux_opencv//:opencv",
47+
"//third_party:openvino",
48+
"//third_party:opencv",
5649
"@com_github_jupp0r_prometheus_cpp//core",
5750
] + select({
51+
"//:not_disable_cloud": [
52+
"@aws-sdk-cpp//:aws-sdk-cpp",
53+
"@aws-sdk-cpp//:aws-sdk-cpp_cmake",
54+
"@azure//:storage",
55+
"@cpprest//:sdk",
56+
"//third_party:boost",
57+
"@com_github_googleapis_google_cloud_cpp//google/cloud/storage:storage_client",],
58+
"//:disable_cloud": []
59+
})
60+
+ select({
5861
"//:not_disable_mediapipe": [
5962
"@mediapipe//mediapipe/framework:calculator_framework",
6063
"@mediapipe//mediapipe/framework/stream_handler:barrier_input_stream_handler",
@@ -78,6 +81,12 @@ cc_library(
7881
"@pybind11//:pybind11_embed",
7982
],
8083
"//:disable_python": []
84+
})
85+
+ select({
86+
"//conditions:default": [
87+
"@tensorflow_serving//tensorflow_serving/util/net_http/server/public:http_server",
88+
],
89+
"//src:windows" : [],
8190
}),
8291
visibility = ["//visibility:public"],
8392
)

Dockerfile.redhat

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ ARG ov_use_binary=0
175175
ARG DLDT_PACKAGE_URL
176176
ARG TEMP_DIR=/tmp/openvino_installer
177177
ARG CMAKE_BUILD_TYPE=Release
178-
ARG debug_bazel_flags="--strip=always --define MEDIAPIPE_DISABLE=0 --define PYTHON_DISABLE=0 --//:distro=redhat"
178+
ARG debug_bazel_flags="--config=linux --strip=always --define MEDIAPIPE_DISABLE=0 --define PYTHON_DISABLE=0 --//:distro=redhat"
179179

180180
# hadolint ignore=DL3003
181181
RUN if [[ "$NVIDIA" == "1" ]] ; then true ; else exit 0 ; fi ; git clone https://github.com/$ov_contrib_org/openvino_contrib.git /openvino_contrib && cd /openvino_contrib && git checkout $ov_contrib_branch && git submodule update --init --recursive
@@ -352,7 +352,7 @@ RUN rm -Rf /etc/entitlement /etc/rhsm/ca
352352

353353
FROM $BUILD_IMAGE as capi-build
354354
# C api shared library
355-
ARG CAPI_FLAGS="--strip=always --define MEDIAPIPE_DISABLE=1 --define PYTHON_DISABLE=1 --//:distro=redhat"
355+
ARG CAPI_FLAGS="--config=linux --strip=always --define MEDIAPIPE_DISABLE=1 --define PYTHON_DISABLE=1 --//:distro=redhat"
356356
ARG JOBS=40
357357
RUN bazel build --jobs $JOBS ${CAPI_FLAGS} //src:ovms_shared
358358

Dockerfile.ubuntu

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ ARG BASE_IMAGE
9595
ENV DEBIAN_FRONTEND=noninteractive
9696
SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
9797

98-
ARG debug_bazel_flags="--strip=always --define MEDIAPIPE_DISABLE=0 --define PYTHON_DISABLE=0 --//:distro=ubuntu"
98+
ARG debug_bazel_flags="--config=linux --strip=always --define MEDIAPIPE_DISABLE=0 --define PYTHON_DISABLE=0 --//:distro=ubuntu"
9999

100100
RUN apt-get update && apt-get install --no-install-recommends -y \
101101
libgflags-dev \
@@ -356,7 +356,7 @@ FROM $BUILD_IMAGE as capi-build
356356
SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
357357
# C api shared library
358358
# hadolint ignore=DL3059
359-
ARG CAPI_FLAGS="--strip=always --define MEDIAPIPE_DISABLE=1 --define PYTHON_DISABLE=1 --//:distro=ubuntu"
359+
ARG CAPI_FLAGS="--config=linux --strip=always --define MEDIAPIPE_DISABLE=1 --define PYTHON_DISABLE=1 --//:distro=ubuntu"
360360
ARG JOBS=40
361361
ARG FUZZER_BUILD=0
362362
RUN bazel build --jobs=$JOBS ${CAPI_FLAGS} //src:ovms_shared

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ else ifeq ($(findstring redhat,$(BASE_OS)),redhat)
135135
else
136136
$(error BASE_OS must be either ubuntu or redhat)
137137
endif
138-
CAPI_FLAGS = "--strip=$(STRIP)"$(BAZEL_DEBUG_BUILD_FLAGS)" --define MEDIAPIPE_DISABLE=1 --define PYTHON_DISABLE=1"$(OV_TRACING_PARAMS)$(TARGET_DISTRO_PARAMS)
139-
BAZEL_DEBUG_FLAGS="--strip=$(STRIP)"$(BAZEL_DEBUG_BUILD_FLAGS)$(DISABLE_MEDIAPIPE_PARAMS)$(DISABLE_PYTHON_PARAMS)$(FUZZER_BUILD_PARAMS)$(OV_TRACING_PARAMS)$(TARGET_DISTRO_PARAMS)
138+
CAPI_FLAGS = "--config=linux --strip=$(STRIP)"$(BAZEL_DEBUG_BUILD_FLAGS)" --define MEDIAPIPE_DISABLE=1 --define PYTHON_DISABLE=1"$(OV_TRACING_PARAMS)$(TARGET_DISTRO_PARAMS)
139+
BAZEL_DEBUG_FLAGS="--config=linux --strip=$(STRIP)"$(BAZEL_DEBUG_BUILD_FLAGS)$(DISABLE_MEDIAPIPE_PARAMS)$(DISABLE_PYTHON_PARAMS)$(FUZZER_BUILD_PARAMS)$(OV_TRACING_PARAMS)$(TARGET_DISTRO_PARAMS)
140140

141141
# Option to Override release image.
142142
# Release image OS *must have* glibc version >= glibc version on BASE_OS:

0 commit comments

Comments
 (0)