forked from openvinotoolkit/model_server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.ubuntu
549 lines (475 loc) · 28.8 KB
/
Dockerfile.ubuntu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
#
# Copyright (c) 2021 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.
#
ARG BASE_IMAGE
ARG BUILD_IMAGE=build
ARG PKG_IMAGE=pkg
FROM $BASE_IMAGE as base_build
LABEL version="1.0.0"
SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
ARG JOBS=8
ENV DEBIAN_FRONTEND=noninteractive
ARG BASE_IMAGE
ENV BASE_IMAGE=${BASE_IMAGE}
RUN apt-get update && apt-get install --no-install-recommends -y \
build-essential \
gcc-9 \
g++-9 \
make \
cmake \
automake \
autoconf \
curl \
ca-certificates \
git \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
patch \
pkg-config \
wget \
zlib1g-dev && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
####### Azure SDK needs new boost:
WORKDIR /boost
# hadolint ignore=DL3003
RUN wget -nv https://boostorg.jfrog.io/artifactory/main/release/1.69.0/source/boost_1_69_0.tar.gz && \
tar xf boost_1_69_0.tar.gz && cd boost_1_69_0 && ./bootstrap.sh && \
sed -i -e 's|#if PTHREAD_STACK_MIN > 0|#ifdef PTHREAD_STACK_MIN|g' boost/thread/pthread/thread_data.hpp && \
# fix for compiler >=9.5 https://github.com/boostorg/thread/pull/297/files
./b2 -j ${JOBS} cxxstd=17 link=static cxxflags='-fPIC' cflags='-fPIC' \
--with-chrono --with-date_time --with-filesystem --with-program_options --with-system \
--with-random --with-thread --with-atomic --with-regex \
--with-log --with-locale \
install
COPY third_party /ovms/third_party/
####### Azure SDK
WORKDIR /azure
RUN apt-get update && apt-get install --no-install-recommends -y uuid uuid-dev && rm -rf /var/lib/apt/lists/*
RUN git clone --recurse-submodules --depth 1 --branch v2.10.16 https://github.com/Microsoft/cpprestsdk.git && \
git clone --depth 1 --branch v7.5.0 https://github.com/Azure/azure-storage-cpp.git && \
patch -d /azure/cpprestsdk/ -p1 < /ovms/third_party/cpprest/rest_sdk_v2.10.16.patch && \
patch -d /azure/azure-storage-cpp/ -p1 </ovms/third_party/azure/azure_sdk.patch
WORKDIR /azure/cpprestsdk/Release/build.release
RUN cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -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
WORKDIR /azure/azure-storage-cpp/Microsoft.WindowsAzure.Storage/build.release
RUN CASABLANCA_DIR=/azure/cpprestsdk cmake .. -DCMAKE_CXX_FLAGS="-fPIC -Wno-error=deprecated-declarations" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBoost_USE_STATIC_RUNTIME=ON -DBoost_USE_STATIC_LIBS=ON -DCMAKE_VERBOSE_MAKEFILE=ON && make --jobs=$JOBS && make --jobs=$JOBS install
# no-error flag related to https://github.com/aws/aws-sdk-cpp/issues/1582
####### End of Azure SDK
# Build AWS S3 SDK
RUN git clone https://github.com/aws/aws-sdk-cpp.git --branch 1.7.129 --single-branch --depth 1 /awssdk
WORKDIR /awssdk/build
RUN cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY=s3 -DENABLE_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DMINIMIZE_SIZE=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DFORCE_SHARED_CRT=OFF -DSIMPLE_INSTALL=OFF -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=1 -Wno-error=deprecated-declarations -Wuninitialized" .. && make --jobs=$JOBS
####### End of AWS S3 SDK
####### Build OpenCV
WORKDIR /ovms/third_party/opencv
RUN ./install_opencv.sh
####### End of OpenCV
################### BASE BUILD ##########################
FROM base_build as build
ARG BASE_IMAGE
ENV DEBIAN_FRONTEND=noninteractive
ENV BASE_IMAGE=${BASE_IMAGE}
SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
RUN apt-get update && apt-get install --no-install-recommends -y \
libgflags-dev \
bc \
default-jdk \
lcov \
libpugixml1v5 \
libusb-dev \
libusb-1.0-0-dev \
libtool \
libnuma-dev \
libtbb2 \
libssl-dev \
nlohmann-json3-dev \
python2 \
python2-dev \
python3-dev \
python3-pip \
unzip \
gdb \
vim \
xz-utils && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Python <3.10 needed to build TFS in current version
RUN if [ "$BASE_IMAGE" == "ubuntu:22.04" ] ; then \
apt-get update && apt-get install -y software-properties-common gpg gpg-agent --no-install-recommends && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get install -y python3.8 python3.8-dev python3.8-distutils --no-install-recommends && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 ; \
fi ; \
python3 -m pip install numpy==1.21.0 --no-cache-dir
ARG JOBS
ARG ov_use_binary=0
ARG sentencepiece=1
ARG ov_source_org=openvinotoolkit
ARG ov_contrib_org=openvinotoolkit
ARG DLDT_PACKAGE_URL
ARG ov_source_branch=master
ARG ov_contrib_branch=master
ARG APT_OV_PACKAGE=openvino-2022.1.0
ARG CMAKE_BUILD_TYPE=Release
ENV HDDL_INSTALL_DIR=/opt/intel/openvino/deployment_tools/inference_engine/external/hddl
ENV TF_SYSTEM_LIBS="curl"
ENV TEST_LOG="/root/.cache/bazel/_bazel_root/bc57d4817a53cab8c785464da57d1983/execroot/ovms/bazel-out/test.log"
ARG NVIDIA=0
# hadolint ignore=DL3003
RUN if [[ "$sentencepiece" == "1" || "$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
################### BUILD OPENVINO FROM SOURCE - buildarg ov_use_binary=0 ############################
# Build OpenVINO and nGraph (OV dependency) with D_GLIBCXX_USE_CXX11_ABI=0 or 1
# hadolint ignore=DL3003
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
WORKDIR /openvino/build
RUN if [ "$ov_use_binary" == "0" ] ; then true ; else exit 0 ; fi ; cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DENABLE_SAMPLES=0 -DNGRAPH_USE_CXX_ABI=1 -DCMAKE_CXX_FLAGS=" -D_GLIBCXX_USE_CXX11_ABI=1 -Wno-error=parentheses " ..
RUN if [ "$ov_use_binary" == "0" ] ; then true ; else exit 0 ; fi ; make --jobs=$JOBS
RUN if [ "$ov_use_binary" == "0" ] ; then true ; else exit 0 ; fi ; make install
RUN if [ "$ov_use_binary" == "0" ] ; then true ; else exit 0 ; fi ; \
mkdir -p /opt/intel/openvino/extras && \
mkdir -p /opt/intel/openvino && \
ln -s /openvino/inference-engine/temp/opencv_*_ubuntu20/opencv /opt/intel/openvino/extras && \
ln -s /usr/local/runtime /opt/intel/openvino && \
ln -s /openvino/scripts/setupvars/setupvars.sh /opt/intel/openvino/setupvars.sh && \
ln -s /opt/intel/openvino /opt/intel/openvino_2023
################## END OF OPENVINO SOURCE BUILD ######################
ARG TEMP_DIR=/tmp/openvino_installer
################### TAKE OPENVINO FROM A BINARY RELEASE - buildarg ov_use_binary=1 (DEFAULT) ##########
WORKDIR $TEMP_DIR
# OV toolkit package
#RUN if [ "$ov_use_binary" = "1" ] && [ "$DLDT_PACKAGE_URL" != "" ]; then true ; else exit 0 ; fi ; mkdir -p $TEMP_DIR && cd $TEMP_DIR/ && \
# wget $DLDT_PACKAGE_URL && \
# chmod 755 l_openvino_toolkit_* && \
# ./l_openvino_toolkit_* -a -s --eula accept && \
# rm -rf /opt/intel/openvino && \
# ln -s /opt/intel/openvino_2023 /opt/intel/openvino
# OV toolkit package
RUN if [ "$ov_use_binary" == "1" ] && [ "$DLDT_PACKAGE_URL" != "" ]; then true ; else exit 0 ; fi ; \
wget -nv $DLDT_PACKAGE_URL && \
mkdir /opt/intel && \
tar -zxf l_openvino_toolkit*.tgz -C /opt/intel && \
ln -s /opt/intel/l_openvino_toolkit* /opt/intel/openvino && \
ln -s /opt/intel/l_openvino_toolkit* /opt/intel/openvino_2023
WORKDIR /
# apt package
RUN if [ "$ov_use_binary" = "1" ] && [ "$DLDT_PACKAGE_URL" = "" ] ; then true ; else exit 0 ; fi ; \
echo "installing apt package" && \
wget -nv https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && \
apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && \
echo "deb https://apt.repos.intel.com/openvino/2022 focal main" | tee /etc/apt/sources.list.d/intel-openvino-2022.list && \
apt-get update && \
apt-get install --no-install-recommends -y $APT_OV_PACKAGE && \
rm -rf /var/lib/apt/lists/* && \
ln -s /opt/intel/openvino_2023 /opt/intel/openvino
RUN wget -nv https://github.com/oneapi-src/oneTBB/releases/download/v2021.9.0/oneapi-tbb-2021.9.0-lin.tgz && \
tar -xzf oneapi-tbb-2021.9.0-lin.tgz && \
cp -P oneapi-tbb-2021.9.0/lib/intel64/gcc4.8/libtbb.so* /opt/intel/openvino/runtime/lib/intel64/
# install sample apps including benchmark_app
RUN if [ -f /opt/intel/openvino/samples/cpp/build_samples.sh ]; then /opt/intel/openvino/samples/cpp/build_samples.sh ; fi
#################### END OF OPENVINO BINARY INSTALL
# SENTENCEPIECE_EXTENSION
ENV OpenVINO_DIR=/opt/intel/openvino/runtime/cmake
WORKDIR /openvino_contrib/modules/custom_operations/user_ie_extensions
RUN if [ "$sentencepiece" == "1" ] ; then true ; else exit 0 ; fi ; cmake .. -DCMAKE_BUILD_TYPE=Release -DCUSTOM_OPERATIONS="sentence_piece" && cmake --build . --parallel $JOBS
# NVIDIA
ENV OPENVINO_BUILD_PATH=/cuda_plugin_build
ENV OPENVINO_HOME=/openvino
ENV OPENVINO_CONTRIB=/openvino_contrib
# Add Nvidia dev tool if needed
# hadolint ignore=DL3003
RUN if [ "$NVIDIA" == "1" ] ; then true ; else exit 0 ; fi ; \
wget -nv https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin -O /etc/apt/preferences.d/cuda-repository-pin-600 ; \
set -exuo pipefail ; \
rm -f /etc/apt/apt.conf.d/docker-clean ; \
if [[ ${enable_tensorrt-} == "1" ]] ; then dpkg -i /nv-tensorrt-repo-*.deb ; fi; \
apt-get update && apt-get install --no-install-recommends -y \
libzstd-dev \
libcudnn8=8.8.0.121-1+cuda11.8 \
libcudnn8-dev=8.8.0.121-1+cuda11.8 \
libcutensor1=1.6.1.5-1 \
libcutensor-dev=1.6.1.5-1 && \
apt-get install --no-install-recommends -y cuda-11-8 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
pip3 install --no-cache-dir cython && \
curl -L https://github.com/Kitware/ninja/releases/download/v1.10.0.gfb670.kitware.jobserver-1/ninja-1.10.0.gfb670.kitware.jobserver-1_x86_64-linux-gnu.tar.gz | tar xzv --strip-components=1 -C /usr/local/bin ; \
curl https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz -L | tar xvzC /usr/local/bin --strip-components=1 --wildcards '*/sccache' ; \
chmod a+x /usr/local/bin/sccache ;
# hadolint ignore=DL3003
RUN if [ "$NVIDIA" == "1" ] ; then true ; else exit 0 ; fi ; \
mkdir ${OPENVINO_BUILD_PATH} && \
cd "${OPENVINO_BUILD_PATH}" && \
cmake "${OPENVINO_HOME}" \
-DENABLE_NVIDIA=ON \
-DENABLE_TESTS=ON \
-DBUILD_arm_plugin=OFF \
-DBUILD_java_api=OFF \
-DBUILD_custom_operations=OFF \
-DBUILD_mo_pytorch=OFF \
-DBUILD_optimum=OFF \
-DBUILD_ovms_ai_extension=OFF \
-DOPENVINO_EXTRA_MODULES="${OPENVINO_CONTRIB}/modules" \
-DWHEEL_VERSION=2022.1.0 \
-DVERBOSE_BUILD=ON \
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE && \
cmake --build "${OPENVINO_BUILD_PATH}" --target openvino_nvidia_gpu_plugin -j $JOBS && \
cp /openvino/bin/intel64/Release/libopenvino_nvidia_gpu_plugin.so /opt/intel/openvino/runtime/lib/intel64 && \
echo '<ie><plugins><plugin location="libopenvino_nvidia_gpu_plugin.so" name="NVIDIA"></plugin></plugins></ie>' > /opt/intel/openvino/runtime/lib/intel64/plugins.xml
# Set up Bazel
ENV BAZEL_VERSION 6.0.0
WORKDIR /bazel
RUN curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -o /bazel/LICENSE.txt https://raw.githubusercontent.com/bazelbuild/bazel/master/LICENSE && \
chmod +x bazel-*.sh && \
./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
# Build OpenVINO Model Server
WORKDIR /ovms
COPY .bazelrc WORKSPACE /ovms/
COPY external /ovms/external/
# This path is required for namespace to setup Python dependencies for testing the binding
COPY src/BUILD /ovms/src/BUILD
COPY src/bindings/python/tests/requirements.txt /ovms/src/bindings/python/tests/requirements.txt
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/intel/openvino/runtime/lib/intel64/:/opt/opencv/lib/
ARG debug_bazel_flags=--strip=never\ --copt="-g "\ -c\ dbg
RUN bazel build --jobs=$JOBS ${debug_bazel_flags} @org_tensorflow//tensorflow/core:framework
# FROM BASE BUILD
COPY --from=base_build /opt/opencv /opt/opencv/
COPY third_party /ovms/third_party/
# Mediapipe
COPY BUILD.bazel /ovms/
COPY yarn.lock /ovms/
COPY package.json /ovms/
# prebuild dependencies before copying sources
RUN bazel build --jobs=$JOBS ${debug_bazel_flags} //:ovms_dependencies
# Copy example clients into build image for static analysis
WORKDIR /example_cpp_client
COPY demos/common/cpp /example_cpp_client/cpp
COPY demos/benchmark/cpp/synthetic_client_async_benchmark.cpp demos/image_classification/cpp/*.cpp /example_cpp_client/cpp/src/
COPY src/ /ovms/src/
# Compile tokenizer custom node
WORKDIR /ovms/src/custom_nodes/tokenizer/build
RUN cp /ovms/src/custom_node_interface.h /ovms/src/custom_nodes/tokenizer/ && \
cp -r /ovms/src/custom_nodes/common /ovms/src/custom_nodes/tokenizer/ && \
cmake -DWITH_TESTS=1 .. && \
make -j${JOBS} && \
./test/detokenization_test && \
./test/tokenization_test
# Sample CPU Extension
WORKDIR /ovms/src/example/SampleCpuExtension/
RUN make
RUN if ! [[ $debug_bazel_flags == *"PYTHON_DISABLE=1"* ]]; then true ; else exit 0 ; fi ; \
mkdir -p /opt/intel/openvino/python/openvino-2023.2.dist-info && \
echo $'Metadata-Version: 1.0\nName: openvino\nVersion: 2023.2' > /opt/intel/openvino/python/openvino-2023.2.dist-info/METADATA
WORKDIR /ovms
ARG PROJECT_VERSION="2023.2"
ARG PROJECT_NAME="OpenVINO Model Server"
LABEL description=${PROJECT_NAME}
ARG minitrace_flags
ENV PYTHONPATH=/opt/intel/openvino/python:/ovms/bazel-bin/src
# Set OVMS version strings
RUN bash -c "sed -i -e 's|REPLACE_PROJECT_NAME|${PROJECT_NAME}|g' /ovms/src/version.hpp" && \
bash -c "sed -i -e 's|REPLACE_PROJECT_VERSION|${PROJECT_VERSION}|g' /ovms/src/version.hpp" && \
if [ "$ov_use_binary" == "1" ] ; then sed -i -e "s#REPLACE_OPENVINO_NAME#$(find /opt/intel/ -maxdepth 1 -mindepth 1 -type d | grep openvino | grep -Eo '[0-9]{4}.[0-9].[0-9].[0-9]+.[^_]+')#g" /ovms/src/version.hpp ; fi && \
if [ "$ov_use_binary" == "0" ] ; then sed -i -e "s#REPLACE_OPENVINO_NAME#$(git --git-dir /openvino/.git log -n 1 | head -n 1 | cut -d' ' -f2 | head -c 12)#g" /ovms/src/version.hpp ; fi && \
bash -c "sed -i -e 's|REPLACE_BAZEL_BUILD_FLAGS|${debug_bazel_flags}${minitrace_flags}|g' /ovms/src/version.hpp"
# Test Coverage
COPY ci/check_coverage.bat /ovms/
ARG CHECK_COVERAGE=0
ARG RUN_TESTS=1
RUN if [ "$RUN_TESTS" == "1" ] ; then if [ "$CHECK_COVERAGE" == "1" ] ; then \
bazel coverage --instrumentation_filter="-src/test" --combined_report=lcov --jobs=$JOBS ${debug_bazel_flags} --test_timeout=1800 --test_summary=detailed --test_output=streamed --test_filter=* //src:ovms_test > ${TEST_LOG} 2>&1 || { cat ${TEST_LOG} && rm -rf ${TEST_LOG} && exit 1 ; } && genhtml --output genhtml "$(bazel info output_path)/_coverage/_coverage_report.dat" ; fi ; \
bazel test --jobs=$JOBS ${debug_bazel_flags} --test_timeout=1800 --test_summary=detailed --test_output=streamed --test_filter=* //src:ovms_test > ${TEST_LOG} 2>&1 || (cat ${TEST_LOG} && rm -rf ${TEST_LOG} && exit 1 ; ) && tail -n 100 ${TEST_LOG} && rm -rf ${TEST_LOG} ; \
bazel test --jobs=$JOBS ${debug_bazel_flags} --test_timeout=1800 --test_summary=detailed --test_output=streamed --test_filter=* //src:test_python_binding; fi ;
# C api shared library
RUN bazel build --jobs=$JOBS ${debug_bazel_flags} //src:ovms_shared
ARG FUZZER_BUILD=0
# C api app with bazel
# hadolint ignore=DL3059
RUN if [ "$FUZZER_BUILD" == "0" ]; then bazel build ${debug_bazel_flags} --jobs $JOBS //src:capi_cpp_example; fi;
# C-API benchmark app
RUN if [ "$FUZZER_BUILD" == "0" ]; then bazel build --jobs=$JOBS ${debug_bazel_flags} //src:capi_benchmark && ./bazel-bin/src/capi_benchmark --niter 2 --threads_per_ireq 2 --nireq 1 --servable_name "dummy" --inputs_names "b" --shape "b[1,10]"; fi;
# Custom Nodes
RUN if [ "$FUZZER_BUILD" == "0" ]; then bazel build --jobs=$JOBS ${debug_bazel_flags} //src:release_custom_nodes; fi;
# OVMS
# hadolint ignore=DL3059
RUN if [ "$FUZZER_BUILD" == "0" ]; then bazel build --jobs=$JOBS ${debug_bazel_flags} ${minitrace_flags} //src:ovms; fi;
# hadolint ignore=DL3059
RUN if [ "$FUZZER_BUILD" == "0" ]; then bazel build ${debug_bazel_flags} --jobs=$JOBS //src:libsampleloader.so; fi;
# C-api C/C++ app with gcc
COPY MakefileCapi /ovms/
RUN if [ "$FUZZER_BUILD" == "0" ]; then debug_bazel_flags=${debug_bazel_flags} make -f MakefileCapi cpp && \
debug_bazel_flags=${debug_bazel_flags} make -f MakefileCapi c; fi ;
RUN if [ "$FUZZER_BUILD" == "0" ]; then /ovms/bazel-bin/src/ovms --version && /ovms/bazel-bin/src/ovms; fi;
COPY release_files/thirdparty-licenses/ /ovms/release_files/thirdparty-licenses/
COPY release_files/LICENSE /ovms/release_files/LICENSE
COPY client /client
RUN python3 -c "import json; m={'PROJECT_VERSION':'${PROJECT_VERSION}','OPENVINO backend':'$(/ovms/bazel-bin/src/ovms --version | grep backend | cut -d' ' -f3)', \
'BAZEL_BUILD_FLAGS':'${debug_bazel_flags}${minitrace_flags}','BASE_IMAGE':'${BASE_IMAGE}' }; \
print(json.dumps(m,indent=4))" > /ovms/release_files/metadata.json
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
FROM $BUILD_IMAGE as pkg
RUN mkdir /patchelf
WORKDIR /patchelf
# hadolint ignore=DL3003
RUN wget -q https://github.com/NixOS/patchelf/archive/0.10.tar.gz && \
tar -xf 0.10.tar.gz && cd patchelf-0.10 && \
./bootstrap.sh && ./configure && make && make install
WORKDIR /
ARG BASE_OS=ubuntu
ARG ov_use_binary=0
ARG FUZZER_BUILD=0
ARG debug_bazel_flags=--strip=never\ --copt="-g "\ -c\ dbg
COPY create_package.sh /
RUN ./create_package.sh
RUN groupadd --gid 5000 ovms && useradd --home-dir /home/ovms --create-home --uid 5000 --gid 5000 --shell /bin/bash --skel /dev/null ovms && \
chown -R ovms:ovms /ovms_release
RUN mkdir /licenses && ln -s /ovms_release/LICENSE /licenses && ln -s /ovms_release/thirdparty-licenses /licenses/thirdparty-licenses
# Remove capi library
RUN if [ -f /ovms_release/lib/libovms_shared.so ] ; then mv /ovms_release/lib/libovms_shared.so / ; fi ;
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
FROM $BASE_IMAGE as release
ARG INSTALL_RPMS_FROM_URL=
ARG INSTALL_DRIVER_VERSION="23.13.26032"
ARG GPU=0
ARG NVIDIA=0
ENV DEBIAN_FRONTEND=noninteractive
ARG debug_bazel_flags=
LABEL bazel-build-flags=${debug_bazel_flags}
LABEL supported-devices="CPU=1 GNA=1 GPU=${GPU} NVIDIA=${NVIDIA}"
ARG BASE_IMAGE
LABEL base-image=${BASE_IMAGE}
ENV PYTHONPATH=/ovms/lib/python
SHELL ["/bin/bash", "-c"]
WORKDIR /
COPY release_files/drivers /drivers
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# hadolint ignore=DL3003,SC2164
RUN apt-get update -y ; \
apt-get install -y curl ca-certificates libpugixml1v5 libtbb2 --no-install-recommends && \
if [ "$GPU" == "1" ] ; then \
apt-get update && apt-get install -y libnuma1 ocl-icd-libopencl1 --no-install-recommends && rm -rf /var/lib/apt/lists/* && \
case $INSTALL_DRIVER_VERSION in \
"21.48.21782") \
mkdir /tmp/gpu_deps && cd /tmp/gpu_deps ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/21.48.21782/intel-gmmlib_21.3.3_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.9441/intel-igc-core_1.0.9441_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.9441/intel-igc-opencl_1.0.9441_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/21.48.21782/intel-opencl-icd_21.48.21782_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/21.48.21782/intel-level-zero-gpu_1.2.21782_amd64.deb ; \
dpkg -i intel*.deb && rm -Rf /tmp/gpu_deps ; \
;; \
"22.10.22597") \
mkdir /tmp/gpu_deps && cd /tmp/gpu_deps ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/22.10.22597/intel-gmmlib_22.0.2_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.10409/intel-igc-core_1.0.10409_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.10409/intel-igc-opencl_1.0.10409_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/22.10.22597/intel-opencl-icd_22.10.22597_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/22.10.22597/intel-level-zero-gpu_1.3.22597_amd64.deb ; \
dpkg -i intel*.deb && rm -Rf /tmp/gpu_deps ; \
;; \
"22.35.24055") \
apt-get update && apt-get install -y --no-install-recommends gpg gpg-agent && \
curl https://repositories.intel.com/graphics/intel-graphics.key | gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg && \
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/graphics/ubuntu focal-legacy main' | tee /etc/apt/sources.list.d/intel.gpu.focal.list && \
apt-get update && \
apt-get install -y --no-install-recommends \
intel-opencl-icd=22.35.24055+i815~u20.04 \
intel-level-zero-gpu=1.3.24055+i815~u20.04 \
level-zero=1.8.5+i815~u20.04 && \
apt-get purge gpg gpg-agent --yes && apt-get --yes autoremove && \
apt-get clean ; \
rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* ; \
;; \
"22.43.24595") \
apt-get update && apt-get install -y --no-install-recommends gpg gpg-agent && \
curl https://repositories.intel.com/graphics/intel-graphics.key | gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg && \
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/graphics/ubuntu focal-legacy main' | tee /etc/apt/sources.list.d/intel.gpu.focal.list && \
apt-get update && \
apt-get install -y --no-install-recommends \
intel-opencl-icd=22.43.24595.35+i538~20.04 \
intel-level-zero-gpu=1.3.24595.35+i538~20.04 \
level-zero=1.8.8+i524~u20.04 && \
apt-get purge gpg gpg-agent --yes && apt-get --yes autoremove && \
apt-get clean ; \
rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* ; \
;; \
"23.13.26032") \
mkdir /tmp/gpu_deps && cd /tmp/gpu_deps ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/23.05.25593.11/libigdgmm12_22.3.0_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.13700.14/intel-igc-core_1.0.13700.14_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.13700.14/intel-igc-opencl_1.0.13700.14_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/23.13.26032.30/intel-opencl-icd_23.13.26032.30_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/23.13.26032.30/libigdgmm12_22.3.0_amd64.deb ; \
dpkg -i *.deb && rm -Rf /tmp/gpu_deps ; \
;; \
"23.22.26516") \
mkdir /tmp/gpu_deps && cd /tmp/gpu_deps ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/23.22.26516.18/intel-level-zero-gpu_1.3.26516.18_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.14062.11/intel-igc-core_1.0.14062.11_amd64.deb ; \
curl -L -O https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.14062.11/intel-igc-opencl_1.0.14062.11_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/23.22.26516.18/intel-opencl-icd_23.22.26516.18_amd64.deb ; \
curl -L -O https://github.com/intel/compute-runtime/releases/download/23.22.26516.18/libigdgmm12_22.3.0_amd64.deb ; \
dpkg -i *.deb && rm -Rf /tmp/gpu_deps ; \
;; \
*) \
dpkg -P intel-gmmlib intel-igc-core intel-igc-opencl intel-level-zero-gpu intel-ocloc intel-opencl intel-opencl-icd && \
apt-get update && apt-get -y --no-install-recommends install dpkg-dev && rm -rf /var/lib/apt/lists/* && \
cd /drivers/${INSTALL_DRIVER_VERSION} && \
dpkg-scanpackages . > Packages && \
cd - ; \
echo "deb [trusted=yes arch=amd64] file:/drivers/${INSTALL_DRIVER_VERSION} ./" > /etc/apt/sources.list.d/intel-graphics-${INSTALL_DRIVER_VERSION}.list ; \
apt-get update && \
apt-get install -y --no-install-recommends \
intel-opencl-icd \
intel-level-zero-gpu level-zero \
intel-media-va-driver-non-free libmfx1 && \
rm -rf /var/lib/apt/lists/* ; \
esac ; \
fi ; \
apt-get clean ; \
rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* ; \
groupadd --gid 5000 ovms ; \
useradd --home-dir /home/ovms --create-home --uid 5000 --gid 5000 --groups 39,44 --shell /bin/bash --skel /dev/null ovms
RUN apt-get update && apt-get install -y --no-install-recommends libxml2 && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/*
# for NVIDIA
RUN if [ "$NVIDIA" == "1" ]; then true ; else exit 0 ; fi ; echo "installing cuda apt package"; \
apt-get update -y && \
apt-get install -y --no-install-recommends curl && \
curl -o /etc/apt/preferences.d/cuda-repository-pin-600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin ; \
apt-get update && apt-get install -y --no-install-recommends libcudnn8=8.8.0.121-1+cuda11.8 libcutensor1=1.6.1.5-1 libpng16-16 && \
apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/*
COPY --from=pkg /ovms_release /ovms
# For image with Python enabled install Python library
RUN if ! [[ $debug_bazel_flags == *"PYTHON_DISABLE=1"* ]]; then true ; else exit 0 ; fi ; \
apt-get update -y ; \
case $BASE_IMAGE in \
"ubuntu:20.04") \
apt-get install libpython3.8 --no-install-recommends -y \
;; \
"ubuntu:22.04") \
apt-get install libpython3.10 --no-install-recommends -y \
;; \
esac ; \
apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/*
ENV LD_LIBRARY_PATH=/ovms/lib
RUN echo "The source code of added GPL components is stored in https://storage.openvinotoolkit.org/repositories/openvino/ci_dependencies/container_gpl_sources/ubuntu20/" > /ovms/thirdparty-licenses/GPL.txt
USER ovms
ENTRYPOINT ["/ovms/bin/ovms"]