From b10e2a3faa93232109df76520060ba15a99e0fb5 Mon Sep 17 00:00:00 2001 From: Jacky <18255193+kthui@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:48:49 -0800 Subject: [PATCH] test: Fix L0_backend_python for Ubuntu 24.04 base (#7789) --- qa/L0_backend_python/bls/test.sh | 2 +- qa/L0_backend_python/common.sh | 2 +- qa/L0_backend_python/decoupled/test.sh | 2 +- qa/L0_backend_python/env/test.sh | 59 ++++++++++--------- qa/L0_backend_python/io/test.sh | 2 +- .../setup_python_enviroment.sh | 33 +++++++++-- qa/L0_backend_python/test.sh | 6 +- 7 files changed, 65 insertions(+), 41 deletions(-) diff --git a/qa/L0_backend_python/bls/test.sh b/qa/L0_backend_python/bls/test.sh index 46d1f40818..fd7f9c65c8 100755 --- a/qa/L0_backend_python/bls/test.sh +++ b/qa/L0_backend_python/bls/test.sh @@ -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/ diff --git a/qa/L0_backend_python/common.sh b/qa/L0_backend_python/common.sh index 1d0e5094fe..1c3935a4e2 100755 --- a/qa/L0_backend_python/common.sh +++ b/qa/L0_backend_python/common.sh @@ -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 diff --git a/qa/L0_backend_python/decoupled/test.sh b/qa/L0_backend_python/decoupled/test.sh index 86455ff897..0b9f6f1ce0 100755 --- a/qa/L0_backend_python/decoupled/test.sh +++ b/qa/L0_backend_python/decoupled/test.sh @@ -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 diff --git a/qa/L0_backend_python/env/test.sh b/qa/L0_backend_python/env/test.sh index ff9e368e75..11a51378fb 100755 --- a/qa/L0_backend_python/env/test.sh +++ b/qa/L0_backend_python/env/test.sh @@ -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 @@ -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 @@ -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" @@ -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 @@ -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 @@ -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 @@ -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 "*" @@ -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 diff --git a/qa/L0_backend_python/io/test.sh b/qa/L0_backend_python/io/test.sh index e58cd3584f..2d9b48a750 100755 --- a/qa/L0_backend_python/io/test.sh +++ b/qa/L0_backend_python/io/test.sh @@ -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" diff --git a/qa/L0_backend_python/setup_python_enviroment.sh b/qa/L0_backend_python/setup_python_enviroment.sh index a2171e02da..c84c7f5ec8 100755 --- a/qa/L0_backend_python/setup_python_enviroment.sh +++ b/qa/L0_backend_python/setup_python_enviroment.sh @@ -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 @@ -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="" @@ -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" @@ -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" @@ -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 diff --git a/qa/L0_backend_python/test.sh b/qa/L0_backend_python/test.sh index f0ad3f49e1..42988e4d52 100755 --- a/qa/L0_backend_python/test.sh +++ b/qa/L0_backend_python/test.sh @@ -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 @@ -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 @@ -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