|
| 1 | +#!/bin/bash |
| 2 | +# Copyright 2023, 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 | +REPO_VERSION=${NVIDIA_TRITON_SERVER_VERSION} |
| 29 | +if [ "$#" -ge 1 ]; then |
| 30 | + REPO_VERSION=$1 |
| 31 | +fi |
| 32 | +if [ -z "$REPO_VERSION" ]; then |
| 33 | + echo -e "Repository version must be specified" |
| 34 | + echo -e "\n***\n*** Test Failed\n***" |
| 35 | + exit 1 |
| 36 | +fi |
| 37 | +if [ ! -z "$TEST_REPO_ARCH" ]; then |
| 38 | + REPO_VERSION=${REPO_VERSION}_${TEST_REPO_ARCH} |
| 39 | +fi |
| 40 | + |
| 41 | +pip3 uninstall -y torch |
| 42 | +pip3 install torch |
| 43 | + |
| 44 | +DATADIR=/data/inferenceserver/${REPO_VERSION}/qa_model_repository |
| 45 | +SERVER=/opt/tritonserver/bin/tritonserver |
| 46 | +SERVER_ARGS="--model-repository=models --log-verbose=1" |
| 47 | +SERVER_LOG="./inference_server.log" |
| 48 | + |
| 49 | +CLIENT_PY=./client.py |
| 50 | +CLIENT_LOG="./client.log" |
| 51 | +EXPECTED_NUM_TESTS="1" |
| 52 | +TEST_RESULT_FILE='test_results.txt' |
| 53 | + |
| 54 | +source ../common/util.sh |
| 55 | + |
| 56 | +RET=0 |
| 57 | + |
| 58 | +rm -f *.log *.txt |
| 59 | + |
| 60 | +mkdir -p models/libtorch_multi_gpu/1 |
| 61 | +cp models/libtorch_multi_devices/config.pbtxt models/libtorch_multi_gpu/. |
| 62 | +(cd models/libtorch_multi_gpu && \ |
| 63 | + sed -i "s/name: \"libtorch_multi_devices\"/name: \"libtorch_multi_gpu\"/" config.pbtxt) |
| 64 | + |
| 65 | +# Generate the models which are partioned across multiple devices |
| 66 | +set +e |
| 67 | +python3 gen_models.py >> $CLIENT_LOG 2>&1 |
| 68 | +if [ $? -ne 0 ]; then |
| 69 | + echo -e "\n***\n*** Error when generating models. \n***" |
| 70 | + cat $CLIENT_LOG |
| 71 | + RET=1 |
| 72 | +fi |
| 73 | +set -e |
| 74 | + |
| 75 | +# Create the model that does not set instance_group_kind to 'KIND_MODEL' |
| 76 | +mkdir -p models/libtorch_instance_kind_err/1 |
| 77 | +cp models/libtorch_multi_devices/config.pbtxt models/libtorch_instance_kind_err/. |
| 78 | +cp models/libtorch_multi_devices/1/model.pt models/libtorch_instance_kind_err/1/. |
| 79 | +(cd models/libtorch_instance_kind_err && \ |
| 80 | + sed -i "s/name: \"libtorch_multi_devices\"/name: \"libtorch_instance_kind_err\"/" config.pbtxt && \ |
| 81 | + sed -i "s/kind: KIND_MODEL/kind: KIND_GPU/" config.pbtxt) |
| 82 | + |
| 83 | +run_server |
| 84 | +if [ "$SERVER_PID" == "0" ]; then |
| 85 | + echo -e "\n***\n*** Failed to start $SERVER\n***" |
| 86 | + cat $SERVER_LOG |
| 87 | + exit 1 |
| 88 | +fi |
| 89 | + |
| 90 | +set +e |
| 91 | + |
| 92 | +MESSAGE="INPUT0 device: cpu, INPUT1 device: cuda:3" |
| 93 | +export MODEL_NAME='libtorch_multi_devices' |
| 94 | +python3 $CLIENT_PY >> $CLIENT_LOG 2>&1 |
| 95 | +if [ $? -ne 0 ]; then |
| 96 | + echo -e "\n***\n*** Model $MODEL_NAME FAILED. \n***" |
| 97 | + cat $CLIENT_LOG |
| 98 | + RET=1 |
| 99 | +else |
| 100 | + check_test_results $TEST_RESULT_FILE $EXPECTED_NUM_TESTS |
| 101 | + if [ $? -ne 0 ]; then |
| 102 | + cat $CLIENT_LOG |
| 103 | + echo -e "\n***\n*** Test Result Verification Failed\n***" |
| 104 | + RET=1 |
| 105 | + fi |
| 106 | +fi |
| 107 | + |
| 108 | +if grep "$MESSAGE" $SERVER_LOG; then |
| 109 | + echo -e "Found \"$MESSAGE\"" >> $CLIENT_LOG |
| 110 | +else |
| 111 | + echo -e "Not found \"$MESSAGE\"" >> $CLIENT_LOG |
| 112 | + RET=1 |
| 113 | +fi |
| 114 | + |
| 115 | +MESSAGE="INPUT0 device: cuda:2, INPUT1 device: cuda:0" |
| 116 | +export MODEL_NAME='libtorch_multi_gpu' |
| 117 | +python3 $CLIENT_PY >> $CLIENT_LOG 2>&1 |
| 118 | +if [ $? -ne 0 ]; then |
| 119 | + echo -e "\n***\n*** Model $MODEL_NAME FAILED. \n***" |
| 120 | + cat $CLIENT_LOG |
| 121 | + RET=1 |
| 122 | +else |
| 123 | + check_test_results $TEST_RESULT_FILE $EXPECTED_NUM_TESTS |
| 124 | + if [ $? -ne 0 ]; then |
| 125 | + cat $CLIENT_LOG |
| 126 | + echo -e "\n***\n*** Test Result Verification Failed\n***" |
| 127 | + RET=1 |
| 128 | + fi |
| 129 | +fi |
| 130 | + |
| 131 | +if grep "$MESSAGE" $SERVER_LOG; then |
| 132 | + echo -e "Found \"$MESSAGE\"" >> $CLIENT_LOG |
| 133 | +else |
| 134 | + echo -e "Not found \"$MESSAGE\"" >> $CLIENT_LOG |
| 135 | + RET=1 |
| 136 | +fi |
| 137 | + |
| 138 | +MESSAGE="INPUT0 device: cuda:2, INPUT1 device: cuda:0" |
| 139 | +export MODEL_NAME='libtorch_instance_kind_err' |
| 140 | +python3 $CLIENT_PY >> $CLIENT_LOG 2>&1 |
| 141 | +if [ $? -ne 0 ]; then |
| 142 | + echo -e "\n***\n*** Model $MODEL_NAME FAILED. \n***" |
| 143 | + cat $CLIENT_LOG |
| 144 | + RET=1 |
| 145 | +else |
| 146 | + check_test_results $TEST_RESULT_FILE $EXPECTED_NUM_TESTS |
| 147 | + if [ $? -ne 0 ]; then |
| 148 | + cat $CLIENT_LOG |
| 149 | + echo -e "\n***\n*** Test Result Verification Failed\n***" |
| 150 | + RET=1 |
| 151 | + fi |
| 152 | +fi |
| 153 | + |
| 154 | +set -e |
| 155 | + |
| 156 | +kill $SERVER_PID |
| 157 | +wait $SERVER_PID |
| 158 | + |
| 159 | +if [ $RET -eq 0 ]; then |
| 160 | + echo -e "\n***\n*** Test Passed\n***" |
| 161 | +else |
| 162 | + cat $CLIENT_LOG |
| 163 | + echo -e "\n***\n*** Test FAILED\n***" |
| 164 | +fi |
| 165 | + |
| 166 | +exit $RET |
0 commit comments