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

Fix L0_backend_python/env test #5799

Merged
merged 4 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions qa/L0_backend_python/common.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
# Copyright 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -31,7 +31,7 @@ get_shm_pages() {

install_conda() {
rm -rf ./miniconda
file_name="Miniconda3-py310_23.1.0-1-Linux-x86_64.sh"
file_name="Miniconda3-py310_23.3.1-0-Linux-x86_64.sh"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tabrizian does that value somehow interfere, do we need to change the build.py version as well?
https://github.com/triton-inference-server/server/blob/r23.05/build.py#L77

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't interfere. It is just a local installation of miniconda.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use a different version from build.py miniconda.

wget https://repo.anaconda.com/miniconda/$file_name

# install miniconda in silent mode
Expand Down Expand Up @@ -60,7 +60,7 @@ create_conda_env() {
env_name=$2
conda create -n $env_name python=$python_version -y
conda activate $env_name
conda install conda-pack -y
conda install -c conda-forge conda-pack -y
}

create_python_backend_stub() {
Expand Down
56 changes: 31 additions & 25 deletions qa/L0_backend_python/env/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2021-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -48,6 +48,8 @@ install_conda
create_conda_env "3.7" "python-3-7"
conda install numpy=1.20.1 -y
conda install tensorflow=2.1.0 -y
conda install -c conda-forge libstdcxx-ng=12 -y

PY37_VERSION_STRING="Python version is 3.7, NumPy version is 1.20.1, and Tensorflow version is 2.1.0"
create_python_backend_stub
conda-pack -o python3.7.tar.gz
Expand All @@ -65,6 +67,7 @@ conda deactivate
# Tensorflow 2.1.0 only works with Python 3.4 - 3.7. Successful execution of
# the Python model indicates that the environment has been setup correctly.
create_conda_env "3.6" "python-3-6"
conda install -c conda-forge libstdcxx-ng=12 -y
conda install numpy=1.18.1 -y
conda install tensorflow=2.1.0 -y
PY36_VERSION_STRING="Python version is 3.6, NumPy version is 1.18.1, and Tensorflow version is 2.1.0"
Expand All @@ -82,21 +85,23 @@ cp python3.6.tar.gz models/python_3_6/python_3_6_environment.tar.gz
cp ../../python_models/python_version/model.py ./models/python_3_6/1/
cp python_backend/builddir/triton_python_backend_stub ./models/python_3_6

# Test conda env without custom Python backend stub
# Tensorflow 2.3.0 only works with Python 3.5 - 3.8.
path_to_conda_pack='$$TRITON_MODEL_DIRECTORY/python_3_8_environment.tar.gz'
create_conda_env "3.8" "python-3-8"
conda install numpy=1.19.1 -y
conda install tensorflow=2.3.0 -y
PY38_VERSION_STRING="Python version is 3.8, NumPy version is 1.19.1, and Tensorflow version is 2.3.0"
conda-pack -o python3.8.tar.gz
mkdir -p models/python_3_8/1/
cp ../../python_models/python_version/config.pbtxt ./models/python_3_8
cp python3.8.tar.gz models/python_3_8/python_3_8_environment.tar.gz
(cd models/python_3_8 && \
sed -i "s/^name:.*/name: \"python_3_8\"/" config.pbtxt && \
# 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
# it is Python 3.10 and for Ubuntu 20.04 is 3.8
path_to_conda_pack='$$TRITON_MODEL_DIRECTORY/python_3_10_environment.tar.gz'
create_conda_env "3.10" "python-3-10"
tanmayv25 marked this conversation as resolved.
Show resolved Hide resolved
conda install -c conda-forge libstdcxx-ng=12 -y
conda install numpy=1.23.4 -y
conda install tensorflow=2.10.0 -y
PY310_VERSION_STRING="Python version is 3.10, NumPy version is 1.23.4, and Tensorflow version is 2.10.0"
conda pack -o python3.10.tar.gz
mkdir -p models/python_3_10/1/
cp ../../python_models/python_version/config.pbtxt ./models/python_3_10
cp python3.10.tar.gz models/python_3_10/python_3_10_environment.tar.gz
(cd models/python_3_10 && \
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_8/1/
cp ../../python_models/python_version/model.py ./models/python_3_10/1/
rm -rf ./miniconda

run_server
Expand All @@ -110,7 +115,7 @@ kill $SERVER_PID
wait $SERVER_PID

set +e
for EXPECTED_VERSION_STRING in "$PY36_VERSION_STRING" "$PY37_VERSION_STRING" "$PY38_VERSION_STRING"; do
for EXPECTED_VERSION_STRING in "$PY36_VERSION_STRING" "$PY37_VERSION_STRING" "$PY310_VERSION_STRING"; do
grep "$EXPECTED_VERSION_STRING" $SERVER_LOG
if [ $? -ne 0 ]; then
cat $SERVER_LOG
Expand All @@ -130,22 +135,23 @@ if [ "$SERVER_PID" == "0" ]; then
cat $SERVER_LOG
exit 1
fi

# The environment should be extracted
curl -v -X POST localhost:8000/v2/repository/models/python_3_8/load
touch -m models/python_3_8/1/model.py
curl -v -X POST localhost:8000/v2/repository/models/python_3_10/load
touch -m models/python_3_10/1/model.py
# The environment should not be re-extracted
curl -v -X POST localhost:8000/v2/repository/models/python_3_8/load
touch -m models/python_3_8/python_3_8_environment.tar.gz
curl -v -X POST localhost:8000/v2/repository/models/python_3_10/load
touch -m models/python_3_10/python_3_10_environment.tar.gz
# The environment should be re-extracted
curl -v -X POST localhost:8000/v2/repository/models/python_3_8/load
curl -v -X POST localhost:8000/v2/repository/models/python_3_10/load

kill $SERVER_PID
wait $SERVER_PID

set +e

PY38_ENV_EXTRACTION="Extracting Python execution env"
if [ `grep -c "${PY38_ENV_EXTRACTION}" ${SERVER_LOG}` != "2" ]; then
if [ `grep -c "${PY310_ENV_EXTRACTION}" ${SERVER_LOG}` != "2" ]; then
cat $SERVER_LOG
echo -e "\n***\n*** Python execution environment should be extracted exactly twice. \n***"
RET=1
Expand Down Expand Up @@ -207,8 +213,8 @@ aws s3 rm "${BUCKET_URL_SLASH}" --recursive --include "*"
# Test with EXECUTION_ENV_PATH outside the model directory
sed -i "s/TRITON_MODEL_DIRECTORY\/python_3_6_environment/TRITON_MODEL_DIRECTORY\/..\/python_3_6_environment/" models/python_3_6/config.pbtxt
mv models/python_3_6/python_3_6_environment.tar.gz models
sed -i "s/\$\$TRITON_MODEL_DIRECTORY\/python_3_8_environment/s3:\/\/triton-bucket-${CI_JOB_ID}\/python_3_8_environment/" models/python_3_8/config.pbtxt
mv models/python_3_8/python_3_8_environment.tar.gz models
sed -i "s/\$\$TRITON_MODEL_DIRECTORY\/python_3_10_environment/s3:\/\/triton-bucket-${CI_JOB_ID}\/python_3_10_environment/" models/python_3_10/config.pbtxt
mv models/python_3_10/python_3_10_environment.tar.gz models

aws s3 cp models/ "${BUCKET_URL_SLASH}" --recursive --include "*"

Expand All @@ -226,7 +232,7 @@ kill $SERVER_PID
wait $SERVER_PID

set +e
for EXPECTED_VERSION_STRING in "$PY36_VERSION_STRING" "$PY38_VERSION_STRING"; do
for EXPECTED_VERSION_STRING in "$PY36_VERSION_STRING" "$PY310_VERSION_STRING"; do
grep "$EXPECTED_VERSION_STRING" $SERVER_LOG
if [ $? -ne 0 ]; then
cat $SERVER_LOG
Expand Down