|
| 1 | +# |
| 2 | +# Copyright © 2021 Arm Ltd. All rights reserved. |
| 3 | +# SPDX-License-Identifier: MIT |
| 4 | +# |
| 5 | + |
| 6 | +# |
| 7 | +# Multistage build. |
| 8 | +# |
| 9 | + |
| 10 | +ARG BASE_IMAGE=tritonserver |
| 11 | +ARG ARMNN_TFLITE_BACKEND_IMAGE=armnn_tflite_backend |
| 12 | +ARG BUILD_IMAGE=tritonserver_build |
| 13 | +ARG TRITON_REPO_TAG=main |
| 14 | +ARG TRITON_COMMON_REPO_TAG=${TRITON_REPO_TAG} |
| 15 | +ARG TRITON_CORE_REPO_TAG=${TRITON_REPO_TAG} |
| 16 | +ARG TRITON_THIRD_PARTY_REPO_TAG=${TRITON_REPO_TAG} |
| 17 | +ARG TRITON_BACKEND_REPO_TAG=${TRITON_REPO_TAG} |
| 18 | +ARG TRITON_ENABLE_MALI_GPU=OFF |
| 19 | + |
| 20 | + |
| 21 | +############################################################################ |
| 22 | +## Build tests in the BUILD_IMAGE since it has already been configured |
| 23 | +## correctly and has some existing build artifacts. Copy artifacts |
| 24 | +## into QA area. |
| 25 | +############################################################################ |
| 26 | +FROM ${BUILD_IMAGE} AS build |
| 27 | + |
| 28 | +# Ensure apt-get won't prompt for selecting options |
| 29 | +ENV DEBIAN_FRONTEND=noninteractive |
| 30 | + |
| 31 | +# Build the client library and examples |
| 32 | +ARG TRITON_REPO_TAG |
| 33 | +ARG TRITON_COMMON_REPO_TAG |
| 34 | +ARG TRITON_CORE_REPO_TAG |
| 35 | +ARG TRITON_BACKEND_REPO_TAG |
| 36 | +ARG TRITON_THIRD_PARTY_REPO_TAG |
| 37 | +ARG TRITON_ENABLE_MALI_GPU |
| 38 | + |
| 39 | +RUN apt-get update && \ |
| 40 | + apt-get install -y --no-install-recommends \ |
| 41 | + software-properties-common \ |
| 42 | + autoconf \ |
| 43 | + automake \ |
| 44 | + build-essential \ |
| 45 | + curl \ |
| 46 | + git \ |
| 47 | + libb64-dev \ |
| 48 | + libopencv-dev \ |
| 49 | + libopencv-core-dev \ |
| 50 | + libssl-dev \ |
| 51 | + libtool \ |
| 52 | + pkg-config \ |
| 53 | + python3 \ |
| 54 | + python3-pip \ |
| 55 | + python3-dev \ |
| 56 | + rapidjson-dev \ |
| 57 | + vim \ |
| 58 | + wget \ |
| 59 | + python3-pdfkit \ |
| 60 | + maven \ |
| 61 | + default-jdk && \ |
| 62 | + pip3 install --upgrade wheel setuptools && \ |
| 63 | + pip3 install --upgrade grpcio-tools && \ |
| 64 | + pip3 install --upgrade pip |
| 65 | + |
| 66 | +# Build the client repo |
| 67 | +WORKDIR /workspace |
| 68 | +RUN git clone --single-branch --depth=1 -b ${TRITON_REPO_TAG} https://github.com/triton-inference-server/client.git client |
| 69 | +WORKDIR /workspace/build |
| 70 | +RUN cmake -DCMAKE_INSTALL_PREFIX=/workspace/install \ |
| 71 | + -DTRITON_VERSION=`cat /workspace/TRITON_VERSION` \ |
| 72 | + -DTRITON_COMMON_REPO_TAG=${TRITON_COMMON_REPO_TAG} \ |
| 73 | + -DTRITON_CORE_REPO_TAG=${TRITON_CORE_REPO_TAG} \ |
| 74 | + -DTRITON_BACKEND_REPO_TAG=${TRITON_BACKEND_REPO_TAG} \ |
| 75 | + -DTRITON_THIRD_PARTY_REPO_TAG=${TRITON_THIRD_PARTY_REPO_TAG} \ |
| 76 | + -DTRITON_ENABLE_CC_HTTP=ON -DTRITON_ENABLE_CC_GRPC=ON \ |
| 77 | + -DTRITON_ENABLE_PYTHON_HTTP=ON -DTRITON_ENABLE_PYTHON_GRPC=ON \ |
| 78 | + -DTRITON_ENABLE_JAVA_HTTP=ON \ |
| 79 | + -DTRITON_ENABLE_PERF_ANALYZER=ON \ |
| 80 | + -DTRITON_ENABLE_EXAMPLES=ON -DTRITON_ENABLE_TESTS=ON \ |
| 81 | + -DTRITON_ENABLE_GPU=OFF /workspace/client |
| 82 | +RUN make -j$(nproc) cc-clients python-clients java-clients |
| 83 | + |
| 84 | +WORKDIR /workspace |
| 85 | +RUN cd install && \ |
| 86 | + export VERSION=`cat /workspace/TRITON_VERSION` && \ |
| 87 | + tar zcf /workspace/v$VERSION.clients.tar.gz * |
| 88 | + |
| 89 | +# Install the dependencies needed to run the client examples. These |
| 90 | +# are not needed for building but including them allows this image to |
| 91 | +# be used to run the client examples. |
| 92 | +RUN pip3 install --upgrade numpy pillow attrdict && \ |
| 93 | + find install/python/ -maxdepth 1 -type f -name \ |
| 94 | + "tritonclient-*linux*.whl" | xargs printf -- '%s[all]' | \ |
| 95 | + xargs pip3 install --upgrade |
| 96 | + |
| 97 | +# Populate the /workspace/qa directory |
| 98 | +WORKDIR /workspace |
| 99 | +RUN mkdir -p qa/clients && mkdir -p qa/pkgs && \ |
| 100 | + cp -a install/bin/* qa/clients/. && \ |
| 101 | + cp install/lib/libgrpcclient.so qa/clients/. && \ |
| 102 | + cp install/lib/libhttpclient.so qa/clients/. && \ |
| 103 | + cp install/python/*.py qa/clients/. && \ |
| 104 | + cp install/python/triton*.whl qa/pkgs/. && \ |
| 105 | + cp install/java/examples/*.jar qa/clients/. |
| 106 | +RUN cp client/src/grpc_generated/go/*.go qa/L0_simple_go_client/. && \ |
| 107 | + cp -r client/src/grpc_generated/java qa/L0_client_java/. |
| 108 | + |
| 109 | + |
| 110 | +############################################################################ |
| 111 | +## Reference ArmNN TFLite image |
| 112 | +############################################################################ |
| 113 | +FROM $ARMNN_TFLITE_BACKEND_IMAGE as armnn_tflite_backend |
| 114 | + |
| 115 | +############################################################################ |
| 116 | +## Create CI enabled image |
| 117 | +############################################################################ |
| 118 | +FROM $BASE_IMAGE |
| 119 | + |
| 120 | +ARG TARGETPLATFORM |
| 121 | + |
| 122 | +# Ensure apt-get won't prompt for selecting options |
| 123 | +ENV DEBIAN_FRONTEND=noninteractive |
| 124 | + |
| 125 | +# CI/QA for memcheck requires valgrind |
| 126 | +# libarchive-dev is required by Python backend |
| 127 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 128 | + curl \ |
| 129 | + libopencv-dev \ |
| 130 | + libarchive-dev \ |
| 131 | + libopencv-core-dev \ |
| 132 | + libzmq3-dev \ |
| 133 | + python3-dev \ |
| 134 | + python3-pip \ |
| 135 | + python3-protobuf \ |
| 136 | + python3-setuptools \ |
| 137 | + swig \ |
| 138 | + nginx \ |
| 139 | + libpng-dev \ |
| 140 | + protobuf-compiler \ |
| 141 | + g++ \ |
| 142 | + maven \ |
| 143 | + jq \ |
| 144 | + valgrind && \ |
| 145 | + rm -rf /var/lib/apt/lists/* |
| 146 | + |
| 147 | +# CI/QA expects "python" executable (not python3). |
| 148 | +RUN rm -f /usr/bin/python && \ |
| 149 | + ln -s /usr/bin/python3 /usr/bin/python |
| 150 | + |
| 151 | +RUN pip3 install --upgrade wheel setuptools && \ |
| 152 | + pip3 install --upgrade numpy pillow attrdict future grpcio requests gsutil awscli six grpcio-channelz && \ |
| 153 | + pip3 install --upgrade pytest pytest-xdist pytest-xprocess jinja2 |
| 154 | + |
| 155 | +# CI expects tests in /opt/tritonserver/qa. The triton-server (1000) |
| 156 | +# user should own all artifacts in case CI is run using triton-server |
| 157 | +# user. |
| 158 | +WORKDIR /opt/tritonserver |
| 159 | +COPY --chown=1000:1000 --from=build /workspace/qa/ qa/ |
| 160 | + |
| 161 | +# Copy in identity backend used in some qa tests |
| 162 | +COPY --from=build /tmp/tritonbuild/identity/install/backends/identity /opt/tritonserver/backends/identity |
| 163 | + |
| 164 | +# Copy in pytest files from the current repo |
| 165 | +# These are the tests we use to validate the backend functionality |
| 166 | +COPY qa/ qa/armnn_tflite_qa |
| 167 | + |
| 168 | +# Remove CI tests that are meant to run only on build image and |
| 169 | +# install the tritonserver/triton python client APIs. |
| 170 | +RUN rm -fr qa/L0_copyrights qa/L0_build_variants && \ |
| 171 | + find qa/pkgs/ -maxdepth 1 -type f -name \ |
| 172 | + "tritonclient-*linux*.whl" | xargs printf -- '%s[all]' | \ |
| 173 | + xargs pip3 install --upgrade |
| 174 | + |
| 175 | +ENV LD_LIBRARY_PATH /opt/tritonserver/qa/clients:${LD_LIBRARY_PATH} |
| 176 | + |
| 177 | +# Copy in the built armnn_tflite_backend |
| 178 | +COPY --from=armnn_tflite_backend /opt/armnn_tflite_backend/build/install/backends/armnn_tflite /opt/tritonserver/backends/armnn_tflite |
| 179 | + |
0 commit comments