Skip to content

Commit 7a158a4

Browse files
build: RHEL 8 Compatibility (#7519)
Co-authored-by: Francesco Petrini <[email protected]>
1 parent e7c8e7b commit 7a158a4

File tree

4 files changed

+228
-37
lines changed

4 files changed

+228
-37
lines changed

CMakeLists.txt

+6-10
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,13 @@ FetchContent_Declare(
125125

126126
# Some libs are installed to ${TRITON_THIRD_PARTY_INSTALL_PREFIX}/{LIB}/lib64 instead
127127
# of ${TRITON_THIRD_PARTY_INSTALL_PREFIX}/{LIB}/lib on Centos
128-
set (LIB_DIR "lib")
129-
# /etc/os-release does not exist on Windows
130-
if(EXISTS "/etc/os-release")
131-
file(STRINGS /etc/os-release DISTRO REGEX "^NAME=")
132-
string(REGEX REPLACE "NAME=\"(.*)\"" "\\1" DISTRO "${DISTRO}")
133-
message(STATUS "Distro Name: ${DISTRO}")
134-
if(DISTRO MATCHES "CentOS.*")
128+
set(LIB_DIR "lib")
129+
if(LINUX)
130+
file(STRINGS "/etc/os-release" DISTRO_ID_LIKE REGEX "ID_LIKE")
131+
if(${DISTRO_ID_LIKE} MATCHES "rhel|centos")
135132
set (LIB_DIR "lib64")
136-
endif()
137-
endif()
138-
133+
endif(${DISTRO_ID_LIKE} MATCHES "rhel|centos")
134+
endif(LINUX)
139135
set(TRITON_CORE_HEADERS_ONLY OFF)
140136

141137
FetchContent_MakeAvailable(repo-third-party repo-core)

build.py

+196-20
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import sys
3838
from inspect import getsourcefile
3939

40+
import distro
4041
import requests
4142

4243
#
@@ -117,7 +118,17 @@ def fail_if(p, msg):
117118
def target_platform():
118119
if FLAGS.target_platform is not None:
119120
return FLAGS.target_platform
120-
return platform.system().lower()
121+
platform_string = platform.system().lower()
122+
if platform_string == "linux":
123+
# Need to inspect the /etc/os-release file to get
124+
# the distribution of linux
125+
id_like_list = distro.like().split()
126+
if "debian" in id_like_list:
127+
return "linux"
128+
else:
129+
return "rhel"
130+
else:
131+
return platform_string
121132

122133

123134
def target_machine():
@@ -649,7 +660,8 @@ def onnxruntime_cmake_args(images, library_paths):
649660
]
650661

651662
# TRITON_ENABLE_GPU is already set for all backends in backend_cmake_args()
652-
if FLAGS.enable_gpu:
663+
# TODO: TPRD-334 TensorRT extension is not currently supported by our manylinux build
664+
if FLAGS.enable_gpu and target_platform() != "rhel":
653665
cargs.append(
654666
cmake_backend_enable(
655667
"onnxruntime", "TRITON_ENABLE_ONNXRUNTIME_TENSORRT", True
@@ -680,8 +692,11 @@ def onnxruntime_cmake_args(images, library_paths):
680692
)
681693
)
682694

683-
if (target_machine() != "aarch64") and (
684-
TRITON_VERSION_MAP[FLAGS.version][3] is not None
695+
# TODO: TPRD-333 OpenVino extension is not currently supported by our manylinux build
696+
if (
697+
(target_machine() != "aarch64")
698+
and (target_platform() != "rhel")
699+
and (TRITON_VERSION_MAP[FLAGS.version][3] is not None)
685700
):
686701
cargs.append(
687702
cmake_backend_enable(
@@ -697,7 +712,7 @@ def onnxruntime_cmake_args(images, library_paths):
697712
)
698713
)
699714

700-
if target_platform() == "igpu":
715+
if (target_platform() == "igpu") or (target_platform() == "rhel"):
701716
cargs.append(
702717
cmake_backend_arg(
703718
"onnxruntime",
@@ -833,8 +848,31 @@ def install_dcgm_libraries(dcgm_version, target_machine):
833848
)
834849
return ""
835850
else:
836-
if target_machine == "aarch64":
837-
return """
851+
# RHEL has the same install instructions for both aarch64 and x86
852+
if target_platform() == "rhel":
853+
if target_machine == "aarch64":
854+
return """
855+
ENV DCGM_VERSION {}
856+
# Install DCGM. Steps from https://developer.nvidia.com/dcgm#Downloads
857+
RUN dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/sbsa/cuda-rhel8.repo \\
858+
&& dnf clean expire-cache \\
859+
&& dnf install -y datacenter-gpu-manager-{}
860+
""".format(
861+
dcgm_version, dcgm_version
862+
)
863+
else:
864+
return """
865+
ENV DCGM_VERSION {}
866+
# Install DCGM. Steps from https://developer.nvidia.com/dcgm#Downloads
867+
RUN dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo \\
868+
&& dnf clean expire-cache \\
869+
&& dnf install -y datacenter-gpu-manager-{}
870+
""".format(
871+
dcgm_version, dcgm_version
872+
)
873+
else:
874+
if target_machine == "aarch64":
875+
return """
838876
ENV DCGM_VERSION {}
839877
# Install DCGM. Steps from https://developer.nvidia.com/dcgm#Downloads
840878
RUN curl -o /tmp/cuda-keyring.deb \\
@@ -844,10 +882,10 @@ def install_dcgm_libraries(dcgm_version, target_machine):
844882
&& apt-get update \\
845883
&& apt-get install -y datacenter-gpu-manager=1:{}
846884
""".format(
847-
dcgm_version, dcgm_version
848-
)
849-
else:
850-
return """
885+
dcgm_version, dcgm_version
886+
)
887+
else:
888+
return """
851889
ENV DCGM_VERSION {}
852890
# Install DCGM. Steps from https://developer.nvidia.com/dcgm#Downloads
853891
RUN curl -o /tmp/cuda-keyring.deb \\
@@ -857,8 +895,106 @@ def install_dcgm_libraries(dcgm_version, target_machine):
857895
&& apt-get update \\
858896
&& apt-get install -y datacenter-gpu-manager=1:{}
859897
""".format(
860-
dcgm_version, dcgm_version
861-
)
898+
dcgm_version, dcgm_version
899+
)
900+
901+
902+
def create_dockerfile_buildbase_rhel(ddir, dockerfile_name, argmap):
903+
df = """
904+
ARG TRITON_VERSION={}
905+
ARG TRITON_CONTAINER_VERSION={}
906+
ARG BASE_IMAGE={}
907+
""".format(
908+
argmap["TRITON_VERSION"],
909+
argmap["TRITON_CONTAINER_VERSION"],
910+
argmap["BASE_IMAGE"],
911+
)
912+
913+
df += """
914+
FROM ${BASE_IMAGE}
915+
916+
ARG TRITON_VERSION
917+
ARG TRITON_CONTAINER_VERSION
918+
"""
919+
df += """
920+
# Install docker docker buildx
921+
RUN yum install -y ca-certificates curl gnupg yum-utils \\
922+
&& yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo \\
923+
&& yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
924+
# && yum install -y docker.io docker-buildx-plugin
925+
926+
# libcurl4-openSSL-dev is needed for GCS
927+
# python3-dev is needed by Torchvision
928+
# python3-pip and libarchive-dev is needed by python backend
929+
# libxml2-dev is needed for Azure Storage
930+
# scons is needed for armnn_tflite backend build dep
931+
RUN yum install -y \\
932+
ca-certificates \\
933+
autoconf \\
934+
automake \\
935+
git \\
936+
gperf \\
937+
re2-devel \\
938+
openssl-devel \\
939+
libtool \\
940+
libcurl-devel \\
941+
libb64-devel \\
942+
gperftools-devel \\
943+
patchelf \\
944+
python3.11-devel \\
945+
python3-pip \\
946+
python3-setuptools \\
947+
rapidjson-devel \\
948+
python3-scons \\
949+
pkg-config \\
950+
unzip \\
951+
wget \\
952+
zlib-devel \\
953+
libarchive-devel \\
954+
libxml2-devel \\
955+
numactl-devel \\
956+
wget
957+
958+
RUN pip3 install --upgrade pip \\
959+
&& pip3 install --upgrade \\
960+
wheel \\
961+
setuptools \\
962+
docker \\
963+
virtualenv
964+
965+
# Install boost version >= 1.78 for boost::span
966+
# Current libboost-dev apt packages are < 1.78, so install from tar.gz
967+
RUN wget -O /tmp/boost.tar.gz \\
968+
https://archives.boost.io/release/1.80.0/source/boost_1_80_0.tar.gz \\
969+
&& (cd /tmp && tar xzf boost.tar.gz) \\
970+
&& mv /tmp/boost_1_80_0/boost /usr/include/boost
971+
972+
# Server build requires recent version of CMake (FetchContent required)
973+
# Might not need this if the installed version of cmake is high enough for our build.
974+
# RUN apt update -q=2 \\
975+
# && apt install -y gpg wget \\
976+
# && wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null \\
977+
# && . /etc/os-release \\
978+
# && echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $UBUNTU_CODENAME main" | tee /etc/apt/sources.list.d/kitware.list >/dev/null \\
979+
# && apt-get update -q=2 \\
980+
# && apt-get install -y --no-install-recommends cmake=3.27.7* cmake-data=3.27.7*
981+
"""
982+
if FLAGS.enable_gpu:
983+
df += install_dcgm_libraries(argmap["DCGM_VERSION"], target_machine())
984+
df += """
985+
ENV TRITON_SERVER_VERSION ${TRITON_VERSION}
986+
ENV NVIDIA_TRITON_SERVER_VERSION ${TRITON_CONTAINER_VERSION}
987+
"""
988+
989+
df += """
990+
WORKDIR /workspace
991+
RUN rm -fr *
992+
COPY . .
993+
ENTRYPOINT []
994+
"""
995+
996+
with open(os.path.join(ddir, dockerfile_name), "w") as dfile:
997+
dfile.write(df)
862998

863999

8641000
def create_dockerfile_buildbase(ddir, dockerfile_name, argmap):
@@ -1161,7 +1297,29 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach
11611297
fi \\
11621298
&& [ `id -u $TRITON_SERVER_USER` -eq 1000 ] \\
11631299
&& [ `id -g $TRITON_SERVER_USER` -eq 1000 ]
1300+
""".format(
1301+
gpu_enabled=gpu_enabled
1302+
)
11641303

1304+
# This
1305+
if target_platform() == "rhel":
1306+
df += """
1307+
# Common dpeendencies.
1308+
RUN yum install -y \\
1309+
git \\
1310+
gperf \\
1311+
re2-devel \\
1312+
openssl-devel \\
1313+
libtool \\
1314+
libcurl-devel \\
1315+
libb64-devel \\
1316+
gperftools-devel \\
1317+
patchelf \\
1318+
wget \\
1319+
numactl-devel
1320+
"""
1321+
else:
1322+
df += """
11651323
# Ensure apt-get won't prompt for selecting options
11661324
ENV DEBIAN_FRONTEND=noninteractive
11671325
@@ -1184,12 +1342,14 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach
11841342
wget \\
11851343
{backend_dependencies} \\
11861344
&& rm -rf /var/lib/apt/lists/*
1345+
""".format(
1346+
backend_dependencies=backend_dependencies
1347+
)
11871348

1349+
df += """
11881350
# Set TCMALLOC_RELEASE_RATE for users setting LD_PRELOAD with tcmalloc
11891351
ENV TCMALLOC_RELEASE_RATE 200
1190-
""".format(
1191-
gpu_enabled=gpu_enabled, backend_dependencies=backend_dependencies
1192-
)
1352+
"""
11931353

11941354
if "fastertransformer" in backends:
11951355
be = "fastertransformer"
@@ -1433,9 +1593,14 @@ def create_build_dockerfiles(
14331593
)
14341594
dockerfileargmap["GPU_BASE_IMAGE"] = gpu_base_image
14351595

1436-
create_dockerfile_buildbase(
1437-
FLAGS.build_dir, "Dockerfile.buildbase", dockerfileargmap
1438-
)
1596+
if target_platform() == "rhel":
1597+
create_dockerfile_buildbase_rhel(
1598+
FLAGS.build_dir, "Dockerfile.buildbase", dockerfileargmap
1599+
)
1600+
else:
1601+
create_dockerfile_buildbase(
1602+
FLAGS.build_dir, "Dockerfile.buildbase", dockerfileargmap
1603+
)
14391604

14401605
if target_platform() == "windows":
14411606
create_dockerfile_windows(
@@ -1651,6 +1816,17 @@ def core_build(
16511816
os.path.join(repo_install_dir, "lib", "tritonserver.lib"),
16521817
os.path.join(install_dir, "bin"),
16531818
)
1819+
elif target_platform() == "rhel":
1820+
cmake_script.mkdir(os.path.join(install_dir, "bin"))
1821+
cmake_script.cp(
1822+
os.path.join(repo_install_dir, "bin", "tritonserver"),
1823+
os.path.join(install_dir, "bin"),
1824+
)
1825+
cmake_script.mkdir(os.path.join(install_dir, "lib64"))
1826+
cmake_script.cp(
1827+
os.path.join(repo_install_dir, "lib64", "libtritonserver.so"),
1828+
os.path.join(install_dir, "lib64"),
1829+
)
16541830
else:
16551831
cmake_script.mkdir(os.path.join(install_dir, "bin"))
16561832
cmake_script.cp(
@@ -2128,7 +2304,7 @@ def enable_all():
21282304
"--target-platform",
21292305
required=False,
21302306
default=None,
2131-
help='Target platform for build, can be "linux", "windows" or "igpu". If not specified, build targets the current platform.',
2307+
help='Target platform for build, can be "linux", "rhel", "windows" or "igpu". If not specified, build targets the current platform.',
21322308
)
21332309
parser.add_argument(
21342310
"--target-machine",

qa/L0_infer/install_and_test.sh

+16-6
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,24 @@
2525
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2626
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727

28+
# Determine the operating system to call the correct package manager.
29+
ID_LIKE=$(grep -Po '(?<=ID_LIKE=).*' /etc/os-release | awk -F= '{print $1}' | tr -d '"' | awk '{print $1}')
30+
2831
# Note: This script is to be used with customized triton containers that need
2932
# dependencies to run L0_infer tests
30-
apt-get update && \
31-
apt-get install -y --no-install-recommends \
32-
curl \
33-
jq \
34-
python3 \
35-
python3-pip
33+
if [[ "$ID_LIKE" =~ "debian" ]]; then
34+
apt-get update && \
35+
apt-get install -y --no-install-recommends \
36+
curl \
37+
jq \
38+
python3 \
39+
python3-pip
40+
else
41+
yum install -y \
42+
jq \
43+
curl
44+
fi
45+
3646
pip3 install --upgrade pip
3747
# install client libraries
3848
pip3 install tritonclient[all]

src/CMakeLists.txt

+10-1
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,23 @@ else()
138138
)
139139
endif()
140140

141+
set(LIB_DIR "lib")
142+
if(LINUX)
143+
file(STRINGS "/etc/os-release" DISTRO_ID_LIKE REGEX "ID_LIKE")
144+
if(${DISTRO_ID_LIKE} MATCHES "rhel|centos")
145+
set (LIB_DIR "lib64")
146+
endif(${DISTRO_ID_LIKE} MATCHES "rhel|centos")
147+
endif(LINUX)
148+
set(TRITON_CORE_HEADERS_ONLY OFF)
149+
141150
set_target_properties(
142151
main
143152
PROPERTIES
144153
POSITION_INDEPENDENT_CODE ON
145154
SKIP_BUILD_RPATH TRUE
146155
BUILD_WITH_INSTALL_RPATH TRUE
147156
INSTALL_RPATH_USE_LINK_PATH FALSE
148-
INSTALL_RPATH "$\{ORIGIN\}/../lib"
157+
INSTALL_RPATH "$\{ORIGIN\}/../${LIB_DIR}"
149158
)
150159

151160
target_link_libraries(

0 commit comments

Comments
 (0)