Skip to content

Commit

Permalink
Improve env test (triton-inference-server#3182)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tabrizian authored Aug 2, 2021
1 parent 4a29c54 commit 1362011
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
39 changes: 25 additions & 14 deletions qa/L0_backend_python/env/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,26 @@ wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null |
cmake-data=3.18.4-0kitware1ubuntu20.04.1 cmake=3.18.4-0kitware1ubuntu20.04.1
install_conda

# Create a model with python 3.9 version
create_conda_env "3.9" "python-3-9"
# Create a model with python 3.7 version
create_conda_env "3.7" "python-3-7"
conda install numpy=1.20.1 -y
conda install tensorflow=2.1.0 -y
create_python_backend_stub
conda-pack -o python3.9.tar.gz
path_to_conda_pack=`pwd`/python3.9.tar.gz
mkdir -p models/python_3_9/1/
cp ../../python_models/python_version/config.pbtxt ./models/python_3_9
(cd models/python_3_9 && \
sed -i "s/^name:.*/name: \"python_3_9\"/" config.pbtxt && \
conda-pack -o python3.7.tar.gz
path_to_conda_pack=`pwd`/python3.7.tar.gz
mkdir -p models/python_3_7/1/
cp ../../python_models/python_version/config.pbtxt ./models/python_3_7
(cd models/python_3_7 && \
sed -i "s/^name:.*/name: \"python_3_7\"/" config.pbtxt && \
echo "parameters: {key: \"EXECUTION_ENV_PATH\", value: {string_value: \"$path_to_conda_pack\"}}">> config.pbtxt)
cp ../../python_models/python_version/model.py ./models/python_3_9/1/
cp python_backend/builddir/triton_python_backend_stub ./models/python_3_9
cp ../../python_models/python_version/model.py ./models/python_3_7/1/
cp python_backend/builddir/triton_python_backend_stub ./models/python_3_7
conda deactivate

# Create a model with python 3.6 version
create_conda_env "3.6" "python-3-6"
conda install numpy=1.18.1 -y
conda install tensorflow=2.1.0 -y
conda-pack -o python3.6.tar.gz
path_to_conda_pack=`pwd`/python3.6.tar.gz
create_python_backend_stub
Expand All @@ -77,6 +79,7 @@ cp ../../python_models/python_version/config.pbtxt ./models/python_3_6
(cd models/python_3_6 && \
sed -i "s/^name:.*/name: \"python_3_6\"/" config.pbtxt && \
echo "parameters: {key: \"EXECUTION_ENV_PATH\", value: {string_value: \"$path_to_conda_pack\"}}" >> config.pbtxt)
rm -rf ./miniconda
cp ../../python_models/python_version/model.py ./models/python_3_6/1/
cp python_backend/builddir/triton_python_backend_stub ./models/python_3_6

Expand All @@ -91,17 +94,24 @@ kill $SERVER_PID
wait $SERVER_PID

set +e
grep "Python version is 3.6 and NumPy version is 1.18.1" $SERVER_LOG
grep "Python version is 3.6, NumPy version is 1.18.1, and Tensorflow version is 2.1.0" $SERVER_LOG
if [ $? -ne 0 ]; then
cat $SERVER_LOG
echo -e "\n***\n*** Python 3.6 and NumPy 1.18.1 was not found in Triton logs. \n***"
echo -e "\n***\n*** Python version is 3.6, NumPy version is 1.18.1, and Tensorflow version is 2.1.0 was not found in Triton logs. \n***"
RET=1
fi

grep "Python version is 3.9 and NumPy version is 1.20.1" $SERVER_LOG
grep "Python version is 3.7, NumPy version is 1.20.1, and Tensorflow version is 2.1.0" $SERVER_LOG
if [ $? -ne 0 ]; then
cat $SERVER_LOG
echo -e "\n***\n*** Python 3.9 and NumPy 1.20.1 was not found in Triton logs. \n***"
echo -e "\n***\n*** Python version is 3.7, NumPy version is 1.20.1, and Tensorflow version is 2.1.0 was not found in Triton logs. \n***"
RET=1
fi

grep "no version information available (required by /bin/bash)." $SERVER_LOG
if [ $? -eq 0 ]; then
cat $SERVER_LOG
echo -e "\n***\n*** \"no version information available (required by /bin/bash).\" was found in the server logs. \n***"
RET=1
fi
set -e
Expand All @@ -114,3 +124,4 @@ else
fi

exit $RET

9 changes: 8 additions & 1 deletion qa/python_models/python_version/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,21 @@

import numpy as np
import sys
import os
import triton_python_backend_utils as pb_utils


class TritonPythonModel:

def initialize(self, args):
import tensorflow
self.model_config = args['model_config']
print(f'Python version is {sys.version_info.major}.{sys.version_info.minor} and NumPy version is {np.version.version}', flush=True)
# This is to make sure that /bin/bash is not picking up
# the wrong shared libraries after installing Tensorflow.
# Tensorflow uses a shared library which is common with
# bash.
os.system('/bin/bash --help')
print(f'Python version is {sys.version_info.major}.{sys.version_info.minor}, NumPy version is {np.version.version}, and Tensorflow version is {tensorflow.__version__}', flush=True)

def execute(self, requests):
""" This function is called on inference request.
Expand Down

0 comments on commit 1362011

Please sign in to comment.