-
Notifications
You must be signed in to change notification settings - Fork 212
/
Dockerfile.ubuntu
472 lines (405 loc) · 22.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
#
# 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
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 \
gpg \
libcurl4-openssl-dev \
libssl-dev \
libva-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://sourceforge.net/projects/boost/files/boost/1.69.0/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/azure /ovms/third_party/azure
COPY third_party/cpprest /ovms/third_party/cpprest
####### 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 OpenCV
COPY third_party/opencv /ovms/third_party/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
SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
ARG debug_bazel_flags="--strip=always --config=mp_on_py_on --//:distro=ubuntu"
RUN apt-get update && apt-get install --no-install-recommends -y \
libgflags-dev \
bc \
ca-certificates \
curl \
default-jdk \
lcov \
less \
libpugixml1v5 \
libusb-dev \
libusb-1.0-0-dev \
libtool \
libnuma-dev \
libtbb-dev \
libssl-dev \
python2 \
python2-dev \
python3-dev \
python3-venv \
python3-pip \
unzip \
gdb \
vim && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
python3 -m pip install "numpy<2.0.0" --no-cache-dir && \
python3 -m pip install "Jinja2==3.1.4" "MarkupSafe==3.0.2" --no-cache-dir
RUN apt-get update; apt-get install -y --no-install-recommends libxml2 && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/*
ARG JOBS=8
ARG ov_use_binary=0
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 CMAKE_BUILD_TYPE=Release
ENV HDDL_INSTALL_DIR=/opt/intel/openvino/deployment_tools/inference_engine/external/hddl
ENV TF_SYSTEM_LIBS="curl"
# Set up Bazel
ENV BAZEL_VERSION 6.1.1
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
ENV TEST_LOG="/root/.cache/bazel/_bazel_root/bc57d4817a53cab8c785464da57d1983/execroot/ovms/bazel-out/test.log"
ARG NVIDIA=0
# hadolint ignore=DL3003
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
################### 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
RUN if [ "$ov_use_binary" == "0" ]; then true ; else exit 0 ; fi ; if ! [[ $debug_bazel_flags == *"py_off"* ]]; then true ; else exit 0 ; fi ; pip install --no-cache-dir -r /openvino/src/bindings/python/wheel/requirements-dev.txt
WORKDIR /openvino/build
RUN if [ "$ov_use_binary" == "0" ]; then true ; else exit 0 ; fi ; if ! [[ $debug_bazel_flags == *"py_off"* ]]; then true ; else exit 0 ; fi ; cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DENABLE_PYTHON=ON -DENABLE_SAMPLES=0 -DNGRAPH_USE_CXX_ABI=1 -DCMAKE_CXX_FLAGS=" -D_GLIBCXX_USE_CXX11_ABI=1 -Wno-error=parentheses " -DENABLE_CPPLINT=OFF -DENABLE_INTEL_NPU_PROTOPIPE=OFF ..
RUN if [ "$ov_use_binary" == "0" ] && [[ $debug_bazel_flags == *"py_off"* ]]; 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 " -DENABLE_CPPLINT=OFF -DENABLE_INTEL_NPU_PROTOPIPE=OFF ..
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 && \
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_2024
RUN if [ "$ov_use_binary" == "0" ]; then true ; else exit 0 ; fi ; if ! [[ $debug_bazel_flags == *"py_off"* ]]; then true ; else exit 0 ; fi ; mkdir -p /opt/intel/openvino && cp -r /openvino/bin/intel64/${CMAKE_BUILD_TYPE}/python /opt/intel/openvino/
RUN if [ "$ov_use_binary" == "0" ]; then true ; else exit 0 ; fi ; if ! [[ $debug_bazel_flags == *"py_off"* ]]; then true ; else exit 0 ; fi ; cp -r /openvino/tools/ovc/* /opt/intel/openvino/python
################## 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 ; \
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_2024
# update oneTBB
RUN wget -nv https://github.com/oneapi-src/oneTBB/releases/download/v2021.13.0/oneapi-tbb-2021.13.0-lin.tgz && \
tar -zxf oneapi-tbb-2021.13.0-lin.tgz && \
rm /opt/intel/openvino/runtime/3rdparty/tbb/lib/*.so* && \
cp -vP oneapi-tbb-2021.13.0/lib/intel64/gcc4.8/*.so* /opt/intel/openvino/runtime/3rdparty/tbb/lib/ && \
rm -f /opt/intel/openvino/oneapi-tbb-2021.13.0-lin.tgz
WORKDIR /
# 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
# OpenVINO Tokenizers extension
ENV OpenVINO_DIR=/opt/intel/openvino/runtime/cmake
ARG ov_tokenizers_branch=master
# hadolint ignore=DL3003
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
WORKDIR /openvino_tokenizers/build
RUN cmake .. -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE && cmake --build . --parallel $JOBS ; cp /openvino_tokenizers/build/src/lib*.so /opt/intel/openvino/runtime/lib/intel64/
# NVIDIA
ENV OPENVINO_BUILD_PATH=/cuda_plugin_build
ENV OPENVINO_HOME=/openvino
ENV OPENVINO_CONTRIB=/openvino_contrib
# Add Nvidia dev tool if needed
RUN apt-get update ; \
apt-get install -y --no-install-recommends opencl-clhpp-headers opencl-c-headers intel-opencl-icd && \
apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* ;
# hadolint ignore=DL3003
RUN if [ "$NVIDIA" == "1" ] ; then true ; else exit 0 ; fi ; \
set -exuo pipefail ; \
rm -f /etc/apt/apt.conf.d/docker-clean ; \
if [[ ${enable_tensorrt-} == "1" ]] ; then dpkg -i /nv-tensorrt-repo-*.deb ; fi; \
if [[ "$BASE_IMAGE" == *"22.04"* ]] ; then libcutensor_version=1.7.0.1-1; else libcutensor_version=1.6.1.5-1; 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="$libcutensor_version" \
libcutensor-dev="$libcutensor_version" && \
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
WORKDIR /ovms
# GPU testing in build img
COPY ./install_ubuntu_gpu_drivers.sh /tmp/install_gpu_drivers.sh
ARG INSTALL_DRIVER_VERSION="23.22.26516"
RUN /tmp/install_gpu_drivers.sh && \
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
# GPU testing in build img
# Build OpenVINO Model Server
COPY .bazelrc .user.bazelr[c] .bazelversion 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/python/binding/BUILD /ovms/src/python/binding/BUILD
COPY src/python/binding/tests/requirements.txt /ovms/src/python/binding/tests/requirements.txt
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/intel/openvino/runtime/lib/intel64/:/opt/opencv/lib/:/opt/intel/openvino/runtime/3rdparty/tbb/lib
# FROM BASE BUILD
COPY --from=base_build /opt/opencv /opt/opencv/
COPY third_party /ovms/third_party/
# Mediapipe
COPY BUILD.bazel /ovms/
COPY *\.bzl /ovms/
COPY yarn.lock /ovms/
COPY package.json /ovms/
# prebuild dependencies before copying sources & test dependencies for caching
RUN bazel build --jobs=$JOBS ${debug_bazel_flags} //:ovms_dependencies @com_google_googletest//:gtest
COPY src/ /ovms/src/
# hadolint ignore=DL3059
RUN bazel build --jobs=$JOBS ${debug_bazel_flags} @org_tensorflow//tensorflow/core:framework
# 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/
# Sample CPU Extension
WORKDIR /ovms/src/example/SampleCpuExtension/
RUN make && cp libcustom_relu_cpu_extension.so /opt
RUN if ! [[ $debug_bazel_flags == *"py_off"* ]]; then true ; else exit 0 ; fi ; \
mkdir -p /opt/intel/openvino/python/openvino-2024.5.dist-info && \
echo $'Metadata-Version: 1.0\nName: openvino\nVersion: 2024.5' > /opt/intel/openvino/python/openvino-2024.5.dist-info/METADATA
WORKDIR /ovms
ARG PROJECT_VERSION="2024.5"
ARG PROJECT_NAME="OpenVINO Model Server"
LABEL description=${PROJECT_NAME}
ARG minitrace_flags
ENV PYTHONPATH=/opt/intel/openvino/python:/ovms/bazel-bin/src/python/binding
# 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"
WORKDIR /usr/lib/x86_64-linux-gnu/
RUN ln -s libOpenCL.so.1 libOpenCL.so
WORKDIR /ovms
# Test Coverage
COPY ci/check_coverage.bat /ovms/
ARG CHECK_COVERAGE=0
COPY run_unit_tests.sh prepare_llm_models.sh install_va.sh /ovms/
ARG RUN_TESTS=0
RUN if [ "$RUN_TESTS" == "1" ] ; then ./prepare_llm_models.sh /ovms/src/test/llm_testing docker && ./run_unit_tests.sh ; fi
ARG FUZZER_BUILD=0
# Custom Nodes
# hadolint ignore=DL3059
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 //src:ovms_test; fi;
# hadolint ignore=DL3059
RUN if [ "$FUZZER_BUILD" == "0" ]; then bazel build ${debug_bazel_flags} --jobs=$JOBS //src:libsampleloader.so; 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 capi-build
SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
# C api shared library
# hadolint ignore=DL3059
ARG CAPI_FLAGS="--strip=always --config mp_off_py_off --//:distro=ubuntu"
ARG JOBS=40
ARG FUZZER_BUILD=0
RUN bazel build --jobs=$JOBS ${CAPI_FLAGS} //src:ovms_shared
# C-API benchmark app
RUN if [ "$FUZZER_BUILD" == "0" ]; then bazel build --jobs=$JOBS ${CAPI_FLAGS} //src:capi_benchmark && ./bazel-bin/src/capi_benchmark --niter 2 --nstreams 1 --servable_name "dummy"; fi;
ARG FUZZER_BUILD=0
# C api app with bazel
# hadolint ignore=DL3059
RUN if [ "$FUZZER_BUILD" == "0" ]; then bazel build ${CAPI_FLAGS} --jobs $JOBS //src:capi_cpp_example; fi;
# C-api C/C++ app with gcc
COPY MakefileCapi /ovms/
RUN if [ "$FUZZER_BUILD" == "0" ]; then CAPI_FLAGS=${CAPI_FLAGS} make -f MakefileCapi cpp && \
CAPI_FLAGS=${CAPI_FLAGS} make -f MakefileCapi c; fi ;
RUN mkdir -p /ovms_release/lib/ ; find /ovms/bazel-out/k8-*/bin -iname 'libovms_shared.so' -exec cp -v {} /ovms_release/lib/ \;
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
FROM build 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 --from=capi-build /ovms_release/lib/libovms_shared.so /ovms_release/lib/
COPY create_package.sh /
RUN ./create_package.sh
RUN chown -R ovms:ovms /ovms_release && \
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="24.26.30049"
ARG GPU=0
ARG NPU=0
ARG NVIDIA=0
ENV DEBIAN_FRONTEND=noninteractive
ARG debug_bazel_flags=
LABEL bazel-build-flags=${debug_bazel_flags}
LABEL supported-devices="CPU=1 GPU=${GPU} NPU=${NPU} NVIDIA=${NVIDIA}"
ARG BASE_IMAGE
LABEL base-image=${BASE_IMAGE}
ENV PYTHONPATH=/ovms/lib/python:/ovms/python_deps
SHELL ["/bin/bash", "-c"]
WORKDIR /
COPY release_files/drivers /drivers
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG INSTALL_DRIVER_VERSION="23.22.26516"
COPY ./install_ubuntu_gpu_drivers.sh /tmp/install_gpu_drivers.sh
# hadolint ignore=DL3003,SC2164
RUN apt-get update ; \
apt-get install -y --no-install-recommends curl ca-certificates libxml2 && \
if [ "$GPU" == "1" ] ; then \
/tmp/install_gpu_drivers.sh ; \
fi ; \
if [ "$NPU" == "1" ] ; then \
mkdir /tmp/npu_deps && cd /tmp/npu_deps ; \
apt-get update && apt-get install -y --no-install-recommends libtbb12 && \
curl -L -O https://github.com/intel/linux-npu-driver/releases/download/v1.6.0/intel-driver-compiler-npu_1.6.0.20240814-10390978568_ubuntu22.04_amd64.deb ; \
curl -L -O https://github.com/intel/linux-npu-driver/releases/download/v1.6.0/intel-fw-npu_1.6.0.20240814-10390978568_ubuntu22.04_amd64.deb ; \
curl -L -O https://github.com/intel/linux-npu-driver/releases/download/v1.6.0/intel-level-zero-npu_1.6.0.20240814-10390978568_ubuntu22.04_amd64.deb ; \
curl -L -O https://github.com/oneapi-src/level-zero/releases/download/v1.17.6/level-zero_1.17.6+u22.04_amd64.deb ; \
dpkg -i ./*.deb && rm -Rf /tmp/npu_deps ; \
fi ; \
apt-get clean ; \
rm -rf /tmp/install_gpu_drivers.sh && \
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
# for NVIDIA
RUN if [ "$NVIDIA" == "1" ]; then true ; else exit 0 ; fi ; echo "installing cuda apt package"; \
apt-get install -y --no-install-recommends curl && \
if [[ "$BASE_IMAGE" == *"22.04"* ]] ; then libcutensor_version=1.7.0.1-1; else libcutensor_version=1.6.1.5-1; fi; \
apt-get update && apt-get install -y --no-install-recommends libcudnn8=8.8.0.121-1+cuda11.8 libcutensor1="$libcutensor_version" libpng16-16 && \
apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/*
COPY --from=pkg /ovms_release /ovms
COPY --from=build /usr/local/lib/python3.*/dist-packages/MarkupSafe-3.0.2.dist-info /ovms/python_deps/MarkupSafe-3.0.2.dist-info
COPY --from=build /usr/local/lib/python3.*/dist-packages/jinja2 /ovms/python_deps/jinja2
COPY --from=build /usr/local/lib/python3.*/dist-packages/jinja2-3.1.4.dist-info /ovms/python_deps/jinja2-3.1.4.dist-info
COPY --from=build /usr/local/lib/python3.*/dist-packages/markupsafe /ovms/python_deps/markupsafe
# For image with Python enabled install Python library
RUN if ! [[ $debug_bazel_flags == *"py_off"* ]]; then true ; else exit 0 ; fi ; \
apt-get update -y ; \
if [[ "$BASE_IMAGE" == *"22.04"* ]] ; then python_version=3.10; else python_version=3.8; fi; \
apt-get install libpython$python_version --no-install-recommends -y && \
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/" > /ovms/thirdparty-licenses/GPL.txt
USER ovms
ENTRYPOINT ["/ovms/bin/ovms"]