Skip to content

Commit

Permalink
Ubuntu based docker images (openvinotoolkit#736)
Browse files Browse the repository at this point in the history
* remove move from return statements

* initial ubuntu build

* further adjustments

* added release and nginx dockerfiles

* define shell in builder dockerfile

* update TF, TFS and bazel versions

* upgrade bazel in centos and redhat dockerfiles

* install numpy for centos and rhel

* Add redhat xz package.

* symlinks for libgna lib

* move xz install to builder docker image

* Code review.

* Remove compile log.

Co-authored-by: Dariusz Trawinski <[email protected]>
Co-authored-by: rasapala <[email protected]>
  • Loading branch information
3 people authored Jul 20, 2021
1 parent 0f908c9 commit 4930102
Show file tree
Hide file tree
Showing 22 changed files with 405 additions and 95 deletions.
6 changes: 4 additions & 2 deletions Dockerfile.centos
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,21 @@ RUN yum update -d6 -y && yum install -d6 -y epel-release centos-release-scl && y
python3-devel \
python3-setuptools \
python3-virtualenv \
python3-numpy \
wget \
which \
libxml2-devel \
yum-utils \
unzip && \
unzip \
xz && \
yum clean all

SHELL [ "/usr/bin/scl", "enable", "devtoolset-8" ]
ENV CC=/opt/rh/devtoolset-8/root/bin/gcc
ENV CXX=/opt/rh/devtoolset-8/root/bin/g++

# Set up Bazel
ENV BAZEL_VERSION 2.0.0
ENV BAZEL_VERSION 3.7.2
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 && \
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile.redhat
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.n
python3-devel \
python3-setuptools \
python3-virtualenv \
python3-numpy \
wget \
which \
yum-utils \
unzip && \
unzip \
xz && \
yum clean all

# Set up Bazel
ENV BAZEL_VERSION 2.0.0
ENV BAZEL_VERSION 3.7.2
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 && \
Expand Down
208 changes: 208 additions & 0 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
#
# 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=ubuntu:20.04
FROM $BASE_IMAGE as base_build

LABEL version="1.0.0"

ARG PROJECT_NAME="OpenVINO Model Server 2021.4"

LABEL description=${PROJECT_NAME}

ARG ov_source_branch=master
ARG ovms_metadata_file
ARG ov_use_binary=1
ARG DLDT_PACKAGE_URL
ARG OPENVINO_NAME=${DLDT_PACKAGE_URL}
ARG INSTALL_DIR=/opt/intel/openvino
ARG TEMP_DIR=/tmp/openvino_installer
ARG DL_INSTALL_DIR=/opt/intel/openvino/deployment_tools
ARG DL_DIR=/tmp
ARG JOBS
ARG APT_OV_PACKAGE=intel-openvino-runtime-ubuntu20-2021.4.582
# build_type=[ opt, dbg ]
ARG build_type=dbg
ARG debug_bazel_flags=--strip=never\ --copt="-g"\ -c\ dbg
ENV HDDL_INSTALL_DIR=/opt/intel/openvino/deployment_tools/inference_engine/external/hddl
ENV DEBIAN_FRONTEND=noninteractive
SHELL ["/bin/bash", "-c"]
RUN apt update && apt install -y \
libboost-atomic1.67.0 \
libboost-chrono1.67.0 \
libboost-filesystem1.67.0 \
libboost-program-options1.67.0 \
libboost-thread1.67.0 \
libboost-system1.67.0 \
libboost-date-time1.67.0 \
build-essential \
cmake \
automake \
autoconf \
curl \
gdb \
git \
libusb-dev \
libcurl4-openssl-dev \
libtool \
libxml2-dev \
libnuma-dev \
patch \
pkg-config \
python2 \
python2-dev \
python-setuptools \
python3 \
python3-pip \
python3-dev \
python3-setuptools \
python3-virtualenv \
python3-numpy \
python-is-python3 \
unzip \
wget \
unzip \
xz-utils && \
apt clean


# Set up Bazel
ENV BAZEL_VERSION 3.7.2
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 && \
cd / && \
rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh

################### BUILD OPENVINO FROM SOURCE - buildarg ov_use_binary=0 ############################
# Build OpenVINO and nGraph (OV dependency) with D_GLIBCXX_USE_CXX11_ABI=0 or 1
RUN if [ "$ov_use_binary" == "0" ] ; then true ; else exit 0 ; fi ; git clone https://github.com/openvinotoolkit/openvino /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 ; cmake3 -DCMAKE_BUILD_TYPE=Release -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 ; mkdir -p /opt/intel/openvino/deployment_tools/inference_engine/lib/intel64/ && \
mkdir -p /opt/intel/openvino/deployment_tools/inference_engine && \
ln -s /openvino/bin/intel64/Release/lib/* /opt/intel/openvino/deployment_tools/inference_engine/lib/intel64/ && \
ln -s /openvino/inference-engine/include/ /opt/intel/openvino/deployment_tools/inference_engine/
################## END OF OPENVINO SOURCE BUILD ######################

################### TAKE OPENVINO FROM A BINARY RELEASE - buildarg ov_use_binary=1 (DEFAULT) ##########
WORKDIR /
# OV toolkit package
RUN apt install -y cpio
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 && \
tar -zxf l_openvino_toolkit*.tgz && \
cd l_openvino_toolkit*/ && \
sed -i 's/decline/accept/g' silent.cfg && \
./install.sh -s silent.cfg --ignore-signature && \
rm -Rf $TEMP_DIR $INSTALL_DIR/uninstall* /tmp/* $DL_INSTALL_DIR/documentation $DL_INSTALL_DIR/inference_engine/samples

# apt package
RUN if [ "$ov_use_binary" = "1" ] && [ "$DLDT_PACKAGE_URL" = "" ] ; then true ; else exit 0 ; fi ; \
echo "installing apt package" && \
wget https://apt.repos.intel.com/openvino/2021/GPG-PUB-KEY-INTEL-OPENVINO-2021 && \
apt-key add GPG-PUB-KEY-INTEL-OPENVINO-2021 && \
echo "deb https://apt.repos.intel.com/openvino/2021 all main" | tee /etc/apt/sources.list.d/intel-openvino-2021.list && \
apt update && \
apt install -y $APT_OV_PACKAGE

RUN if [ "$ov_use_binary" = "1" ] ; then true ; else exit 0 ; fi ; \
ln -s /opt/intel/openvino_2021 /opt/intel/openvino

# install sample apps including benchmark_app
RUN if [ -f /opt/intel/openvino/deployment_tools/inference_engine/samples/cpp/build_samples.sh ]; then /opt/intel/openvino/deployment_tools/inference_engine/samples/cpp/build_samples.sh ; fi
#################### END OF OPENVINO BINARY INSTALL

# Build OpenVINO Model Server
WORKDIR /ovms
COPY .bazelrc WORKSPACE /ovms/
COPY external /ovms/external/
COPY third_party /ovms/third_party/

ENV BAZEL_LINKLIBS=-l%:libstdc++.a
RUN apt install -y python-is-python3
RUN bazel build --jobs=$JOBS ${debug_bazel_flags} @org_tensorflow//tensorflow/core:framework
RUN bazel build --jobs=$JOBS ${debug_bazel_flags} @tensorflow_serving//tensorflow_serving/apis:prediction_service_cc_proto

####### Azure SDK needs new boost:
WORKDIR /boost
RUN wget https://sourceforge.net/projects/boost/files/boost/1.68.0/boost_1_68_0.tar.gz && \
tar xvf boost_1_68_0.tar.gz && cd boost_1_68_0 && ./bootstrap.sh && \
./b2 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

# OPENSSL
WORKDIR /openssl

RUN git clone https://github.com/openssl/openssl && cd openssl && git checkout tags/OpenSSL_1_1_1k
RUN cd openssl && ./config --prefix=/usr/local/ssl --openssldir=/etc/pki/tls shared && make --jobs=$JOBS && make --jobs=$JOBS install || true && make --jobs=$JOBS install_runtime

####### Azure SDK

WORKDIR /azure
RUN apt-get install -y uuid uuid-dev
RUN git clone https://github.com/Microsoft/cpprestsdk.git && cd cpprestsdk && git checkout tags/v2.10.18 -b v2.10.18 && git submodule update --init

RUN git clone https://github.com/Azure/azure-storage-cpp.git && cd azure-storage-cpp/Microsoft.WindowsAzure.Storage && git checkout tags/v7.5.0 && mkdir build.release

WORKDIR /
RUN cp -rf /ovms/third_party/cpprest/rest_sdk_v2.10.16.patch /azure/cpprestsdk/
RUN cd /azure/cpprestsdk/ && patch -p1 < rest_sdk_v2.10.16.patch
RUN cp -rf /ovms/third_party/azure/azure_sdk.patch /azure/azure-storage-cpp/
RUN cd /azure/azure-storage-cpp/ && patch -p1 < azure_sdk.patch
WORKDIR /azure

RUN cd cpprestsdk && mkdir Release/build.release && cd Release/build.release && 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
RUN cd azure-storage-cpp/Microsoft.WindowsAzure.Storage/build.release && 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 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 OPENSSL_ROOT_DIR=/usr/local/ssl/ 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 " ..
RUN make --jobs=$JOBS
#RUN mv .deps/install/lib64 .deps/install/lib

####### End of AWS S3 SDK

WORKDIR /ovms

COPY src/ /ovms/src/
COPY release_files/ /ovms/release_files/

# Set OVMS version strings
RUN bash -c "sed -i -e 's|REPLACE_PROJECT_NAME|${PROJECT_NAME}|g' /ovms/src/version.hpp"
RUN if [ "$ov_use_binary" = "1" ] ; then true ; else exit 0 ; fi ; sed -i -e "s#REPLACE_OPENVINO_NAME#`find /opt/intel/ -maxdepth 1 -type d | grep openvino | cut -d'_' -f2`#g" /ovms/src/version.hpp
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/intel/openvino/deployment_tools/inference_engine/lib/intel64/:/opt/intel/openvino/deployment_tools/ngraph/lib/:/opt/intel/openvino/inference_engine/external/tbb/lib/:/openvino/bin/intel64/Release/lib/:/opt/intel/openvino/opencv/lib/

RUN bazel build ${debug_bazel_flags} --jobs $JOBS //src:ovms
RUN bazel build ${debug_bazel_flags} --jobs $JOBS //src:libsampleloader.so

RUN cd /ovms/src/test/cpu_extension/ && make

RUN bazel test ${debug_bazel_flags} --jobs $JOBS --test_summary=detailed --test_output=all //src:ovms_test

COPY ${ovms_metadata_file} metadata.json

RUN ./bazel-bin/src/./ovms --version
RUN ./bazel-bin/src/./ovms
5 changes: 4 additions & 1 deletion DockerfileMakePackage
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
#

ARG BUILD_IMAGE=ovms-centos:latest
ARG BASE_OS=centos

FROM $BUILD_IMAGE

ARG ov_use_binary=1
RUN yum install -y xz
SHELL ["/bin/bash", "-c"]

RUN mkdir /patchelf && cd /patchelf && \
wget https://github.com/NixOS/patchelf/archive/0.10.tar.gz && \
tar -xf 0.10.tar.gz && ls -lah && cd */ && \
Expand Down Expand Up @@ -56,6 +58,7 @@ RUN find /usr/local/ssl/lib -iname 'libcrypto.so*' -exec cp -vP {} /ovms_release
RUN if [ -f /ovms_release/lib/libbsl.so.0 ] ; then cd /ovms_release/lib/ ; rm -f libbsl.so.0 ; ln -s libbsl.so libbsl.so.0 ; fi
RUN if [ -f /ovms_release/lib/libmvnc-hddl.so.0 ] ; then cd /ovms_release/lib/ ; rm -f libmvnc-hddl.so.0 ; ln -s libmvnc-hddl.so libmvnc-hddl.so.0 ; fi
RUN if [ -f /ovms_release/lib/libion.so.0 ] ; then cd /ovms_release/lib/ ; rm -f libion.so.0 ; ln -s libion.so libion.so.0 ; fi
RUN if [ -f /ovms_release/lib/libgna.so.2 ] ; then cd /ovms_release/lib/ ; rm -f libgna.so.2 ; ln -s libgna.so libgna.so.2 ; if [ -f /ovms_release/lib/libgna.so.2.0.0.1226 ] ; then cd /ovms_release/lib/ ; rm -f libgna.so.2.0.0.1226 ; ln -s libgna.so.2 libgna.so.2.0.0.1226 ; fi ; fi

RUN find /ovms/bazel-bin/src -name 'ovms' -type f -exec cp -v {} /ovms_release/bin \;
WORKDIR /ovms_release/bin
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ BASE_IMAGE ?= centos:7
# do not change this; change versions per OS a few lines below (BASE_OS_TAG_*)!
BASE_OS_TAG ?= latest

BASE_OS_TAG_UBUNTU ?= 18.04
BASE_OS_TAG_UBUNTU ?= 20.04
BASE_OS_TAG_CENTOS ?= 7
BASE_OS_TAG_CLEARLINUX ?= latest
BASE_OS_TAG_REDHAT ?= 8.4
Expand All @@ -53,7 +53,7 @@ OV_SOURCE_BRANCH ?= master
DLDT_PACKAGE_URL ?=
OV_USE_BINARY ?= 1
YUM_OV_PACKAGE ?= intel-openvino-runtime-centos7

APT_OV_PACKAGE ?= intel-openvino-runtime-ubuntu20-2021.3.394
# opt, dbg:
BAZEL_BUILD_TYPE ?= opt

Expand All @@ -70,6 +70,7 @@ DIST_OS_TAG ?= $(BASE_OS_TAG)

ifeq ($(BASE_OS),ubuntu)
BASE_OS_TAG=$(BASE_OS_TAG_UBUNTU)
BASE_IMAGE=ubuntu:$(BASE_OS_TAG_UBUNTU)
endif
ifeq ($(BASE_OS),centos)
BASE_OS_TAG=$(BASE_OS_TAG_CENTOS)
Expand Down Expand Up @@ -176,14 +177,15 @@ endif
--build-arg ovms_metadata_file=.workspace/metadata.json --build-arg ov_source_branch="$(OV_SOURCE_BRANCH)" \
--build-arg ov_use_binary=$(OV_USE_BINARY) --build-arg DLDT_PACKAGE_URL=$(DLDT_PACKAGE_URL) \
--build-arg YUM_OV_PACKAGE=$(YUM_OV_PACKAGE) \
--build-arg APT_OV_PACKAGE=$(APT_OV_PACKAGE) \
--build-arg build_type=$(BAZEL_BUILD_TYPE) --build-arg debug_bazel_flags=$(BAZEL_DEBUG_FLAGS) \
--build-arg PROJECT_NAME=${PROJECT_NAME} \
--build-arg BASE_IMAGE=$(BASE_IMAGE) \
-t $(OVMS_CPP_DOCKER_IMAGE)-build:$(OVMS_CPP_IMAGE_TAG) \
--build-arg JOBS=$(JOBS)
docker build $(NO_CACHE_OPTION) -f DockerfileMakePackage . \
--build-arg http_proxy=$(HTTP_PROXY) --build-arg https_proxy="$(HTTPS_PROXY)" \
--build-arg ov_use_binary=$(OV_USE_BINARY) --build-arg DLDT_PACKAGE_URL=$(DLDT_PACKAGE_URL) \
--build-arg ov_use_binary=$(OV_USE_BINARY) --build-arg DLDT_PACKAGE_URL=$(DLDT_PACKAGE_URL) --build-arg BASE_OS=$(BASE_OS) \
-t $(OVMS_CPP_DOCKER_IMAGE)-pkg:$(OVMS_CPP_IMAGE_TAG) \
--build-arg BUILD_IMAGE=$(OVMS_CPP_DOCKER_IMAGE)-build:$(OVMS_CPP_IMAGE_TAG)
rm -vrf dist/$(DIST_OS) && mkdir -vp dist/$(DIST_OS) && cd dist/$(DIST_OS) && \
Expand Down
Loading

0 comments on commit 4930102

Please sign in to comment.