Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test python environments 3.8-3.11 #6109

Merged
merged 13 commits into from
Aug 8, 2023
113 changes: 112 additions & 1 deletion qa/L0_backend_python/env/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ cp python3.6.tar.gz models/python_3_6/python_3_6_environment.tar.gz
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_6/1/
cp python_backend/builddir/triton_python_backend_stub ./models/python_3_6
conda deactivate

# Test conda env without custom Python backend stub This environment should
# always use the default Python version shipped in the container. For Ubuntu 22.04
Expand All @@ -126,7 +127,7 @@ cp python3.10.tar.gz models/python_3_10/python_3_10_environment.tar.gz
sed -i "s/^name:.*/name: \"python_3_10\"/" 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_10/1/
rm -rf ./miniconda
conda deactivate

run_server
if [ "$SERVER_PID" == "0" ]; then
Expand All @@ -148,6 +149,116 @@ for EXPECTED_VERSION_STRING in "$PY36_VERSION_STRING" "$PY37_VERSION_STRING" "$P
fi
done

# Test other python versions
conda update -n base -c defaults conda -y
rm $SERVER_LOG
# Create a model with python 3.8 version
# Successful execution of the Python model indicates that the environment has
# been setup correctly.

create_conda_env "3.8" "python-3-8"
conda install -c conda-forge libstdcxx-ng=12 -y
conda install numpy=1.23.4 -y
conda install tensorflow=2.10.0 -y
PY38_VERSION_STRING="Python version is 3.8, NumPy version is 1.23.4, and Tensorflow version is 2.10.0"

create_python_backend_stub
conda-pack -o python3.8.tar.gz
path_to_conda_pack="$PWD/python-3-8"
mkdir -p $path_to_conda_pack
tar -xzf python3.8.tar.gz -C $path_to_conda_pack
mkdir -p models/python_3_8/1/
cp ../../python_models/python_version/config.pbtxt ./models/python_3_8
(cd models/python_3_8 && \
sed -i "s/^name:.*/name: \"python_3_8\"/" 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_8/1/
cp python_backend/builddir/triton_python_backend_stub ./models/python_3_8
# copy the stub out to /opt/tritonserver/backends/python/3-8
mkdir -p /opt/tritonserver/backends/python/3-8
cp python_backend/builddir/triton_python_backend_stub /opt/tritonserver/backends/python/3-8/triton_python_backend_stub
conda deactivate

# Create a model with python 3.9 version
# Successful execution of the Python model indicates that the environment has
# been setup correctly.
create_conda_env "3.9" "python-3-9"
conda install -c conda-forge libstdcxx-ng=12 -y
conda install numpy=1.23.4 -y
conda install tensorflow=2.10.0 -y
PY39_VERSION_STRING="Python version is 3.9, NumPy version is 1.23.4, and Tensorflow version is 2.10.0"
create_python_backend_stub
conda-pack -o python3.9.tar.gz
path_to_conda_pack="$PWD/python-3-9"
mkdir -p $path_to_conda_pack
tar -xzf python3.9.tar.gz -C $path_to_conda_pack
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 && \
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
# copy the stub out to /opt/tritonserver/backends/python/3-9
mkdir -p /opt/tritonserver/backends/python/3-9
cp python_backend/builddir/triton_python_backend_stub /opt/tritonserver/backends/python/3-9/triton_python_backend_stub
conda deactivate

# Create a model with python 3.11 version
# Successful execution of the Python model indicates that the environment has
# been setup correctly.
create_conda_env "3.11" "python-3-11"
# tensorflow needs to be installed before numpy so pip does not mess up conda
# environment
pip install tensorflow==2.12.0
conda install -c conda-forge libstdcxx-ng=12 -y
conda install numpy=1.23.5 -y
PY311_VERSION_STRING="Python version is 3.11, NumPy version is 1.23.5, and Tensorflow version is 2.12.0"

create_python_backend_stub
conda-pack -o python3.11.tar.gz
path_to_conda_pack=`pwd`/python3.11.tar.gz
path_to_conda_pack="$PWD/python-3-11"
mkdir -p $path_to_conda_pack
tar -xzf python3.11.tar.gz -C $path_to_conda_pack
mkdir -p models/python_3_11/1/
cp ../../python_models/python_version/config.pbtxt ./models/python_3_11
(cd models/python_3_11 && \
sed -i "s/^name:.*/name: \"python_3_11\"/" 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_11/1/
cp python_backend/builddir/triton_python_backend_stub ./models/python_3_11
# copy the stub out to /opt/tritonserver/backends/python/3-11
mkdir -p /opt/tritonserver/backends/python/3-11
cp python_backend/builddir/triton_python_backend_stub /opt/tritonserver/backends/python/3-11/triton_python_backend_stub
conda deactivate

# copy the stub out to /opt/tritonserver/backends/python/3-10
mkdir -p /opt/tritonserver/backends/python/3-10
cp /opt/tritonserver/backends/python/triton_python_backend_stub /opt/tritonserver/backends/python/3-10/triton_python_backend_stub

rm -rf ./miniconda

run_server
if [ "$SERVER_PID" == "0" ]; then
echo -e "\n***\n*** Failed to start $SERVER\n***"
cat $SERVER_LOG
exit 1
fi

kill $SERVER_PID
wait $SERVER_PID

set +e
for EXPECTED_VERSION_STRING in "$PY38_VERSION_STRING" "$PY39_VERSION_STRING" "$PY311_VERSION_STRING"; do
grep "$EXPECTED_VERSION_STRING" $SERVER_LOG
if [ $? -ne 0 ]; then
cat $SERVER_LOG
echo -e "\n***\n*** $EXPECTED_VERSION_STRING was not found in Triton logs. \n***"
RET=1
fi
done

# Test default (non set) locale in python stub processes
# NOTE: In certain pybind versions, the locale settings may not be propagated from parent to
# stub processes correctly. See https://github.com/triton-inference-server/python_backend/pull/260.
Expand Down
Loading