forked from google-ai-edge/mediapipe
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile.openvino
294 lines (251 loc) · 13.2 KB
/
Dockerfile.openvino
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
#
# 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
## Start of base image ############################################
FROM $BASE_IMAGE as base
LABEL version="0.0.1"
ARG JOBS=16
SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
#######
# Install dependencies
#######
# # to avoid question for continent
ENV DEBIAN_FRONTEND=noninteractive
# Install unit tests and examples requierments
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
ffmpeg \
git \
wget \
less \
tmux \
unzip \
nodejs \
npm \
python3-dev \
python3-opencv \
python3-pip \
libopencv-core-dev \
libopencv-highgui-dev \
libopencv-imgproc-dev \
libopencv-video-dev \
libopencv-calib3d-dev \
libopencv-features2d-dev \
software-properties-common && \
apt-get update && apt-get install -y openjdk-8-jdk && \
apt-get install -y mesa-common-dev libegl1-mesa-dev libgles2-mesa-dev && \
apt-get install -y mesa-utils && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN pip3 install setuptools==70.1.0
RUN pip3 install attrs matplotlib wheel future absl-py opencv-contrib-python numpy==1.24.4 tensorflow==2.9.0 protobuf==3.20.2 six==1.14.0 tf_slim
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN apt-get update && apt-get install -y protobuf-compiler
# Install unit tests and examples requierments
RUN wget https://github.com/bazelbuild/bazelisk/releases/download/v1.17.0/bazelisk-linux-amd64 && \
mv bazelisk-linux-amd64 /usr/bin/bazelisk && chmod +x /usr/bin/bazelisk
RUN apt-get update && apt-get install --no-install-recommends -y \
cmake \
automake \
autoconf \
curl \
libcurl4-openssl-dev \
git \
wget \
vim \
ca-certificates \
python3 \
pip \
libopencv-core-dev \
libopencv-highgui-dev \
libopencv-calib3d-dev \
libopencv-features2d-dev \
libopencv-imgproc-dev \
libopencv-video-dev \
build-essential \
unzip
# 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 libva-dev&& \
apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* ;
ARG INSTALL_DRIVER_VERSION="23.22.26516"
RUN 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 ;
WORKDIR /usr/lib/x86_64-linux-gnu/
RUN ln -s libOpenCL.so.1 libOpenCL.so
# install ovms_lib requirements
# xml2, uuid for azure
RUN apt-get update && apt-get install -y curl libpugixml1v5 libtbb2 libxml2-dev uuid-dev uuid libssl-dev --no-install-recommends
RUN apt-get update && apt-get install --no-install-recommends -y libtool
# Install bazel
ARG BAZEL_VERSION=6.1.1
RUN mkdir /bazel && \
wget --no-check-certificate -O /bazel/installer.sh "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/b\
azel-${BAZEL_VERSION}-installer-linux-x86_64.sh" && \
wget --no-check-certificate -O /bazel/LICENSE.txt "https://raw.githubusercontent.com/bazelbuild/bazel/master/LICENSE" && \
chmod +x /bazel/installer.sh && \
/bazel/installer.sh && \
rm -f /bazel/installer.sh
#OPENVINO
ARG DLDT_PACKAGE_URL
# OV toolkit package
RUN 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_2022
####### 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
# Main at Fix building without MediaPipe (#2129)
# Update SHA in two places here and in WORKSPACE ovms git repository
ARG OVMS_COMMIT="e2267e6b1b5715dc77aec6d89e299968287364fa"
RUN mkdir /opt/ovms
RUN wget -nv -P /opt/ovms https://raw.githubusercontent.com/openvinotoolkit/model_server/${OVMS_COMMIT}/third_party/cpprest/rest_sdk_v2.10.16.patch
RUN wget -nv -P /opt/ovms https://raw.githubusercontent.com/openvinotoolkit/model_server/${OVMS_COMMIT}/third_party/azure/azure_sdk.patch
RUN wget -nv -P /opt/ovms https://raw.githubusercontent.com/openvinotoolkit/model_server/${OVMS_COMMIT}/third_party/build_bazel_rules_apple/bazel_rules_apple.patch
RUN mkdir -p /root/ovms/dummy/1
RUN wget -nv -O /root/ovms/config.json https://raw.githubusercontent.com/openvinotoolkit/model_server/${OVMS_COMMIT}/src/test/mediapipe/config_standard_dummy.json
RUN sed -i 's:/ovms/src/test/dummy:/root/ovms/dummy:g' /root/ovms/config.json
RUN wget -nv -O /root/ovms/dummy/1/dummy.xml https://raw.githubusercontent.com/openvinotoolkit/model_server/${OVMS_COMMIT}/src/test/dummy/1/dummy.xml
RUN wget -nv -O /root/ovms/dummy/1/dummy.bin https://raw.githubusercontent.com/openvinotoolkit/model_server/${OVMS_COMMIT}/src/test/dummy/1/dummy.bin
####### 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 < /opt/ovms/rest_sdk_v2.10.16.patch && \
patch -d /azure/azure-storage-cpp/ -p1 < /opt/ovms/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" -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
####### End of Azure SDK
####### Build OpenCV
COPY setup_opencv.sh /mediapipe/setup_opencv.sh
COPY third_party/opencv_linux.BUILD /mediapipe/third_party/opencv_linux.BUILD
COPY WORKSPACE /mediapipe/WORKSPACE
WORKDIR /mediapipe
RUN ./setup_opencv.sh
####### End of OpenCV
## End of base image ###############################################################
####################################################################################
## Start of build image ############################################################
FROM base as build
RUN wget -O video.mp4 "https://www.pexels.com/download/video/3044127/?fps=24.0&h=1080&w=1920"
COPY mediapipe /mediapipe/mediapipe/
COPY third_party /mediapipe/third_party/
COPY .bazelrc .user.bazelr[c] /mediapipe/
COPY .bazelversion /mediapipe/
COPY *.sh /mediapipe/
COPY *.py /mediapipe/
COPY BUILD.bazel /mediapipe/
COPY LICENSE /mediapipe/
COPY Makefile /mediapipe/
COPY MANIFEST.in /mediapipe/
COPY package.json /mediapipe/
COPY platform_mappings /mediapipe/
COPY README.md /mediapipe/
COPY platform_mappings /mediapipe/
COPY tsconfig.json /mediapipe/
COPY requirements*.txt /mediapipe/
COPY yarn.lock /mediapipe/
# BUILD Geti calculators
RUN bazel build //mediapipe:geti_targets
# BUILD examples
ENV GLOG_logtostderr=1
ENV LD_LIBRARY_PATH="/opt/intel/openvino/runtime/3rdparty/tbb/lib:/opt/intel/openvino/runtime/lib/intel64/:${LD_LIBRARY_PATH}"
RUN python setup_ovms.py --get_models
RUN bash build_desktop_examples.sh -b
RUN curl https://storage.googleapis.com/mediapipe-assets/ssdlite_object_detection_labelmap.txt -o mediapipe/models/ssdlite_object_detection_labelmap.txt
# BUILD python framework
RUN python setup.py install
## End of build image ################################################################
######################################################################################
## Start of demos image - minimal size ###############################################
FROM $BASE_IMAGE as demos
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install --no-install-recommends -y curl libpugixml1v5 libtbb2 libxml2-dev uuid-dev uuid libssl-dev --no-install-recommends
RUN apt-get update && apt-get install --no-install-recommends -y ffmpeg
# Python samples requirements start
RUN apt-get update && apt-get install --no-install-recommends -y \
python3 \
python3-opencv \
python3-pip
RUN pip3 install attrs matplotlib protobuf==3.20.2 numpy==1.24.4
RUN ln -s /usr/bin/python3 /usr/bin/python
# Python samples requirements end
# Openvino
RUN apt-get update && apt-get install -y libavformat-dev libdc1394-dev libgtk2.0-dev
RUN mkdir -p /opt/intel/openvino/runtime/lib/intel64/
COPY --from=build /opt/intel/openvino/runtime/lib/intel64/ /opt/intel/openvino/runtime/lib/intel64/
RUN mkdir -p /opt/intel/openvino/runtime/3rdparty/tbb/lib/
COPY --from=build /opt/intel/openvino/runtime/3rdparty/tbb/lib/ /opt/intel/openvino/runtime/3rdparty/tbb/lib/
# 2GB with python 3.8 - currently excluded as only .so libs are copied
COPY --from=build /usr/local/lib/*.so* /usr/local/lib/
# Models
RUN mkdir -p /mediapipe/mediapipe/models/
COPY --from=build /mediapipe/mediapipe/models/ /mediapipe/mediapipe/models/
# Graphs
RUN mkdir -p /mediapipe/mediapipe/graphs/
COPY --from=build /mediapipe/mediapipe/graphs/ /mediapipe/mediapipe/graphs/
# Object detection
RUN mkdir -p /mediapipe/mediapipe/examples/desktop/object_detection/
COPY --from=build /mediapipe/mediapipe/examples/desktop/object_detection/test_video.mp4 /mediapipe/mediapipe/examples/desktop/object_detection/
COPY --from=build /mediapipe/bazel-bin/mediapipe/examples/desktop/object_detection/object_detection_ovms /mediapipe/bazel-bin/mediapipe/examples/desktop/object_detection/
COPY --from=build /mediapipe/video.mp4 /mediapipe/
# Face detection
RUN mkdir -p /mediapipe/bazel-bin/mediapipe/examples/desktop/face_detection/
COPY --from=build /mediapipe/bazel-bin/mediapipe/examples/desktop/face_detection/face_detection_cpu /mediapipe/bazel-bin/mediapipe/examples/desktop/face_detection/
# Holistic tracking
RUN mkdir -p /mediapipe/bazel-bin/mediapipe/examples/desktop/holistic_tracking/
COPY --from=build /mediapipe/bazel-bin/mediapipe/examples/desktop/holistic_tracking/holistic_tracking_cpu /mediapipe/bazel-bin/mediapipe/examples/desktop/holistic_tracking/
RUN mkdir -p /mediapipe/mediapipe/modules/hand_landmark/
COPY --from=build /mediapipe/mediapipe/modules/hand_landmark/handedness.txt /mediapipe/mediapipe/modules/hand_landmark/
# Iris tracking
RUN mkdir -p /mediapipe/bazel-bin/mediapipe/examples/desktop/iris_tracking/
COPY --from=build /mediapipe/bazel-bin/mediapipe/examples/desktop/iris_tracking/iris_tracking_cpu /mediapipe/bazel-bin/mediapipe/examples/desktop/iris_tracking/
# Pose tracking
RUN mkdir -p /mediapipe/bazel-bin/mediapipe/examples/desktop/pose_tracking/
COPY --from=build /mediapipe/bazel-bin/mediapipe/examples/desktop/pose_tracking/pose_tracking_cpu /mediapipe/bazel-bin/mediapipe/examples/desktop/pose_tracking/
#OVMS Config
RUN mkdir -p /mediapipe/mediapipe/calculators/ovms/
COPY --from=build /mediapipe/mediapipe/calculators/ovms/config.json /mediapipe/mediapipe/calculators/ovms/
# Makefile
COPY --from=build /mediapipe/Makefile /mediapipe/
# Add python solutions TODO currently disabled
#COPY --from=build /mediapipe/build/ /mediapipe/build/
# Environment variables
ENV GLOG_logtostderr=1
ENV LD_LIBRARY_PATH=/usr/local/lib:/opt/intel/openvino/runtime/lib/intel64/:/opt/intel/openvino/runtime/3rdparty/tbb/lib/
WORKDIR /mediapipe
## End of demos image #########################################################