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

build: RHEL 8 Compatibility #7519

Merged
merged 17 commits into from
Aug 16, 2024
Merged
Changes from 10 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
7 changes: 5 additions & 2 deletions CMakeLists.txt
mc-nv marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -125,13 +125,16 @@ FetchContent_Declare(

# Some libs are installed to ${TRITON_THIRD_PARTY_INSTALL_PREFIX}/{LIB}/lib64 instead
# of ${TRITON_THIRD_PARTY_INSTALL_PREFIX}/{LIB}/lib on Centos
set (LIB_DIR "lib")
set(LIB_DIR "lib")
# /etc/os-release does not exist on Windows
if(EXISTS "/etc/os-release")
file(STRINGS /etc/os-release DISTRO REGEX "^NAME=")
file(STRINGS /etc/os-release DISTRO_LIKE REGEX "^ID_LIKE=")
string(REGEX REPLACE "NAME=\"(.*)\"" "\\1" DISTRO "${DISTRO}")
string(REGEX REPLACE "ID_LIKE=\"(.*)\"" "\\1" DISTRO_LIKE "${DISTRO_LIKE}")
message(STATUS "Distro Name: ${DISTRO}")
if(DISTRO MATCHES "CentOS.*")
message(STATUS "Distro Like: ${DISTRO_LIKE}")
if(DISTRO_LIKE MATCHES ".*rhel.*" OR DISTRO_LIKE MATCHES ".*centos.*")
set (LIB_DIR "lib64")
nv-kmcgill53 marked this conversation as resolved.
Show resolved Hide resolved
endif()
endif()
222 changes: 202 additions & 20 deletions build.py
Original file line number Diff line number Diff line change
@@ -117,7 +117,17 @@ def fail_if(p, msg):
def target_platform():
if FLAGS.target_platform is not None:
return FLAGS.target_platform
return platform.system().lower()
platform_string = platform.system().lower()
if platform_string == "linux":
# Need to inspect the /etc/os-release file to get
# the distribution of linux
id_like_list = platform.freedesktop_os_release()["ID_LIKE"].split()
if "debian" in id_like_list:
return "linux"
else:
return "rhel"
else:
return platform_string


def target_machine():
@@ -649,7 +659,8 @@ def onnxruntime_cmake_args(images, library_paths):
]

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

if (target_machine() != "aarch64") and (
TRITON_VERSION_MAP[FLAGS.version][3] is not None
# TODO: TPRD-333 OpenVino extension is not currently supported by our manylinux build
if (
(target_machine() != "aarch64")
and (target_platform() != "rhel")
and (TRITON_VERSION_MAP[FLAGS.version][3] is not None)
):
cargs.append(
cmake_backend_enable(
@@ -697,7 +711,7 @@ def onnxruntime_cmake_args(images, library_paths):
)
)

if target_platform() == "igpu":
if (target_platform() == "igpu") or (target_platform() == "rhel"):
cargs.append(
cmake_backend_arg(
"onnxruntime",
@@ -833,8 +847,31 @@ def install_dcgm_libraries(dcgm_version, target_machine):
)
return ""
else:
if target_machine == "aarch64":
return """
# RHEL has the same install instructions for both aarch64 and x86
if target_platform() == "rhel":
if target_machine == "aarch64":
return """
ENV DCGM_VERSION {}
# Install DCGM. Steps from https://developer.nvidia.com/dcgm#Downloads
RUN dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/sbsa/cuda-rhel8.repo \\
&& dnf clean expire-cache \\
&& dnf install -y datacenter-gpu-manager-{}
""".format(
dcgm_version, dcgm_version
)
else:
return """
ENV DCGM_VERSION {}
# Install DCGM. Steps from https://developer.nvidia.com/dcgm#Downloads
RUN dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo \\
&& dnf clean expire-cache \\
&& dnf install -y datacenter-gpu-manager-{}
""".format(
dcgm_version, dcgm_version
)
else:
if target_machine == "aarch64":
return """
ENV DCGM_VERSION {}
# Install DCGM. Steps from https://developer.nvidia.com/dcgm#Downloads
RUN curl -o /tmp/cuda-keyring.deb \\
@@ -844,10 +881,10 @@ def install_dcgm_libraries(dcgm_version, target_machine):
&& apt-get update \\
&& apt-get install -y datacenter-gpu-manager=1:{}
""".format(
dcgm_version, dcgm_version
)
else:
return """
dcgm_version, dcgm_version
)
else:
return """
ENV DCGM_VERSION {}
# Install DCGM. Steps from https://developer.nvidia.com/dcgm#Downloads
RUN curl -o /tmp/cuda-keyring.deb \\
@@ -857,8 +894,106 @@ def install_dcgm_libraries(dcgm_version, target_machine):
&& apt-get update \\
&& apt-get install -y datacenter-gpu-manager=1:{}
""".format(
dcgm_version, dcgm_version
)
dcgm_version, dcgm_version
)


def create_dockerfile_buildbase_rhel(ddir, dockerfile_name, argmap):
df = """
ARG TRITON_VERSION={}
ARG TRITON_CONTAINER_VERSION={}
ARG BASE_IMAGE={}
""".format(
argmap["TRITON_VERSION"],
argmap["TRITON_CONTAINER_VERSION"],
argmap["BASE_IMAGE"],
)

df += """
FROM ${BASE_IMAGE}

ARG TRITON_VERSION
ARG TRITON_CONTAINER_VERSION
"""
df += """
# Install docker docker buildx
RUN yum install -y ca-certificates curl gnupg yum-utils \\
&& yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo \\
&& yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# && yum install -y docker.io docker-buildx-plugin

# libcurl4-openSSL-dev is needed for GCS
# python3-dev is needed by Torchvision
# python3-pip and libarchive-dev is needed by python backend
# libxml2-dev is needed for Azure Storage
# scons is needed for armnn_tflite backend build dep
RUN yum install -y \\
ca-certificates \\
autoconf \\
automake \\
git \\
gperf \\
re2-devel \\
openssl-devel \\
libtool \\
libcurl-devel \\
libb64-devel \\
gperftools-devel \\
patchelf \\
python3.11-devel \\
python3-pip \\
python3-setuptools \\
rapidjson-devel \\
python3-scons \\
pkg-config \\
unzip \\
wget \\
zlib-devel \\
libarchive-devel \\
libxml2-devel \\
numactl-devel \\
wget

RUN pip3 install --upgrade pip \\
&& pip3 install --upgrade \\
wheel \\
setuptools \\
docker \\
virtualenv

# Install boost version >= 1.78 for boost::span
# Current libboost-dev apt packages are < 1.78, so install from tar.gz
RUN wget -O /tmp/boost.tar.gz \\
https://archives.boost.io/release/1.80.0/source/boost_1_80_0.tar.gz \\
&& (cd /tmp && tar xzf boost.tar.gz) \\
&& mv /tmp/boost_1_80_0/boost /usr/include/boost

# Server build requires recent version of CMake (FetchContent required)
# Might not need this if the installed version of cmake is high enough for our build.
# RUN apt update -q=2 \\
# && apt install -y gpg wget \\
# && 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 \\
# && . /etc/os-release \\
# && 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 \\
# && apt-get update -q=2 \\
# && apt-get install -y --no-install-recommends cmake=3.27.7* cmake-data=3.27.7*
"""
if FLAGS.enable_gpu:
df += install_dcgm_libraries(argmap["DCGM_VERSION"], target_machine())
df += """
ENV TRITON_SERVER_VERSION ${TRITON_VERSION}
ENV NVIDIA_TRITON_SERVER_VERSION ${TRITON_CONTAINER_VERSION}
"""

df += """
WORKDIR /workspace
RUN rm -fr *
COPY . .
ENTRYPOINT []
"""

with open(os.path.join(ddir, dockerfile_name), "w") as dfile:
dfile.write(df)


def create_dockerfile_buildbase(ddir, dockerfile_name, argmap):
@@ -1018,6 +1153,12 @@ def create_dockerfile_cibase(ddir, dockerfile_name, argmap):
dfile.write(df)


def create_dockerfile_rhel(
nv-kmcgill53 marked this conversation as resolved.
Show resolved Hide resolved
ddir, dockerfile_name, argmap, backends, repoagents, caches, endpoints
):
pass


def create_dockerfile_linux(
ddir, dockerfile_name, argmap, backends, repoagents, caches, endpoints
):
@@ -1161,7 +1302,30 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach
fi \\
&& [ `id -u $TRITON_SERVER_USER` -eq 1000 ] \\
&& [ `id -g $TRITON_SERVER_USER` -eq 1000 ]
""".format(
gpu_enabled=gpu_enabled
)

# This
if target_platform() == "rhel":
df += """
# Common dpeendencies.
RUN yum install -y \\
git \\
gperf \\
re2-devel \\
openssl-devel \\
libtool \\
libcurl-devel \\
libb64-devel \\
gperftools-devel \\
patchelf \\
wget \\
numactl-devel \\
wget
nv-kmcgill53 marked this conversation as resolved.
Show resolved Hide resolved
"""
else:
df += """
# Ensure apt-get won't prompt for selecting options
ENV DEBIAN_FRONTEND=noninteractive

@@ -1184,12 +1348,14 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach
wget \\
{backend_dependencies} \\
&& rm -rf /var/lib/apt/lists/*
""".format(
backend_dependencies=backend_dependencies
)

df += """
# Set TCMALLOC_RELEASE_RATE for users setting LD_PRELOAD with tcmalloc
ENV TCMALLOC_RELEASE_RATE 200
""".format(
gpu_enabled=gpu_enabled, backend_dependencies=backend_dependencies
)
"""

if "fastertransformer" in backends:
be = "fastertransformer"
@@ -1433,9 +1599,14 @@ def create_build_dockerfiles(
)
dockerfileargmap["GPU_BASE_IMAGE"] = gpu_base_image

create_dockerfile_buildbase(
FLAGS.build_dir, "Dockerfile.buildbase", dockerfileargmap
)
if target_platform() == "rhel":
create_dockerfile_buildbase_rhel(
FLAGS.build_dir, "Dockerfile.buildbase", dockerfileargmap
)
else:
create_dockerfile_buildbase(
FLAGS.build_dir, "Dockerfile.buildbase", dockerfileargmap
)

if target_platform() == "windows":
create_dockerfile_windows(
@@ -1651,6 +1822,17 @@ def core_build(
os.path.join(repo_install_dir, "lib", "tritonserver.lib"),
os.path.join(install_dir, "bin"),
)
elif target_platform() == "rhel":
cmake_script.mkdir(os.path.join(install_dir, "bin"))
cmake_script.cp(
os.path.join(repo_install_dir, "bin", "tritonserver"),
os.path.join(install_dir, "bin"),
)
cmake_script.mkdir(os.path.join(install_dir, "lib64"))
cmake_script.cp(
os.path.join(repo_install_dir, "lib64", "libtritonserver.so"),
os.path.join(install_dir, "lib64"),
)
else:
cmake_script.mkdir(os.path.join(install_dir, "bin"))
cmake_script.cp(
@@ -2124,7 +2306,7 @@ def enable_all():
"--target-platform",
required=False,
default=None,
help='Target platform for build, can be "linux", "windows" or "igpu". If not specified, build targets the current platform.',
help='Target platform for build, can be "linux", "rhel", "windows" or "igpu". If not specified, build targets the current platform.',
)
parser.add_argument(
"--target-machine",
22 changes: 16 additions & 6 deletions qa/L0_infer/install_and_test.sh
Original file line number Diff line number Diff line change
@@ -25,14 +25,24 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Determine the operating system to call the correct package manager.
ID_LIKE=$(grep -Po '(?<=ID_LIKE=).*' /etc/os-release | awk -F= '{print $1}' | tr -d '"' | awk '{print $1}')

# Note: This script is to be used with customized triton containers that need
# dependencies to run L0_infer tests
apt-get update && \
apt-get install -y --no-install-recommends \
curl \
jq \
python3 \
python3-pip
if [[ "$ID_LIKE" =~ "debian" ]]; then
apt-get update && \
apt-get install -y --no-install-recommends \
curl \
jq \
python3 \
python3-pip
else
yum install -y \
jq \
curl
fi

pip3 install --upgrade pip
# install client libraries
pip3 install tritonclient[all]
16 changes: 15 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -138,14 +138,28 @@ else()
)
endif()

set(LIB_DIR "lib")
# /etc/os-release does not exist on Windows
if(EXISTS "/etc/os-release")
file(STRINGS /etc/os-release DISTRO REGEX "^NAME=")
file(STRINGS /etc/os-release DISTRO_LIKE REGEX "^ID_LIKE=")
string(REGEX REPLACE "NAME=\"(.*)\"" "\\1" DISTRO "${DISTRO}")
string(REGEX REPLACE "ID_LIKE=\"(.*)\"" "\\1" DISTRO_LIKE "${DISTRO_LIKE}")
message(STATUS "Distro Name: ${DISTRO}")
message(STATUS "Distro Like: ${DISTRO_LIKE}")
if(DISTRO_LIKE MATCHES ".*rhel.*" OR DISTRO_LIKE MATCHES ".*centos.*")
set (LIB_DIR "lib64")
endif()
endif()

set_target_properties(
main
PROPERTIES
POSITION_INDEPENDENT_CODE ON
SKIP_BUILD_RPATH TRUE
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH_USE_LINK_PATH FALSE
INSTALL_RPATH "$\{ORIGIN\}/../lib"
INSTALL_RPATH "$\{ORIGIN\}/../${LIB_DIR}"
)

target_link_libraries(