Dockerfile.openvino-rhel8 4.21 KB
Newer Older
gaoqiong's avatar
gaoqiong committed
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
# Build stage
FROM registry.access.redhat.com/ubi8/ubi:8.4

WORKDIR /code

ARG MY_ROOT=/code
ARG DEVICE=CPU_FP32
ARG ONNXRUNTIME_REPO=https://github.com/microsoft/onnxruntime
ARG ONNXRUNTIME_BRANCH=main

ENV INTEL_OPENVINO_DIR=/opt/intel/openvino_2022.2.0.7713

ENV InferenceEngine_DIR=${INTEL_OPENVINO_DIR}/runtime/cmake
ENV IE_PLUGINS_PATH=${INTEL_OPENVINO_DIR}/runtime/lib/intel64/
ENV ngraph_DIR=${INTEL_OPENVINO_DIR}/runtime/cmake
ENV LD_LIBRARY_PATH=${INTEL_OPENVINO_DIR}/runtime/3rdparty/tbb/lib/:${IE_PLUGINS_PATH}:${LD_LIBRARY_PATH}
ENV OpenCV_DIR=${INTEL_OPENVINO_DIR}/extras/opencv/cmake
ENV LD_LIBRARY_PATH=${INTEL_OPENVINO_DIR}/extras/opencv/lib:${LD_LIBRARY_PATH}
ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/usr/local/lib64:/usr/lib64:/lib64:${LD_LIBRARY_PATH}

# Install packages 
RUN yum install -y yum-utils autoconf automake libtool unzip udev wget zlib-devel libffi-devel openssl-devel git make gcc && \
    yum clean packages &&  yum clean all && rm -rf /var/cache/yum && \
# Install python 3.8
    cd $MY_ROOT && \
    wget https://www.python.org/ftp/python/3.8.9/Python-3.8.9.tgz && tar xvf Python-3.8.9.tgz && rm -rf Python-3.8.9.tgz && \
    cd Python-3.8*/ && ./configure && make && make install && \
    cd ../ &&  mkdir -p /usr/bin/Python38 && ln -s Python-3.8.9/ /usr/bin/Python38 && \
# libusb1.0.22
    cd /opt/ && wget https://github.com/libusb/libusb/archive/v1.0.22.zip && \
    unzip v1.0.22.zip && rm -rf v1.0.22.zip && cd  /opt/libusb-1.0.22 && \
# bootstrap steps
    ./bootstrap.sh && \ 
    ./configure --disable-udev --enable-shared && \
    make -j4 && \
# configure libusb1.0.22
    cd /opt/libusb-1.0.22/libusb && \
    /bin/mkdir -p '/usr/local/lib' && \
    /bin/bash ../libtool   --mode=install /usr/bin/install -c   libusb-1.0.la '/usr/local/lib' && \
    /bin/mkdir -p '/usr/local/include/libusb-1.0' && \
    /usr/bin/install -c -m 644 libusb.h '/usr/local/include/libusb-1.0' && \
    /bin/mkdir -p '/usr/local/lib/pkgconfig' && \
# Install openvino
    cd /opt/ && mkdir intel/ && cd intel && \
    wget https://storage.openvinotoolkit.org/repositories/openvino/packages/2022.2/linux/l_openvino_toolkit_rhel8_2022.2.0.7713.af16ea1d79a_x86_64.tgz  && \
    tar xvf l_openvino_toolkit_rhel8_2022.2.0.7713.af16ea1d79a_x86_64.tgz && \
    rm -rf l_openvino_toolkit_rhel8_2022.2.0.7713.af16ea1d79a_x86_64.tgz && \
    mv l_openvino_toolkit_rhel8_2022.2.0.7713.af16ea1d79a_x86_64 openvino_2022.2.0.7713 && \
    cd ${INTEL_OPENVINO_DIR}/install_dependencies/ && ./install_openvino_dependencies.sh -y && ./install_NEO_OCL_driver.sh -y && \
    printf "\nexport LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:/usr/local/lib\n" >> /opt/intel/openvino_2022.2.0.7713/setupvars.sh && \
    cd /opt/libusb-1.0.22 && \
    /usr/bin/install -c -m 644 libusb-1.0.pc '/usr/local/lib/pkgconfig' && \
    cp /opt/intel/openvino_2022.2.0.7713/install_dependencies/97-myriad-usbboot.rules /etc/udev/rules.d/ && \
    ldconfig && \
#Install protobuf
    cd $MY_ROOT && \
    git clone https://github.com/protocolbuffers/protobuf.git && \
    cd protobuf && \ 
    git checkout v3.16.0 && \
    git submodule update --init --recursive && \
    mkdir build_source && cd build_source && \
    cmake ../cmake  -DCMAKE_INSTALL_LIBDIR=lib64 -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release && \
    make -j$(nproc) && \
    make install && \
# Build onnxruntime
    cd $MY_ROOT && \
    pip3 install numpy wheel setuptools cython && \
    git clone --recursive -b ${ONNXRUNTIME_BRANCH} ${ONNXRUNTIME_REPO} && \
    pip3 install onnx && \
    source /opt/intel/openvino_2022.2.0.7713/setupvars.sh && \
    cd /code/onnxruntime && ./build.sh --config Release --update --build --parallel --use_openvino ${DEVICE} --build_shared_lib --build_wheel && \
    pip3 install /code/onnxruntime/build/Linux/Release/dist/*-linux_x86_64.whl && \
# Clean up
    cd ${MY_ROOT} && rm -rf onnxruntime && rm -rf Python-3.8.9 && rm -rf protobuf

# Deploy stage
ARG BUILD_UID=1001
ARG BUILD_USER=onnxruntimedev
RUN adduser --uid $BUILD_UID $BUILD_USER
RUN usermod -a -G video,users,render ${BUILD_USER}
ENV WORKDIR_PATH /home/${BUILD_USER}

WORKDIR ${WORKDIR_PATH}
USER ${BUILD_USER}