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: Fix L0_backend_python for Ubuntu 24.04 base #7789

Merged
merged 10 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion qa/L0_backend_python/bls/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ rm -fr *.log ./models *.txt *.xml
# FIXME: [DLIS-5970] Until Windows supports GPU tensors, only test CPU
if [[ ${TEST_WINDOWS} == 0 ]]; then
pip3 uninstall -y torch
pip3 install torch==1.13.0+cu117 -f https://download.pytorch.org/whl/torch_stable.html
pip3 install torch==2.3.1+cu118 -f https://download.pytorch.org/whl/torch_stable.html

mkdir -p models/bls/1/
cp ../../python_models/bls/model.py models/bls/1/
Expand Down
2 changes: 1 addition & 1 deletion qa/L0_backend_python/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ get_shm_pages() {

install_conda() {
rm -rf ./miniconda
file_name="Miniconda3-py310_23.11.0-2-Linux-x86_64.sh"
file_name="Miniconda3-py312_24.9.2-0-Linux-x86_64.sh"
wget https://repo.anaconda.com/miniconda/$file_name

# install miniconda in silent mode
Expand Down
2 changes: 1 addition & 1 deletion qa/L0_backend_python/decoupled/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pip3 uninstall -y torch
if [[ ${TEST_WINDOWS} == 1 ]]; then
pip3 install torch==1.13.0 -f https://download.pytorch.org/whl/torch_stable.html
else
pip3 install torch==1.13.0+cu117 -f https://download.pytorch.org/whl/torch_stable.html
pip3 install torch==2.3.1+cu118 -f https://download.pytorch.org/whl/torch_stable.html
fi

RET=0
Expand Down
59 changes: 30 additions & 29 deletions qa/L0_backend_python/env/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ 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
conda install -c conda-forge libstdcxx-ng=14 -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
Expand All @@ -71,7 +71,7 @@ path_to_conda_pack="$PWD/python-3-7-1"
create_conda_env_with_specified_path "3.7" $path_to_conda_pack
conda install numpy=1.20.3 -y
conda install tensorflow=2.1.0 -y
conda install -c conda-forge libstdcxx-ng=12 -y
conda install -c conda-forge libstdcxx-ng=14 -y

PY37_1_VERSION_STRING="Python version is 3.7, NumPy version is 1.20.3, and Tensorflow version is 2.1.0"
create_python_backend_stub
Expand All @@ -90,7 +90,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 -c conda-forge libstdcxx-ng=14 -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 @@ -110,22 +110,23 @@ 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
# 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"
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 && \
# always use the default Python version shipped in the container. For Ubuntu
# 24.04 it is Python 3.12, for Ubuntu 22.04 is Python 3.10 and for Ubuntu 20.04
# is 3.8.
path_to_conda_pack='$$TRITON_MODEL_DIRECTORY/python_3_12_environment.tar.gz'
create_conda_env "3.12" "python-3-12"
conda install -c conda-forge libstdcxx-ng=14 -y
conda install numpy=1.26.4 -y
conda install tensorflow=2.16.2 -y
PY312_VERSION_STRING="Python version is 3.12, NumPy version is 1.26.4, and Tensorflow version is 2.16.2"
conda pack -o python3.12.tar.gz
mkdir -p models/python_3_12/1/
cp ../../python_models/python_version/config.pbtxt ./models/python_3_12
cp python3.12.tar.gz models/python_3_12/python_3_12_environment.tar.gz
(cd models/python_3_12 && \
sed -i "s/^name:.*/name: \"python_3_12\"/" 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/
cp ../../python_models/python_version/model.py ./models/python_3_12/1/
conda deactivate
rm -rf ./miniconda

Expand All @@ -140,7 +141,7 @@ kill $SERVER_PID
wait $SERVER_PID

set +e
for EXPECTED_VERSION_STRING in "$PY36_VERSION_STRING" "$PY37_VERSION_STRING" "$PY37_1_VERSION_STRING" "$PY310_VERSION_STRING"; do
for EXPECTED_VERSION_STRING in "$PY36_VERSION_STRING" "$PY37_VERSION_STRING" "$PY37_1_VERSION_STRING" "$PY312_VERSION_STRING"; do
grep "$EXPECTED_VERSION_STRING" $SERVER_LOG
if [ $? -ne 0 ]; then
cat $SERVER_LOG
Expand Down Expand Up @@ -198,21 +199,21 @@ if [ "$SERVER_PID" == "0" ]; then
fi

# The environment should be extracted
curl -v -X POST localhost:8000/v2/repository/models/python_3_10/load
touch -m models/python_3_10/1/model.py
curl -v -X POST localhost:8000/v2/repository/models/python_3_12/load
touch -m models/python_3_12/1/model.py
# The environment should not be re-extracted
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
curl -v -X POST localhost:8000/v2/repository/models/python_3_12/load
touch -m models/python_3_12/python_3_12_environment.tar.gz
# The environment should be re-extracted
curl -v -X POST localhost:8000/v2/repository/models/python_3_10/load
curl -v -X POST localhost:8000/v2/repository/models/python_3_12/load

kill $SERVER_PID
wait $SERVER_PID

set +e

PY310_ENV_EXTRACTION="Extracting Python execution env"
if [ `grep -c "${PY310_ENV_EXTRACTION}" ${SERVER_LOG}` != "2" ]; then
PY312_ENV_EXTRACTION="Extracting Python execution env"
if [ `grep -c "${PY312_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 @@ -275,8 +276,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_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
sed -i "s/\$\$TRITON_MODEL_DIRECTORY\/python_3_12_environment/s3:\/\/triton-bucket-${CI_JOB_ID}\/python_3_12_environment/" models/python_3_12/config.pbtxt
mv models/python_3_12/python_3_12_environment.tar.gz models

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

Expand All @@ -295,7 +296,7 @@ kill $SERVER_PID
wait $SERVER_PID

set +e
for EXPECTED_VERSION_STRING in "$PY36_VERSION_STRING" "$PY310_VERSION_STRING"; do
for EXPECTED_VERSION_STRING in "$PY36_VERSION_STRING" "$PY312_VERSION_STRING"; do
grep "$EXPECTED_VERSION_STRING" $SERVER_LOG
if [ $? -ne 0 ]; then
cat $SERVER_LOG
Expand Down
2 changes: 1 addition & 1 deletion qa/L0_backend_python/io/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RET=0
rm -fr *.log ./models

pip3 uninstall -y torch
pip3 install torch==1.13.0+cu117 -f https://download.pytorch.org/whl/torch_stable.html
pip3 install torch==2.3.1+cu118 -f https://download.pytorch.org/whl/torch_stable.html

# IOTest.test_ensemble_io
TRIALS="default decoupled"
Expand Down
33 changes: 28 additions & 5 deletions qa/L0_backend_python/setup_python_enviroment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
RET=0
set -e
if [ ${PYTHON_ENV_VERSION} = "10" ]; then
if [ ${PYTHON_ENV_VERSION} = "12" ]; then
echo No need to set up anything for default python3.${PYTHON_ENV_VERSION}
exit $RET
fi
Expand All @@ -39,7 +39,7 @@ BASE_SERVER_ARGS="--model-repository=${MODELDIR}/models --log-verbose=1 --disabl
PYTHON_BACKEND_BRANCH=$PYTHON_BACKEND_REPO_TAG
SERVER_ARGS=$BASE_SERVER_ARGS
SERVER_LOG="./inference_server.log"
export PYTHON_ENV_VERSION=${PYTHON_ENV_VERSION:="10"}
export PYTHON_ENV_VERSION=${PYTHON_ENV_VERSION:="12"}
RET=0
EXPECTED_VERSION_STRINGS=""

Expand All @@ -55,7 +55,7 @@ conda update -n base -c defaults conda -y
# been setup correctly.
if [ ${PYTHON_ENV_VERSION} = "8" ]; then
create_conda_env "3.8" "python-3-8"
conda install -c conda-forge libstdcxx-ng=12 -y
conda install -c conda-forge libstdcxx-ng=14 -y
conda install numpy=1.23.4 -y
conda install tensorflow=2.10.0 -y
EXPECTED_VERSION_STRING="Python version is 3.8, NumPy version is 1.23.4, and Tensorflow version is 2.10.0"
Expand All @@ -78,7 +78,7 @@ fi
# been setup correctly.
if [ ${PYTHON_ENV_VERSION} = "9" ]; then
create_conda_env "3.9" "python-3-9"
conda install -c conda-forge libstdcxx-ng=12 -y
conda install -c conda-forge libstdcxx-ng=14 -y
conda install numpy=1.23.4 -y
conda install tensorflow=2.10.0 -y
EXPECTED_VERSION_STRING="Python version is 3.9, NumPy version is 1.23.4, and Tensorflow version is 2.10.0"
Expand All @@ -96,13 +96,36 @@ if [ ${PYTHON_ENV_VERSION} = "9" ]; then
cp python_backend/builddir/triton_python_backend_stub ./models/python_3_9
fi

# Create a model with python 3.10 version
# Successful execution of the Python model indicates that the environment has
# been setup correctly.
if [ ${PYTHON_ENV_VERSION} = "10" ]; then
create_conda_env "3.10" "python-3-10"
conda install -c conda-forge libstdcxx-ng=14 -y
conda install tensorflow=2.10.0 -y
conda install numpy=1.23.4 -y
EXPECTED_VERSION_STRING="Python version is 3.10, NumPy version is 1.23.4, and Tensorflow version is 2.10.0"
create_python_backend_stub
conda-pack -o python3.10.tar.gz
path_to_conda_pack="$PWD/python-3-10"
mkdir -p $path_to_conda_pack
tar -xzf python3.10.tar.gz -C $path_to_conda_pack
mkdir -p models/python_3_10/1/
cp ../python_models/python_version/config.pbtxt ./models/python_3_10
(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_10/1/
cp python_backend/builddir/triton_python_backend_stub ./models/python_3_10
fi

# Create a model with python 3.11 version
# Successful execution of the Python model indicates that the environment has
# been setup correctly.
if [ ${PYTHON_ENV_VERSION} = "11" ]; then
create_conda_env "3.11" "python-3-11"
conda install tensorflow=2.12.0 -y
conda install -c conda-forge libstdcxx-ng=12 -y
conda install -c conda-forge libstdcxx-ng=14 -y
conda install numpy=1.23.5 -y
EXPECTED_VERSION_STRING="Python version is 3.11, NumPy version is 1.23.5, and Tensorflow version is 2.12.0"
create_python_backend_stub
Expand Down
6 changes: 3 additions & 3 deletions qa/L0_backend_python/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ rm -fr *.log ./models

python3 --version | grep "3.12" > /dev/null
if [ $? -ne 0 ]; then
echo -e "Expecting Python default version to be: Python 3.10 but actual version is $(python3 --version)"
echo -e "Expecting Python default version to be: Python 3.12 but actual version is $(python3 --version)"
exit 1
fi

Expand Down Expand Up @@ -169,7 +169,7 @@ cp ../python_models/dlpack_identity/config.pbtxt ./models/dlpack_identity


if [ "$TEST_JETSON" == "0" ] && [[ ${TEST_WINDOWS} == 0 ]]; then
pip3 install torch==1.13.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
pip3 install torch==2.3.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
else
# GPU tensor tests are disabled on jetson
pip3 install torch==1.13.0 -f https://download.pytorch.org/whl/torch_stable.html
Expand Down Expand Up @@ -444,7 +444,7 @@ if [ "$TEST_JETSON" == "0" ]; then
done

# [DLIS-5969]: Incorporate env test for windows
if [[ ${PYTHON_ENV_VERSION} = "10" ]] && [[ ${TEST_WINDOWS} == 0 ]]; then
if [[ ${PYTHON_ENV_VERSION} = "12" ]] && [[ ${TEST_WINDOWS} == 0 ]]; then
# In 'env' test we use miniconda for dependency management. No need to run
# the test in a virtual environment.
set +e
Expand Down
Loading