forked from microsoft/onnxruntime
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile.openvino-csharp
More file actions
90 lines (73 loc) · 3.36 KB
/
Dockerfile.openvino-csharp
File metadata and controls
90 lines (73 loc) · 3.36 KB
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
#-------------------------------------------------------------------------
# Copyright(C) 2021-2023 Intel Corporation.
# SPDX-License-Identifier: MIT
#--------------------------------------------------------------------------
ARG OPENVINO_VERSION=2023.0.0
# Build stage
FROM openvino/ubuntu20_runtime:${OPENVINO_VERSION} AS base
ENV WORKDIR_PATH=/home/openvino
WORKDIR $WORKDIR_PATH
ENV DEBIAN_FRONTEND noninteractive
USER root
RUN apt update; apt install -y --no-install-recommends wget gnupg && \
rm -rf /var/lib/apt/lists/*
# Install Mono
RUN wget http://download.mono-project.com/repo/xamarin.gpg && apt-key add xamarin.gpg && rm xamarin.gpg && \
echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | tee /etc/apt/sources.list.d/mono-official-stable.list && \
apt update -y && \
apt install -y mono-devel
# Install nuget.exe
RUN 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
RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
apt-get update -y &&\
apt-get install -y apt-transport-https && \
apt-get update -y && \
apt-get install -y dotnet-sdk-5.0
# Build stage
FROM base AS builder
ENV WORKDIR_PATH=/home/openvino
WORKDIR $WORKDIR_PATH
ENV DEBIAN_FRONTEND noninteractive
ARG DEVICE=CPU_FP32
ARG ONNXRUNTIME_REPO=https://github.com/microsoft/onnxruntime.git
ARG ONNXRUNTIME_BRANCH=main
ENV InferenceEngine_DIR=${INTEL_OPENVINO_DIR}/runtime/cmake
ENV LANG en_US.UTF-8
USER root
RUN apt update; apt install -y --no-install-recommends git protobuf-compiler libprotobuf-dev ca-certificates unattended-upgrades && \
unattended-upgrade && \
rm -rf /var/lib/apt/lists/*
RUN git clone --recursive -b ${ONNXRUNTIME_BRANCH} ${ONNXRUNTIME_REPO}
RUN /bin/sh onnxruntime/dockerfiles/scripts/install_common_deps.sh
RUN ln -s cmake-* cmake-dir
RUN python3 -m pip install wheel
ENV PATH=${WORKDIR_PATH}/cmake-dir/bin:$PATH
RUN pip3 install onnx
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN apt install locales && \
locale-gen en_US en_US.UTF-8 && \
dpkg-reconfigure locales
RUN cd onnxruntime && ./build.sh --allow_running_as_root --config Release --update --build --parallel --use_openvino ${DEVICE} --build_nuget --build_shared_lib
RUN cp /home/openvino/onnxruntime/build/Linux/Release/Microsoft.ML.OnnxRuntime.Managed* /home/openvino/onnxruntime/build/Linux/Release/nuget-artifacts
# Deploy stage
FROM base
ENV DEBIAN_FRONTEND noninteractive
USER root
RUN apt update; apt install -y unattended-upgrades fonts-freefont-ttf && \
unattended-upgrade
ARG BUILD_UID=1001
ARG BUILD_USER=onnxruntimedev
RUN adduser --uid $BUILD_UID $BUILD_USER
RUN usermod -a -G video,users ${BUILD_USER}
ENV WORKDIR_PATH /home/${BUILD_USER}
WORKDIR ${WORKDIR_PATH}
COPY --from=builder /home/openvino/onnxruntime/build/Linux/Release/nuget-artifacts ${WORKDIR_PATH}/nuget-artifacts
USER ${BUILD_USER}
ENV PATH=${WORKDIR_PATH}/miniconda/bin:${WORKDIR_PATH}/cmake-dir/bin:$PATH
ENV IE_PLUGINS_PATH=${INTEL_OPENVINO_DIR}/runtime/lib/intel64
ENV LD_LIBRARY_PATH=/opt/intel/opencl:${INTEL_OPENVINO_DIR}/runtime/3rdparty/tbb/lib:${IE_PLUGINS_PATH}:${LD_LIBRARY_PATH}