|
| 1 | +#!/bin/bash |
| 2 | +# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 3 | +# |
| 4 | +# Redistribution and use in source and binary forms, with or without |
| 5 | +# modification, are permitted provided that the following conditions |
| 6 | +# are met: |
| 7 | +# * Redistributions of source code must retain the above copyright |
| 8 | +# notice, this list of conditions and the following disclaimer. |
| 9 | +# * Redistributions in binary form must reproduce the above copyright |
| 10 | +# notice, this list of conditions and the following disclaimer in the |
| 11 | +# documentation and/or other materials provided with the distribution. |
| 12 | +# * Neither the name of NVIDIA CORPORATION nor the names of its |
| 13 | +# contributors may be used to endorse or promote products derived |
| 14 | +# from this software without specific prior written permission. |
| 15 | +# |
| 16 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY |
| 17 | +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 19 | +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 20 | +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 21 | +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 22 | +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 23 | +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 24 | +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | + |
| 28 | +export TRITON_PATH="/home/ubuntu" |
| 29 | +export DEFAULT_REPO_TAG="main" |
| 30 | +export TRITON_COMMON_REPO_TAG=${DEFAULT_REPO_TAG} |
| 31 | +export TRITON_CORE_REPO_TAG=${DEFAULT_REPO_TAG} |
| 32 | +export TRITON_BACKEND_REPO_TAG=${DEFAULT_REPO_TAG} |
| 33 | +export TRITON_THIRD_PARTY_REPO_TAG=${DEFAULT_REPO_TAG} |
| 34 | +export IDENTITY_BACKEND_REPO_TAG=${DEFAULT_REPO_TAG} |
| 35 | +export PYTHON_BACKEND_REPO_TAG=${DEFAULT_REPO_TAG} |
| 36 | +export CHECKSUM_REPOAGENT_REPO_TAG=${DEFAULT_REPO_TAG} |
| 37 | +export TRITON_SERVER_BRANCH_NAME=${TRITON_SERVER_BRANCH_NAME:=${DEFAULT_REPO_TAG}} |
| 38 | +export TRITON_CLIENT_REPO_TAG=${TRITON_CLIENT_REPO_TAG:=${DEFAULT_REPO_TAG}} |
| 39 | +export TRITON_VERSION="2.17.0dev" |
| 40 | +export TRITON_CONTAINER_VERSION="21.12dev" |
| 41 | +export TRITON_UPSTREAM_CONTAINER_VERSION="21.10" |
| 42 | +export BASE_IMAGE=tritonserver |
| 43 | +export SDK_IMAGE=tritonserver_sdk |
| 44 | +export BUILD_IMAGE=tritonserver_build |
| 45 | +export QA_IMAGE=tritonserver_qa |
| 46 | + |
| 47 | +cd ${TRITON_PATH} |
| 48 | +# Clone necessary branches |
| 49 | +rm -rf ${TRITON_PATH}/server |
| 50 | +git clone --single-branch --depth=1 -b ${TRITON_SERVER_BRANCH_NAME} \ |
| 51 | + https://github.com/triton-inference-server/server.git |
| 52 | +echo ${TRITON_VERSION} > server/TRITON_VERSION |
| 53 | +cd ${TRITON_PATH}/server |
| 54 | +git clone --single-branch --depth=1 -b ${TRITON_CLIENT_REPO_TAG} \ |
| 55 | + https://github.com/triton-inference-server/client.git clientrepo |
| 56 | + |
| 57 | +# First set up inferentia and run in detatched mode |
| 58 | +cd ${TRITON_PATH}/python_backend |
| 59 | +chmod 777 ${TRITON_PATH}/python_backend/inferentia/scripts/setup-pre-container.sh |
| 60 | +sudo ${TRITON_PATH}/python_backend/inferentia/scripts/setup-pre-container.sh |
| 61 | + |
| 62 | +# Build container with only python backend |
| 63 | +cd ${TRITON_PATH}/server |
| 64 | +pip3 install docker |
| 65 | +./build.py --build-dir=/tmp/tritonbuild \ |
| 66 | + --cmake-dir=${TRITON_PATH}/server/build \ |
| 67 | + --version=${TRITON_VERSION} \ |
| 68 | + --container-version=${TRITON_CONTAINER_VERSION} \ |
| 69 | + --enable-logging --enable-stats --enable-tracing \ |
| 70 | + --enable-metrics --enable-gpu-metrics --enable-gpu \ |
| 71 | + --filesystem=gcs --filesystem=azure_storage --filesystem=s3 \ |
| 72 | + --endpoint=http --endpoint=grpc \ |
| 73 | + --repo-tag=common:${TRITON_COMMON_REPO_TAG} \ |
| 74 | + --repo-tag=core:${TRITON_CORE_REPO_TAG} \ |
| 75 | + --repo-tag=backend:${TRITON_BACKEND_REPO_TAG} \ |
| 76 | + --repo-tag=thirdparty:${TRITON_THIRD_PARTY_REPO_TAG} \ |
| 77 | + --backend=identity:${IDENTITY_BACKEND_REPO_TAG} \ |
| 78 | + --backend=python:${PYTHON_BACKEND_REPO_TAG} \ |
| 79 | + --repoagent=checksum:${CHECKSUM_REPOAGENT_REPO_TAG} |
| 80 | +docker tag tritonserver_build "${BUILD_IMAGE}" |
| 81 | +docker tag tritonserver "${BASE_IMAGE}" |
| 82 | + |
| 83 | +# Build docker container for SDK |
| 84 | +docker build -t ${SDK_IMAGE} \ |
| 85 | + -f ${TRITON_PATH}/server/Dockerfile.sdk \ |
| 86 | + --build-arg "TRITON_CLIENT_REPO_SUBDIR=clientrepo" . |
| 87 | + |
| 88 | +# Build QA container |
| 89 | +docker build -t ${QA_IMAGE} \ |
| 90 | + -f ${TRITON_PATH}/python_backend/inferentia/qa/Dockerfile.QA \ |
| 91 | + --build-arg "TRITON_PATH=${TRITON_PATH}" \ |
| 92 | + --build-arg "BASE_IMAGE=${BASE_IMAGE}" \ |
| 93 | + --build-arg "BUILD_IMAGE=${BUILD_IMAGE}" \ |
| 94 | + --build-arg "SDK_IMAGE=${SDK_IMAGE}" . |
| 95 | + |
| 96 | +export TEST_JSON_REPO=/opt/tritonserver/qa/common/inferentia_perf_analyzer_input_data_json |
| 97 | +export TEST_REPO=/opt/tritonserver/qa/L0_inferentia_perf_analyzer |
| 98 | +export TEST_SCRIPT="test.sh" |
| 99 | + |
| 100 | +# Run single instance test |
| 101 | +CONTAINER_NAME="qa_container" |
| 102 | +docker stop ${CONTAINER_NAME} && docker rm ${CONTAINER_NAME} |
| 103 | +docker create --name ${CONTAINER_NAME} \ |
| 104 | + --device /dev/neuron0 \ |
| 105 | + --device /dev/neuron1 \ |
| 106 | + --shm-size=1g --ulimit memlock=-1 \ |
| 107 | + -p 8000:8000 -p 8001:8001 -p 8002:8002 \ |
| 108 | + --ulimit stack=67108864 \ |
| 109 | + -e TEST_REPO=${TEST_REPO} \ |
| 110 | + -e TEST_JSON_REPO=${TEST_JSON_REPO} \ |
| 111 | + -e TRITON_PATH=${TRITON_PATH} \ |
| 112 | + --net host -ti ${QA_IMAGE} \ |
| 113 | + /bin/bash -c "bash -ex ${TEST_REPO}/${TEST_SCRIPT}" && \ |
| 114 | + docker cp /lib/udev ${CONTAINER_NAME}:/mylib/udev && \ |
| 115 | + docker cp /home/ubuntu/python_backend ${CONTAINER_NAME}:${TRITON_PATH}/python_backend && \ |
| 116 | + docker start -a ${CONTAINER_NAME} || RV=$?; |
0 commit comments