|
| 1 | +# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +ANALYZER_LOG="test.log" |
| 16 | +source ../common/util.sh |
| 17 | +source ../common/check_analyzer_results.sh |
| 18 | + |
| 19 | +rm -f *.log |
| 20 | +rm -rf results && mkdir -p results |
| 21 | + |
| 22 | +# Set test parameters |
| 23 | +MODEL_ANALYZER="`which model-analyzer`" |
| 24 | +REPO_VERSION=${NVIDIA_TRITON_SERVER_VERSION} |
| 25 | +MODEL_REPOSITORY=${MODEL_REPOSITORY:="/mnt/nvdl/datasets/inferenceserver/$REPO_VERSION/libtorch_model_store"} |
| 26 | +QA_MODELS="resnet50_libtorch" |
| 27 | +MODEL_NAMES="$(echo $QA_MODELS | sed 's/ /,/g')" |
| 28 | +TRITON_LAUNCH_MODE=${TRITON_LAUNCH_MODE:="local"} |
| 29 | +CLIENT_PROTOCOL="grpc" |
| 30 | +PORTS=(`find_available_ports 3`) |
| 31 | +GPUS=(`get_all_gpus_uuids`) |
| 32 | +OUTPUT_MODEL_REPOSITORY=${OUTPUT_MODEL_REPOSITORY:=`get_output_directory`} |
| 33 | +CONFIG_FILE="config.yml" |
| 34 | +EXPORT_PATH="`pwd`/results" |
| 35 | +FILENAME_SERVER_ONLY="server-metrics.csv" |
| 36 | +FILENAME_INFERENCE_MODEL="model-metrics-inference.csv" |
| 37 | +FILENAME_GPU_MODEL="model-metrics-gpu.csv" |
| 38 | + |
| 39 | +rm -rf $OUTPUT_MODEL_REPOSITORY |
| 40 | + |
| 41 | +python3 test_config_generator.py --profile-models $MODEL_NAMES |
| 42 | + |
| 43 | +# Run the analyzer and check the results |
| 44 | +RET=0 |
| 45 | + |
| 46 | +set +e |
| 47 | + |
| 48 | +MODEL_ANALYZER_ARGS="-m $MODEL_REPOSITORY -f $CONFIG_FILE" |
| 49 | +MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS --client-protocol=$CLIENT_PROTOCOL --triton-launch-mode=$TRITON_LAUNCH_MODE --run-config-search-mode=quick" |
| 50 | +MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS --triton-http-endpoint localhost:${PORTS[0]} --triton-grpc-endpoint localhost:${PORTS[1]}" |
| 51 | +MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS --triton-metrics-url http://localhost:${PORTS[2]}/metrics" |
| 52 | +MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS --output-model-repository-path $OUTPUT_MODEL_REPOSITORY --override-output-model-repository" |
| 53 | +MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS -e $EXPORT_PATH --filename-server-only=$FILENAME_SERVER_ONLY" |
| 54 | +MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS --filename-model-inference=$FILENAME_INFERENCE_MODEL --filename-model-gpu=$FILENAME_GPU_MODEL" |
| 55 | +MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS --skip-summary-reports" |
| 56 | +MODEL_ANALYZER_SUBCOMMAND="profile" |
| 57 | +run_analyzer |
| 58 | +if [ $? -ne 0 ]; then |
| 59 | + echo -e "\n***\n*** Test Failed. model-analyzer $MODEL_ANALYZER_SUBCOMMAND exited with non-zero exit code. \n***" |
| 60 | + cat $ANALYZER_LOG |
| 61 | + RET=1 |
| 62 | +else |
| 63 | + # Check the Analyzer log for correct output |
| 64 | + TEST_NAME='profile_logs' |
| 65 | + python3 check_results.py -f $CONFIG_FILE -t $TEST_NAME -l $ANALYZER_LOG |
| 66 | + if [ $? -ne 0 ]; then |
| 67 | + echo -e "\n***\n*** Test Output Verification Failed for $TEST_NAME test.\n***" |
| 68 | + cat $ANALYZER_LOG |
| 69 | + RET=1 |
| 70 | + fi |
| 71 | + |
| 72 | + SERVER_METRICS_FILE=${EXPORT_PATH}/results/${FILENAME_SERVER_ONLY} |
| 73 | + MODEL_METRICS_GPU_FILE=${EXPORT_PATH}/results/${FILENAME_GPU_MODEL} |
| 74 | + MODEL_METRICS_INFERENCE_FILE=${EXPORT_PATH}/results/${FILENAME_INFERENCE_MODEL} |
| 75 | + |
| 76 | + for file in SERVER_METRICS_FILE, MODEL_METRICS_GPU_FILE, MODEL_METRICS_INFERENCE_FILE; do |
| 77 | + check_no_csv_exists $file |
| 78 | + if [ $? -ne 0 ]; then |
| 79 | + echo -e "\n***\n*** Test Output Verification Failed.\n***" |
| 80 | + cat $ANALYZER_LOG |
| 81 | + RET=1 |
| 82 | + fi |
| 83 | + done |
| 84 | +fi |
| 85 | +set -e |
| 86 | + |
| 87 | +if [ $RET -eq 0 ]; then |
| 88 | + echo -e "\n***\n*** Test PASSED\n***" |
| 89 | +else |
| 90 | + echo -e "\n***\n*** Test FAILED\n***" |
| 91 | +fi |
| 92 | + |
| 93 | +exit $RET |
0 commit comments