From 38ae9043598defa5aae34ffa21940e059b88a62f Mon Sep 17 00:00:00 2001 From: saipj Date: Mon, 8 Jul 2019 16:36:06 -0700 Subject: [PATCH 1/3] Updated Dockerfile for OpenvinoEP Signed-off-by: avidiyal --- dockerfiles/Dockerfile.openvino | 105 ++++++++++++++++++++++++-------- dockerfiles/README.md | 93 ++++++++++++++++++++++------ 2 files changed, 153 insertions(+), 45 deletions(-) diff --git a/dockerfiles/Dockerfile.openvino b/dockerfiles/Dockerfile.openvino index 026879852d880..0daf4713d9ac8 100644 --- a/dockerfiles/Dockerfile.openvino +++ b/dockerfiles/Dockerfile.openvino @@ -1,37 +1,90 @@ -#------------------------------------------------------------------------- -# Copyright(C) 2019 Intel Corporation. -# Licensed under the MIT License. -#-------------------------------------------------------------------------- +# BSD 3-clause "New" or "Revised" license +# +# Copyright (C) 2018 Intel Coporation. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +FROM ubuntu:16.04 -ARG OS_VERSION=16.04 -FROM ubuntu:${OS_VERSION} +RUN apt update && \ + apt -y install python3.5 python3-pip zip x11-apps lsb-core wget cpio sudo libboost-python-dev libpng-dev zlib1g-dev git libnuma1 ocl-icd-libopencl1 clinfo libboost-filesystem1.58.0 libboost-thread1.58.0 protobuf-compiler libprotoc-dev && pip3 install numpy networkx opencv-python pytest && locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8 -ARG PYTHON_VERSION=3.5 -ARG OPENVINO_VERSION=2018_R5 -ARG TARGET_DEVICE=CPU_FP32 +ARG DEVICE=CPU_FP32 +ARG ONNXRUNTIME_REPO=https://github.com/microsoft/onnxruntime +ARG ONNXRUNTIME_BRANCH=master -ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update && \ - apt-get install -y sudo git bash +ENV pattern="COMPONENTS=DEFAULTS" +ENV replacement="COMPONENTS=intel-inference_engine_sdk__noarch;intel-inference_engine_cpu__noarch;intel-inference_engine_gpu__noarch;intel-inference_engine_vpu__noarch;intel-inference_engine_gna__noarch;intel-inference_engine_hddl__noarch;intel-model_optimizer__noarch;intel-opencv_ubuntu_16_rel__noarch" +COPY l_openvino_*.tgz . +RUN tar -xzf l_openvino_toolkit*.tgz && \ + rm -rf l_openvino_toolkit*.tgz && \ + cd l_openvino_toolkit* && \ + sed -i "s/$pattern/$replacement/" silent.cfg && \ + sed -i 's/decline/accept/g' silent.cfg && \ + ./install.sh -s silent.cfg && \ + /bin/bash -c "source /opt/intel/computer_vision_sdk/bin/setupvars.sh" && \ + ./install_cv_sdk_dependencies.sh && \ + cd - && \ + rm -rf l_openvino_toolkit* -ENV PATH="/opt/cmake/bin:${PATH}" -RUN git clone --branch preview-v0.7 --recursive https://github.com/intel/onnxruntime onnxruntime -RUN /onnxruntime/tools/ci_build/github/linux/docker/scripts/install_ubuntu.sh -p ${PYTHON_VERSION} && \ - /onnxruntime/tools/ci_build/github/linux/docker/scripts/install_deps.sh +ENV LD_LIBRARY_PATH=/usr/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH +ENV INSTALLDIR=/opt/intel/computer_vision_sdk +ENV INTEL_CVSDK_DIR=${INSTALLDIR} +ENV LD_LIBRARY_PATH=${INSTALLDIR}/deployment_tools/model_optimizer/model_optimizer_caffe/bin:${LD_LIBRARY_PATH} +ENV ModelOptimizer_ROOT_DIR=${INSTALLDIR}/deployment_tools/model_optimizer/model_optimizer_caffe +ENV InferenceEngine_DIR=${INTEL_CVSDK_DIR}/deployment_tools/inference_engine/share +ENV IE_PLUGINS_PATH=${INTEL_CVSDK_DIR}/deployment_tools/inference_engine/lib/ubuntu_16.04/intel64 +ENV LD_LIBRARY_PATH=/opt/intel/opencl:${INSTALLDIR}/deployment_tools/inference_engine/external/cldnn/lib:${INSTALLDIR}/inference_engine/external/gna/lib:${INSTALLDIR}/deployment_tools/inference_engine/external/mkltiny_lnx/lib:${INSTALLDIR}/deployment_tools/inference_engine/external/omp/lib:${IE_PLUGINS_PATH}:${LD_LIBRARY_PATH} +ENV OpenCV_DIR=${INSTALLDIR}/opencv/share/OpenCV +ENV LD_LIBRARY_PATH=${INSTALLDIR}/opencv/lib:${INSTALLDIR}/opencv/share/OpenCV/3rdparty/lib:${LD_LIBRARY_PATH} +ENV PATH=${INTEL_CVSDK_DIR}/deployment_tools/model_optimizer:$PATH +ENV PYTHONPATH=${INTEL_CVSDK_DIR}/deployment_tools/model_optimizer:$PYTHONPATH +ENV PYTHONPATH=$INTEL_CVSDK_DIR/python/python3.5:${INTEL_CVSDK_DIR}/python/python3.5/ubuntu16:${PYTHONPATH} +ENV HDDL_INSTALL_DIR=${INSTALLDIR}/deployment_tools/inference_engine/external/hddl +ENV LD_LIBRARY_PATH=${INSTALLDIR}/deployment_tools/inference_engine/external/hddl/lib:$LD_LIBRARY_PATH -RUN /onnxruntime/tools/ci_build/github/linux/docker/scripts/install_openvino.sh -o ${OPENVINO_VERSION} +RUN wget https://github.com/intel/compute-runtime/releases/download/19.15.12831/intel-gmmlib_19.1.1_amd64.deb +RUN wget https://github.com/intel/compute-runtime/releases/download/19.15.12831/intel-igc-core_1.0.2-1787_amd64.deb +RUN wget https://github.com/intel/compute-runtime/releases/download/19.15.12831/intel-igc-opencl_1.0.2-1787_amd64.deb +RUN wget https://github.com/intel/compute-runtime/releases/download/19.15.12831/intel-opencl_19.15.12831_amd64.deb +RUN wget https://github.com/intel/compute-runtime/releases/download/19.15.12831/intel-ocloc_19.15.12831_amd64.deb -WORKDIR / +RUN sudo dpkg -i *.deb && rm -rf *.deb -ENV INTEL_CVSDK_DIR /data/dldt -ENV LD_LIBRARY_PATH $INTEL_CVSDK_DIR/deployment_tools/inference_engine/lib/ubuntu_16.04/intel64:$INTEL_CVSDK_DIR/deployment_tools/inference_engine/temp/omp/lib:/usr/local/openblas/lib:$LD_LIBRARY_PATH +RUN mkdir -p /opt/cmake/bin + +ENV PATH /opt/cmake/bin:$PATH +ENV LANG en_US.UTF-8 +RUN wget https://github.com/Kitware/CMake/releases/download/v3.13.2/cmake-3.13.2-Linux-x86_64.tar.gz && \ + tar -xf cmake-3.13.2-Linux-x86_64.tar.gz --strip 1 -C /opt/cmake + +RUN /bin/bash -c "source /opt/intel/computer_vision_sdk/bin/setupvars.sh" && \ + git clone --recursive -b $ONNXRUNTIME_BRANCH $ONNXRUNTIME_REPO /onnxruntime && \ + cd /onnxruntime/cmake/external/onnx && python3 setup.py install && \ + cd /onnxruntime && ./build.sh --config RelWithDebInfo --update --build --parallel --use_openvino $DEVICE --build_wheel && pip3 install /onnxruntime/build/Linux/RelWithDebInfo/dist/*-linux_x86_64.whl && rm -rf /onnxruntime -ENV PATH $INTEL_CVSDK_DIR/deployment_tools/model_optimizer:$PATH -ENV PYTHONPATH $INTEL_CVSDK_DIR/deployment_tools/model_optimizer:$INTEL_CVSDK_DIR/tools:$PYTHONPATH -RUN mkdir -p /onnxruntime/build && \ - python3 /onnxruntime/tools/ci_build/build.py --build_dir /onnxruntime/build --config Release --build_shared_lib --skip_submodule_sync --build_wheel --parallel --use_openvino ${TARGET_DEVICE} && \ - pip3 install /onnxruntime/build/Release/dist/onnxruntime-*linux_x86_64.whl && \ - rm -rf /onnxruntime diff --git a/dockerfiles/README.md b/dockerfiles/README.md index 96aeb0f0c280a..823edf461d96d 100644 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -40,22 +40,77 @@ ## OpenVINO Version (Preview) #### Linux 16.04, Python Bindings - -1. Build the docker image from the Dockerfile in this repository. - ``` - # If you have a Linux machine, preface this command with "sudo" - - docker build -t onnxruntime-openvino -f Dockerfile.openvino . - ``` - To use GPU_FP32: - ``` - docker build -t onnxruntime-openvino --build-arg TARGET_DEVICE=GPU_FP32 -f Dockerfile.openvino . - ``` - -2. Run the Docker image - - ``` - # If you have a Linux machine, preface this command with "sudo" - - docker run -it onnxruntime-openvino - ``` \ No newline at end of file +1. Build the onnxruntime image for all the accelerators supported as below + + Retrieve your docker image in one of the following ways. + + - For building the docker image, download OpenVINO online installer version 2018 R5.0.1 from [here](https://software.intel.com/en-us/openvino-toolkit/choose-download) and copy the openvino tar file in the same directory and build the image. The online installer size is only 16MB and the components needed for the accelerators are mentioned in the dockerfile. + ``` + docker build -t onnxruntime -$device --build-arg DEVICE=$DEVICE . + ``` + - Pull the official image from DockerHub. + + +2. DEVICE: Specifies the hardware target for building OpenVINO Execution Provider. Below are the options for different Intel target devices. + + | Device Option | Target Device | + | --------- | -------- | + | CPU_FP32 | Intel CPUs | + | GPU_FP32 |Intel Integrated Graphics | + | GPU_FP16 | Intel Integrated Graphics | + | MYRIAD_FP16 | Intel MovidiusTM USB sticks | + | VAD-R_FP16 | Intel Vision Accelerator Design based on MovidiusTM MyriadX VPUs | + +## CPU Version + +1. Retrieve your docker image in one of the following ways. + + - Build the docker image from the DockerFile in this repository. Providing the argument device enables onnxruntime for that particular device. You can also provide arguments ONNXRUNTIME_REPO and ONNXRUNTIME_BRANCH to test that particular repo and branch. Default values are http://github.com/microsoft/onnxruntime and repo is master + + ``` + docker build -t onnxruntime-cpu --build-arg DEVICE=CPU_FP32 --network host . + ``` + ``` + docker build -t onnxruntime-cpu --build-arg DEVICE=CPU_FP32 --network host . + ``` + - Pull the official image from DockerHub. + ``` + # Will be available with next release + ``` +2. Run the docker image + ``` + docker run -it onnxruntime-cpu + ``` + +## GPU Version + +1. Retrieve your docker image in one of the following ways. + - Build the docker image from the DockerFile in this repository. + ``` + docker build -t onnxruntime-gpu --build-arg DEVICE=GPU_FP32 --network host . + ``` + - Pull the official image from DockerHub. + ``` + # Will be available with next release + ``` + +2. Run the docker image + ``` + docker run -it --device /dev/dri:/dev/dri onnxruntime-gpu:latest + ``` + +## VAD-R Accelerator Version + +1. Retrieve your docker image in one of the following ways. + - Build the docker image from the DockerFile in this repository. + ``` + docker build -t onnxruntime-vadr --build-arg DEVICE=VAD-R_FP16 --network host . + ``` + - Pull the official image from DockerHub. + ``` + # Will be available with ONNX Runtime 0.2.0 + ``` +2. Install the HDDL drivers on the host machine according to the reference in [here](https://docs.openvinotoolkit.org/latest/_docs_install_guides_installing_openvino_linux_ivad_vpu.html) +3. Run the docker image by mounting the device drivers + ``` + docker run -it --device --mount type=bind,source=/var/tmp,destination=/var/tmp --device /dev/ion:/dev/ion onnxruntime-hddl:latest From 026f5b6d4db3a3088f8d9b9235ebe4efa4a780c4 Mon Sep 17 00:00:00 2001 From: avidiyal Date: Mon, 8 Jul 2019 17:01:31 -0700 Subject: [PATCH 2/3] Changed the license Signed-off-by: avidiyal --- dockerfiles/Dockerfile.openvino | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/dockerfiles/Dockerfile.openvino b/dockerfiles/Dockerfile.openvino index 0daf4713d9ac8..528545321c8f4 100644 --- a/dockerfiles/Dockerfile.openvino +++ b/dockerfiles/Dockerfile.openvino @@ -1,31 +1,8 @@ -# BSD 3-clause "New" or "Revised" license -# -# Copyright (C) 2018 Intel Coporation. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# * Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#------------------------------------------------------------------------- +# Copyright(C) 2019 Intel Corporation. +# Licensed under the MIT License. +#-------------------------------------------------------------------------- + FROM ubuntu:16.04 RUN apt update && \ From e71437afd72a12f61d0871c1194493a6ce29cf88 Mon Sep 17 00:00:00 2001 From: avidiyal <41489828+avidiyal@users.noreply.github.com> Date: Tue, 9 Jul 2019 15:46:04 -0700 Subject: [PATCH 3/3] Update README.md --- dockerfiles/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dockerfiles/README.md b/dockerfiles/README.md index 823edf461d96d..3070ed303840d 100644 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -70,9 +70,7 @@ ``` docker build -t onnxruntime-cpu --build-arg DEVICE=CPU_FP32 --network host . ``` - ``` - docker build -t onnxruntime-cpu --build-arg DEVICE=CPU_FP32 --network host . - ``` + - Pull the official image from DockerHub. ``` # Will be available with next release