From fb4da44d9132d5a966562a64857f08c427e7ec43 Mon Sep 17 00:00:00 2001 From: Francesco Petrini Date: Wed, 16 Oct 2024 16:50:36 -0700 Subject: [PATCH] build: RHEL SDK (#53) * RHEL SDK --- src/CMakeLists.txt | 56 ++++++++++++++++--- src/client_backend/CMakeLists.txt | 2 +- src/client_backend/openai/CMakeLists.txt | 2 +- src/client_backend/torchserve/CMakeLists.txt | 2 +- src/client_backend/triton/CMakeLists.txt | 6 +- .../triton_c_api/CMakeLists.txt | 4 +- src/data_loader.cc | 7 +++ 7 files changed, 63 insertions(+), 16 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 75a42597..2c2d5031 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,13 +37,9 @@ option(TRITON_ENABLE_PERF_ANALYZER_TS "Enable TorchServe support for Performance option(TRITON_ENABLE_PERF_ANALYZER_OPENAI "Enable OpenAI support for Performance Analyzer" OFF) # -# Client Options +# Feature Options # -option(TRITON_ENABLE_CC_HTTP "Build C++ HTTP client libraries" ON) -option(TRITON_ENABLE_CC_GRPC "Build C++ GRPC client libraries" ON) -option(TRITON_ENABLE_PYTHON_HTTP "Build Python HTTP client libraries" OFF) -option(TRITON_ENABLE_PYTHON_GRPC "Build Python GRPC client libraries" OFF) -option(TRITON_ENABLE_GPU "Enable GPU support in libraries" OFF) +option(TRITON_ENABLE_GPU "Enable GPU support in libraries" ON) option(TRITON_ENABLE_ZLIB "Include ZLIB library in build" ON) # @@ -59,6 +55,36 @@ set(TRITON_THIRD_PARTY_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/third-party-i # Add third party installation to the search path set(CMAKE_PREFIX_PATH ${TRITON_THIRD_PARTY_INSTALL_PREFIX} ${CMAKE_PREFIX_PATH}) +# Triton CC Client Libraries +find_library(TRITON_HTTP_STATIC_LIB + NAMES httpclient_static + PATHS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" + REQUIRED +) +find_library(TRITON_GRPC_STATIC_LIB + NAMES grpcclient_static + PATHS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" + REQUIRED +) +find_library(TRITON_JSON_STATIC_LIB + NAMES json_utils_static + PATHS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" + REQUIRED +) +find_library(TRITON_SHM_STATIC_LIB + NAMES shm_utils_static + PATHS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" + REQUIRED +) + +set(TRITON_RHEL_BUILD OFF) +if(LINUX) + file(STRINGS "/etc/os-release" DISTRO_ID_LIKE REGEX "ID_LIKE") + if(${DISTRO_ID_LIKE} MATCHES "rhel|centos") + set (TRITON_RHEL_BUILD ON) + endif(${DISTRO_ID_LIKE} MATCHES "rhel|centos") +endif(LINUX) + # # Dependencies # @@ -176,8 +202,8 @@ add_executable( target_link_libraries( perf_analyzer PRIVATE - httpclient_static - grpcclient_static + ${TRITON_HTTP_STATIC_LIB} + ${TRITON_GRPC_STATIC_LIB} client-backend-library -lb64 ${CMAKE_DL_LIBS} @@ -198,6 +224,13 @@ target_compile_definitions( GIT_SHA=${GIT_SHA} ) +if(TRITON_RHEL_BUILD) + target_compile_definitions( + perf_analyzer + PUBLIC TRITON_RHEL_BUILD=1 + ) +endif(TRITON_RHEL_BUILD) + # If gpu is enabled then compile with CUDA dependencies if(TRITON_ENABLE_GPU) target_compile_definitions( @@ -305,6 +338,13 @@ add_executable( set_target_properties(perf_analyzer_unit_tests PROPERTIES COMPILE_FLAGS "-Wno-write-strings") +if(TRITON_RHEL_BUILD) + target_compile_definitions( + perf_analyzer_unit_tests + PUBLIC TRITON_RHEL_BUILD=1 + ) +endif(TRITON_RHEL_BUILD) + target_include_directories( perf_analyzer_unit_tests PRIVATE diff --git a/src/client_backend/CMakeLists.txt b/src/client_backend/CMakeLists.txt index 61231a39..1017cd2e 100644 --- a/src/client_backend/CMakeLists.txt +++ b/src/client_backend/CMakeLists.txt @@ -116,7 +116,7 @@ target_link_libraries( PUBLIC triton-common-json # from repo-common triton-client-backend-library - json_utils_static + ${TRITON_JSON_STATIC_LIB} ${CAPI_TARGET_LINK_LIBRARY} ${TFS_TARGET_LINK_LIBRARY} ${TS_TARGET_LINK_LIBRARY} diff --git a/src/client_backend/openai/CMakeLists.txt b/src/client_backend/openai/CMakeLists.txt index a9da2919..34978290 100644 --- a/src/client_backend/openai/CMakeLists.txt +++ b/src/client_backend/openai/CMakeLists.txt @@ -58,7 +58,7 @@ target_include_directories( target_link_libraries( openai-client-backend-library PUBLIC CURL::libcurl - PUBLIC httpclient_static + PUBLIC ${TRITON_HTTP_STATIC_LIB} ) if(${TRITON_ENABLE_GPU}) diff --git a/src/client_backend/torchserve/CMakeLists.txt b/src/client_backend/torchserve/CMakeLists.txt index 3d383fdd..8a284819 100644 --- a/src/client_backend/torchserve/CMakeLists.txt +++ b/src/client_backend/torchserve/CMakeLists.txt @@ -56,7 +56,7 @@ target_include_directories( target_link_libraries( ts-client-backend-library PUBLIC CURL::libcurl - PUBLIC httpclient_static + PUBLIC ${TRITON_HTTP_STATIC_LIB} ) if(${TRITON_ENABLE_GPU}) diff --git a/src/client_backend/triton/CMakeLists.txt b/src/client_backend/triton/CMakeLists.txt index 4b2714e7..76ed37fd 100644 --- a/src/client_backend/triton/CMakeLists.txt +++ b/src/client_backend/triton/CMakeLists.txt @@ -64,15 +64,15 @@ target_link_directories( target_link_libraries( triton-client-backend-library - PUBLIC grpcclient_static + PUBLIC ${TRITON_GRPC_STATIC_LIB} PUBLIC gRPC::grpc++ PUBLIC gRPC::grpc ) target_link_libraries( triton-client-backend-library - PUBLIC shm_utils_static - PUBLIC httpclient_static + PUBLIC ${TRITON_SHM_STATIC_LIB} + PUBLIC ${TRITON_HTTP_STATIC_LIB} PRIVATE CURL::libcurl ) diff --git a/src/client_backend/triton_c_api/CMakeLists.txt b/src/client_backend/triton_c_api/CMakeLists.txt index 0b954b52..ce74a08d 100644 --- a/src/client_backend/triton_c_api/CMakeLists.txt +++ b/src/client_backend/triton_c_api/CMakeLists.txt @@ -71,14 +71,14 @@ target_include_directories( target_link_libraries( triton-c-api-backend-library - PUBLIC grpcclient_static + PUBLIC ${TRITON_GRPC_STATIC_LIB} PUBLIC gRPC::grpc++ PUBLIC gRPC::grpc ) target_link_libraries( triton-c-api-backend-library - PUBLIC httpclient_static + PUBLIC ${TRITON_HTTP_STATIC_LIB} PUBLIC triton-core-serverapi # from repo-core ) diff --git a/src/data_loader.cc b/src/data_loader.cc index 38bfe940..4daaf67b 100644 --- a/src/data_loader.cc +++ b/src/data_loader.cc @@ -26,7 +26,14 @@ #include "data_loader.h" +#ifdef TRITON_RHEL_BUILD +#define BUFFERSIZE BUFSIZ #include +#undef BUFFERSIZE +#else +#include +#endif + #include #include