From aa38893afb299003754bb59f66dec4bd99fd1a18 Mon Sep 17 00:00:00 2001 From: "S. Manohar Karlapalem" Date: Fri, 30 Oct 2020 11:27:15 -0700 Subject: [PATCH] [OpenVINO-EP] Add Dockerfile with C# API bindings (#5633) * Update Dockerfile README with C# info * Add OpenVINO EP dockerfile with C# APIs --- dockerfiles/Dockerfile.openvino-csharp | 89 ++++++++++++++++++++++++++ dockerfiles/README.md | 14 ++-- 2 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 dockerfiles/Dockerfile.openvino-csharp diff --git a/dockerfiles/Dockerfile.openvino-csharp b/dockerfiles/Dockerfile.openvino-csharp new file mode 100644 index 0000000000..66e7173822 --- /dev/null +++ b/dockerfiles/Dockerfile.openvino-csharp @@ -0,0 +1,89 @@ +#------------------------------------------------------------------------- +# Copyright(C) 2019 Intel Corporation. +# Licensed under the MIT License. +#-------------------------------------------------------------------------- + +FROM ubuntu:18.04 + +ARG DEVICE=CPU_FP32 +ARG ONNXRUNTIME_REPO=https://github.com/microsoft/onnxruntime.git +ARG ONNXRUNTIME_BRANCH=master + +WORKDIR /code +ARG MY_ROOT=/code + +ENV PATH /opt/miniconda/bin:/code/cmake-3.14.3-Linux-x86_64/bin:$PATH +ENV LD_LIBRARY_PATH=/opt/miniconda/lib:/usr/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH + +ENV INTEL_OPENVINO_DIR=/opt/intel/openvino_2021.1.110 +ENV InferenceEngine_DIR=${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/share +ENV IE_PLUGINS_PATH=${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/lib/intel64 +ENV LD_LIBRARY_PATH=/opt/intel/opencl:${INTEL_OPENVINO_DIR}/inference_engine/external/gna/lib:${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/external/mkltiny_lnx/lib:$INTEL_OPENVINO_DIR/deployment_tools/ngraph/lib:${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/external/omp/lib:${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/external/tbb/lib:${IE_PLUGINS_PATH}:${LD_LIBRARY_PATH} +ENV OpenCV_DIR=${INTEL_OPENVINO_DIR}/opencv/share/OpenCV +ENV LD_LIBRARY_PATH=${INTEL_OPENVINO_DIR}/opencv/lib:${INTEL_OPENVINO_DIR}/opencv/share/OpenCV/3rdparty/lib:${LD_LIBRARY_PATH} +ENV HDDL_INSTALL_DIR=${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/external/hddl +ENV LD_LIBRARY_PATH=${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/external/hddl/lib:$LD_LIBRARY_PATH +ENV LANG en_US.UTF-8 +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt update && \ + apt -y install apt-transport-https ca-certificates python3 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.65-dev libboost-thread1.65-dev protobuf-compiler libprotoc-dev autoconf automake libtool libjson-c-dev unattended-upgrades && \ + unattended-upgrade && \ + rm -rf /var/lib/apt/lists/* && \ +# Install OpenVINO + cd ${MY_ROOT} && \ + wget https://apt.repos.intel.com/openvino/2021/GPG-PUB-KEY-INTEL-OPENVINO-2021 && \ + apt-key add GPG-PUB-KEY-INTEL-OPENVINO-2021 && rm GPG-PUB-KEY-INTEL-OPENVINO-2021 && \ + cd /etc/apt/sources.list.d && \ + echo "deb https://apt.repos.intel.com/openvino/2021 all main">intel-openvino-2021.list && \ + apt update && \ + apt -y install intel-openvino-dev-ubuntu18-2021.1.110 && \ + cd ${INTEL_OPENVINO_DIR}/install_dependencies && ./install_openvino_dependencies.sh && \ + cd ${INTEL_OPENVINO_DIR} && rm -rf documentation && cd deployment_tools/ && rm -rf model_optimizer open_model_zoo demo && cd inference_engine && rm -rf samples && \ +# Install GPU runtime and drivers + cd ${MY_ROOT} && \ + mkdir /tmp/opencl && \ + cd /tmp/opencl && \ + apt update && \ + apt install -y --no-install-recommends ocl-icd-libopencl1 && \ + rm -rf /var/lib/apt/lists/* && \ + wget "https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-gmmlib_19.3.2_amd64.deb" && \ + wget "https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-igc-core_1.0.2597_amd64.deb" && \ + wget "https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-igc-opencl_1.0.2597_amd64.deb" && \ + wget "https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-opencl_19.41.14441_amd64.deb" && \ + wget "https://github.com/intel/compute-runtime/releases/download/19.41.14441/intel-ocloc_19.41.14441_amd64.deb" && \ + dpkg -i /tmp/opencl/*.deb && \ + ldconfig && \ + rm -rf /tmp/opencl && \ +# Install Mono + cd ${MY_ROOT} && \ + apt install -y gnupg ca-certificates && \ + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \ + echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list && \ + apt update && \ + apt install -y mono-devel && \ +# Install nuget.exe + wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe && \ + mv nuget.exe /usr/local/bin/nuget.exe && \ + echo 'mono /usr/local/bin/nuget.exe $@' > /usr/local/bin/nuget && \ + chmod a+x /usr/local/bin/nuget && \ +# Install .NET core + wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \ + dpkg -i packages-microsoft-prod.deb && \ + apt-get update &&\ + apt-get install -y apt-transport-https && \ + apt-get update && \ + apt-get install -y dotnet-sdk-3.1 && \ +# Download and build ONNX Runtime + cd ${MY_ROOT} && \ + git clone --recursive -b ${ONNXRUNTIME_BRANCH} ${ONNXRUNTIME_REPO} && \ + /bin/sh onnxruntime/dockerfiles/scripts/install_common_deps.sh && \ + cd onnxruntime/cmake/external/onnx && python3 setup.py install && \ + cd ${MY_ROOT}/onnxruntime && ./build.sh --config Release --update --build --parallel --use_openvino ${DEVICE} --build_nuget && \ + mv ${MY_ROOT}/onnxruntime/build/Linux/Release/nuget-artifacts ${MY_ROOT} && \ +# Clean-up unnecessary files + rm -rf ${MY_ROOT}/cmake* /opt/cmake ${MY_ROOT}/onnxruntime && \ + rm -rf /opt/miniconda && \ + rm -rf /opt/intel/openvino/data_processing && \ + rm -rf /opt/intel/openvino/deployment_tools/tools && \ + apt remove -y git && apt autoremove -y diff --git a/dockerfiles/README.md b/dockerfiles/README.md index 687828eade..52ebee7a35 100644 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -114,15 +114,15 @@ Therefore, ONNX RT Execution Provider for **nGraph** will be deprecated starting ## OpenVINO *Public Preview* -**Ubuntu 18.04, Python Bindings** +**Ubuntu 18.04, Python & C# Bindings** 1. Build the onnxruntime image for one of the accelerators supported below. Retrieve your docker image in one of the following ways. - - Choose Dockerfile.openvino as the dockerfile for building an OpenVINO 2021.1 based Docker image. Providing the docker build argument DEVICE enables the onnxruntime build for that particular device. You can also provide arguments ONNXRUNTIME_REPO and ONNXRUNTIME_BRANCH to test that particular repo and branch. Default repository is http://github.com/microsoft/onnxruntime and default branch is master. + - Choose Dockerfile.openvino for Python API or Dockerfile.openvino-csharp for C# API as for building an OpenVINO 2021.1 based Docker image. Providing the docker build argument DEVICE enables the onnxruntime build for that particular device. You can also provide arguments ONNXRUNTIME_REPO and ONNXRUNTIME_BRANCH to test that particular repo and branch. Default repository is http://github.com/microsoft/onnxruntime and default branch is master. ``` - docker build --rm -t onnxruntime --build-arg DEVICE=$DEVICE -f Dockerfile.openvino . + docker build --rm -t onnxruntime --build-arg DEVICE=$DEVICE -f . ``` - Pull the official image from DockerHub. @@ -143,7 +143,7 @@ Therefore, ONNX RT Execution Provider for **nGraph** will be deprecated starting 1. Build the docker image from the DockerFile in this repository. ``` - docker build --rm -t onnxruntime-cpu --build-arg DEVICE=CPU_FP32 --network host -f Dockerfile.openvino . + docker build --rm -t onnxruntime-cpu --build-arg DEVICE=CPU_FP32 --network host -f . ``` 2. Run the docker image ``` @@ -154,7 +154,7 @@ Therefore, ONNX RT Execution Provider for **nGraph** will be deprecated starting 1. Build the docker image from the DockerFile in this repository. ``` - docker build --rm -t onnxruntime-gpu --build-arg DEVICE=GPU_FP32 --network host -f Dockerfile.openvino . + docker build --rm -t onnxruntime-gpu --build-arg DEVICE=GPU_FP32 --network host -f . ``` 2. Run the docker image ``` @@ -164,7 +164,7 @@ Therefore, ONNX RT Execution Provider for **nGraph** will be deprecated starting 1. Build the docker image from the DockerFile in this repository. ``` - docker build --rm -t onnxruntime-myriad --build-arg DEVICE=MYRIAD_FP16 --network host -f Dockerfile.openvino . + docker build --rm -t onnxruntime-myriad --build-arg DEVICE=MYRIAD_FP16 --network host -f . ``` 2. Install the Myriad rules drivers on the host machine according to the reference in [here](https://docs.openvinotoolkit.org/latest/_docs_install_guides_installing_openvino_linux.html#additional-NCS-steps) @@ -182,7 +182,7 @@ Therefore, ONNX RT Execution Provider for **nGraph** will be deprecated starting 3. Build the docker image from the DockerFile in this repository. ``` - docker build --rm -t onnxruntime-vadm --build-arg DEVICE=VAD-M_FP16 --network host -f Dockerfile.openvino . + docker build --rm -t onnxruntime-vadm --build-arg DEVICE=VAD-M_FP16 --network host -f . ``` 4. Run hddldaemon on the host in a separate terminal session using the following command:  ```