Skip to content

Commit 477c679

Browse files
ci: RHEL8 L0_backend_python Support (#7859)
Co-authored-by: Kyle McGill <[email protected]>
1 parent f5e4f69 commit 477c679

File tree

4 files changed

+63
-26
lines changed

4 files changed

+63
-26
lines changed

build.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ def backend_cmake_args(images, components, be, install_dir, library_paths):
565565
elif be == "tensorflow":
566566
args = tensorflow_cmake_args(images, library_paths)
567567
elif be == "python":
568-
args = []
568+
args = python_cmake_args()
569569
elif be == "dali":
570570
args = dali_cmake_args()
571571
elif be == "pytorch":
@@ -631,6 +631,18 @@ def backend_cmake_args(images, components, be, install_dir, library_paths):
631631
return cargs
632632

633633

634+
def python_cmake_args():
635+
cargs = []
636+
if target_platform() == "rhel":
637+
cargs.append(
638+
cmake_backend_arg(
639+
"python", "PYBIND11_PYTHON_VERSION", "STRING", FLAGS.rhel_py_version
640+
)
641+
)
642+
643+
return cargs
644+
645+
634646
def pytorch_cmake_args(images):
635647
if "pytorch" in images:
636648
image = images["pytorch"]
@@ -957,6 +969,10 @@ def create_dockerfile_buildbase_rhel(ddir, dockerfile_name, argmap):
957969
pkg-config \\
958970
unzip \\
959971
wget \\
972+
ncurses-devel \\
973+
readline-devel \\
974+
xz-devel \\
975+
bzip2-devel \\
960976
zlib-devel \\
961977
libarchive-devel \\
962978
libxml2-devel \\
@@ -1542,7 +1558,7 @@ def add_cpu_libs_to_linux_dockerfile(backends, target_machine):
15421558

15431559

15441560
def change_default_python_version_rhel(version):
1545-
df = """
1561+
df = f"""
15461562
# The python library version available for install via 'yum install python3.X-devel' does not
15471563
# match the version of python inside the RHEL base container. This means that python packages
15481564
# installed within the container will not be picked up by the python backend stub process pybind
@@ -1551,21 +1567,17 @@ def change_default_python_version_rhel(version):
15511567
RUN curl https://pyenv.run | bash
15521568
ENV PATH="${{PYENV_ROOT}}/bin:$PATH"
15531569
RUN eval "$(pyenv init -)"
1554-
RUN CONFIGURE_OPTS=\"--with-openssl=/usr/lib64\" && pyenv install {} \\
1555-
&& cp ${{PYENV_ROOT}}/versions/{}/lib/libpython3* /usr/lib64/""".format(
1556-
version, version
1557-
)
1558-
df += """
1570+
RUN CONFIGURE_OPTS=\"--with-openssl=/usr/lib64\" && pyenv install {version} \\
1571+
&& cp ${{PYENV_ROOT}}/versions/{version}/lib/libpython3* /usr/lib64/
1572+
15591573
# RHEL image has several python versions. It's important
15601574
# to set the correct version, otherwise, packages that are
15611575
# pip installed will not be found during testing.
1562-
ENV PYVER={} PYTHONPATH=/opt/python/v
1576+
ENV PYVER={version} PYTHONPATH=/opt/python/v
15631577
RUN ln -sf ${{PYENV_ROOT}}/versions/${{PYVER}}* ${{PYTHONPATH}}
15641578
ENV PYBIN=${{PYTHONPATH}}/bin
15651579
ENV PYTHON_BIN_PATH=${{PYBIN}}/python${{PYVER}} PATH=${{PYBIN}}:${{PATH}}
1566-
""".format(
1567-
version
1568-
)
1580+
"""
15691581
return df
15701582

15711583

qa/L0_backend_python/common.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ install_conda() {
4242
eval "$(./miniconda/bin/conda shell.bash hook)"
4343
}
4444

45-
install_build_deps() {
45+
install_build_deps_apt() {
4646
apt update && apt install software-properties-common rapidjson-dev -y
4747
# Using CMAKE installation instruction from:: https://apt.kitware.com/
4848
apt update -q=2 \
@@ -54,6 +54,18 @@ install_build_deps() {
5454
&& apt-get install -y --no-install-recommends cmake=3.28.3* cmake-data=3.28.3*
5555
}
5656

57+
install_build_deps_yum() {
58+
yum install rapidjson-devel -y
59+
}
60+
61+
install_build_deps() {
62+
if [[ ${TRITON_RHEL} -eq "1" ]]; then
63+
install_build_deps_yum
64+
else
65+
install_build_deps_apt
66+
fi
67+
}
68+
5769
create_conda_env() {
5870
local python_version=$1
5971
local env_name=$2
@@ -74,6 +86,6 @@ create_python_backend_stub() {
7486
rm -rf python_backend
7587
git clone ${TRITON_REPO_ORGANIZATION}/python_backend -b $PYTHON_BACKEND_REPO_TAG
7688
(cd python_backend/ && mkdir builddir && cd builddir && \
77-
cmake -DTRITON_ENABLE_GPU=ON -DTRITON_REPO_ORGANIZATION:STRING=${TRITON_REPO_ORGANIZATION} -DTRITON_BACKEND_REPO_TAG=$TRITON_BACKEND_REPO_TAG -DTRITON_COMMON_REPO_TAG=$TRITON_COMMON_REPO_TAG -DTRITON_CORE_REPO_TAG=$TRITON_CORE_REPO_TAG ../ && \
89+
cmake -DTRITON_ENABLE_GPU=ON -DTRITON_REPO_ORGANIZATION:STRING=${TRITON_REPO_ORGANIZATION} -DTRITON_BACKEND_REPO_TAG=$TRITON_BACKEND_REPO_TAG -DTRITON_COMMON_REPO_TAG=$TRITON_COMMON_REPO_TAG -DTRITON_CORE_REPO_TAG=$TRITON_CORE_REPO_TAG -DPYBIND11_PYTHON_VERSION=$PY_VERSION ../ && \
7890
make -j18 triton-python-backend-stub)
7991
}

qa/L0_backend_python/env/test.sh

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ install_conda
4444
# Tensorflow 2.1.0 only works with Python 3.4 - 3.7. Successful execution of
4545
# the Python model indicates that the environment has been setup correctly.
4646
# Create a model with python 3.7 version
47+
export PY_VERSION="3.7"
4748
create_conda_env "3.7" "python-3-7"
4849
conda install numpy=1.20.1 -y
4950
conda install tensorflow=2.1.0 -y
@@ -67,6 +68,7 @@ conda deactivate
6768
# previous test.
6869
# Tensorflow 2.1.0 only works with Python 3.4 - 3.7. Successful execution of
6970
# the Python model indicates that the environment has been setup correctly.
71+
export PY_VERSION="3.7.1"
7072
path_to_conda_pack="$PWD/python-3-7-1"
7173
create_conda_env_with_specified_path "3.7" $path_to_conda_pack
7274
conda install numpy=1.20.3 -y
@@ -89,6 +91,7 @@ conda deactivate
8991
# Create a model with python 3.6 version
9092
# Tensorflow 2.1.0 only works with Python 3.4 - 3.7. Successful execution of
9193
# the Python model indicates that the environment has been setup correctly.
94+
export PY_VERSION="3.6"
9295
create_conda_env "3.6" "python-3-6"
9396
conda install -c conda-forge libstdcxx-ng=14 -y
9497
conda install numpy=1.18.1 -y
@@ -116,9 +119,13 @@ conda deactivate
116119
path_to_conda_pack='$$TRITON_MODEL_DIRECTORY/python_3_12_environment.tar.gz'
117120
create_conda_env "3.12" "python-3-12"
118121
conda install -c conda-forge libstdcxx-ng=14 -y
122+
TF_VERSION="2.16.2"
119123
conda install numpy=1.26.4 -y
120-
conda install tensorflow=2.16.2 -y
121-
PY312_VERSION_STRING="Python version is 3.12, NumPy version is 1.26.4, and Tensorflow version is 2.16.2"
124+
if [ $TRITON_RHEL -eq 1 ]; then
125+
TF_VERSION="2.17.0"
126+
fi
127+
conda install tensorflow=${TF_VERSION} -y
128+
PY312_VERSION_STRING="Python version is 3.12, NumPy version is 1.26.4, and Tensorflow version is ${TF_VERSION}"
122129
conda pack -o python3.12.tar.gz
123130
mkdir -p models/python_3_12/1/
124131
cp ../../python_models/python_version/config.pbtxt ./models/python_3_12
@@ -137,8 +144,7 @@ if [ "$SERVER_PID" == "0" ]; then
137144
exit 1
138145
fi
139146

140-
kill $SERVER_PID
141-
wait $SERVER_PID
147+
kill_server
142148

143149
set +e
144150
for EXPECTED_VERSION_STRING in "$PY36_VERSION_STRING" "$PY37_VERSION_STRING" "$PY37_1_VERSION_STRING" "$PY312_VERSION_STRING"; do
@@ -154,6 +160,15 @@ done
154160
# NOTE: In certain pybind versions, the locale settings may not be propagated from parent to
155161
# stub processes correctly. See https://github.com/triton-inference-server/python_backend/pull/260.
156162
export LC_ALL=INVALID
163+
run_server
164+
if [ "$SERVER_PID" == "0" ]; then
165+
echo -e "\n***\n*** Failed to start $SERVER\n***"
166+
cat $SERVER_LOG
167+
exit 1
168+
fi
169+
170+
kill_server
171+
157172
grep "Locale is (None, None)" $SERVER_LOG
158173
if [ $? -ne 0 ]; then
159174
cat $SERVER_LOG
@@ -175,8 +190,7 @@ if [ "$SERVER_PID" == "0" ]; then
175190
exit 1
176191
fi
177192

178-
kill $SERVER_PID
179-
wait $SERVER_PID
193+
kill_server
180194

181195
set +e
182196
grep "Locale is ('en_US', 'UTF-8')" $SERVER_LOG
@@ -207,8 +221,7 @@ touch -m models/python_3_12/python_3_12_environment.tar.gz
207221
# The environment should be re-extracted
208222
curl -v -X POST localhost:8000/v2/repository/models/python_3_12/load
209223

210-
kill $SERVER_PID
211-
wait $SERVER_PID
224+
kill_server
212225

213226
set +e
214227

@@ -248,6 +261,8 @@ rm -rf models/python_3_7
248261
aws s3 cp models/ "${BUCKET_URL_SLASH}" --recursive --include "*"
249262

250263
rm $SERVER_LOG
264+
# Occasionally needs more time to load
265+
SERVER_TIMEOUT=420
251266

252267
SERVER_ARGS="--model-repository=$BUCKET_URL_SLASH --log-verbose=1"
253268
run_server
@@ -258,8 +273,7 @@ if [ "$SERVER_PID" == "0" ]; then
258273
exit 1
259274
fi
260275

261-
kill $SERVER_PID
262-
wait $SERVER_PID
276+
kill_server
263277

264278
set +e
265279
grep "$PY36_VERSION_STRING" $SERVER_LOG
@@ -292,8 +306,7 @@ if [ "$SERVER_PID" == "0" ]; then
292306
exit 1
293307
fi
294308

295-
kill $SERVER_PID
296-
wait $SERVER_PID
309+
kill_server
297310

298311
set +e
299312
for EXPECTED_VERSION_STRING in "$PY36_VERSION_STRING" "$PY312_VERSION_STRING"; do

qa/L0_trt_compat/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if [ -z "$REPO_VERSION" ]; then
3434
echo -e "\n***\n*** Test Failed\n***"
3535
exit 1
3636
fi
37-
if [ ! -z "$TEST_REPO_ARCH" ]; then
37+
if [ ! -z "$TEST_REPO_ARCH" ]; then
3838
REPO_VERSION=${REPO_VERSION}_${TEST_REPO_ARCH}
3939
fi
4040

0 commit comments

Comments
 (0)