2024-07-02 09:16:27 -06:00
|
|
|
cmake_minimum_required(VERSION 3.20)
|
2024-06-30 15:37:20 -06:00
|
|
|
|
|
|
|
project(tgi-trtllm-backend VERSION 1.0.0)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
|
|
|
|
include(FetchContent)
|
2024-07-02 09:16:27 -06:00
|
|
|
include(ExternalProject)
|
2024-06-30 15:37:20 -06:00
|
|
|
|
|
|
|
option(TGI_TRTLLM_BACKEND_BUILD_TESTS "Enable building the unittests suite" OFF)
|
2024-07-11 15:24:01 -06:00
|
|
|
option(TGI_TRTLLM_BACKEND_BUILD_EXAMPLES "Enable building the examples suite" OFF)
|
2024-07-03 15:12:24 -06:00
|
|
|
set(TGI_TRTLLM_BACKEND_TARGET_CUDA_ARCH_LIST "89-real" CACHE STRING "List of CUDA architectures to support")
|
2024-07-02 09:16:27 -06:00
|
|
|
set(TGI_TRTLLM_BACKEND_TRT_ROOT "/usr/local/tensorrt" CACHE PATH "Path where TensorRT libraries and headers are located")
|
|
|
|
set(TGI_TRTLLM_BACKEND_TRT_INCLUDE_DIR "${TGI_TRTLLM_BACKEND_TRT_ROOT}/include" CACHE PATH "Path where TensorRT headers are located")
|
|
|
|
set(TGI_TRTLLM_BACKEND_TRT_LIB_DIR "${TGI_TRTLLM_BACKEND_TRT_ROOT}/lib" CACHE PATH "Path where TensorRT libraries are located")
|
|
|
|
|
2024-07-03 15:12:24 -06:00
|
|
|
#### External dependencies ####
|
2024-07-12 13:24:32 -06:00
|
|
|
include(cmake/fmt.cmake)
|
2024-07-03 15:12:24 -06:00
|
|
|
include(cmake/json.cmake)
|
|
|
|
include(cmake/spdlog.cmake)
|
|
|
|
include(cmake/trtllm.cmake)
|
|
|
|
|
2024-07-10 07:48:44 -06:00
|
|
|
add_subdirectory("${trtllm_SOURCE_DIR}/cpp" "${trtllm_SOURCE_DIR}/..")
|
|
|
|
|
2024-07-08 16:32:41 -06:00
|
|
|
find_package(CUDAToolkit REQUIRED COMPONENTS CUDA::nvml)
|
|
|
|
|
2024-07-03 15:12:24 -06:00
|
|
|
# TGI TRTLLM Backend definition
|
|
|
|
add_library(tgi_trtllm_backend_impl STATIC include/backend.h lib/backend.cpp)
|
2024-07-10 07:48:44 -06:00
|
|
|
include_directories(${TGI_TRTLLM_BACKEND_TRT_INCLUDE_DIR})
|
2024-07-03 15:12:24 -06:00
|
|
|
target_include_directories(tgi_trtllm_backend_impl PRIVATE
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
|
|
$<INSTALL_INTERFACE:include>
|
|
|
|
)
|
2024-07-10 07:48:44 -06:00
|
|
|
target_include_directories(tgi_trtllm_backend_impl PUBLIC "${trtllm_SOURCE_DIR}/cpp/include")
|
|
|
|
target_link_libraries(tgi_trtllm_backend_impl PRIVATE tensorrt_llm nvinfer_plugin_tensorrt_llm CUDA::nvml)
|
2024-07-12 13:24:32 -06:00
|
|
|
target_link_libraries(tgi_trtllm_backend_impl PUBLIC nlohmann_json::nlohmann_json spdlog::spdlog fmt::fmt)
|
2024-07-03 15:12:24 -06:00
|
|
|
|
2024-07-11 15:24:01 -06:00
|
|
|
if (${TGI_TRTLLM_BACKEND_BUILD_EXAMPLES})
|
|
|
|
add_executable(tgi_trtllm_backend_example bin/example.cpp)
|
|
|
|
target_link_libraries(tgi_trtllm_backend_example PRIVATE tensorrt_llm nvinfer_plugin_tensorrt_llm tgi_trtllm_backend_impl)
|
2024-07-12 13:24:32 -06:00
|
|
|
target_link_libraries(tgi_trtllm_backend_example PUBLIC nlohmann_json::nlohmann_json spdlog::spdlog fmt::fmt)
|
2024-07-11 15:24:01 -06:00
|
|
|
endif ()
|
|
|
|
|
2024-07-12 13:24:32 -06:00
|
|
|
# TODO: need to find why we can't install fmt (include not found...)
|
|
|
|
#install(TARGETS tgi_trtllm_backend_impl tensorrt_llm nvinfer_plugin_tensorrt_llm spdlog fmt)
|
|
|
|
install(TARGETS tgi_trtllm_backend_impl tensorrt_llm nvinfer_plugin_tensorrt_llm)
|
2024-07-03 15:12:24 -06:00
|
|
|
|
2024-06-30 15:37:20 -06:00
|
|
|
#### Unit Tests ####
|
|
|
|
if (${TGI_TRTLLM_BACKEND_BUILD_TESTS})
|
|
|
|
message(STATUS "Building tests")
|
|
|
|
FetchContent_Declare(
|
|
|
|
Catch2
|
|
|
|
GIT_REPOSITORY https://github.com/catchorg/Catch2
|
|
|
|
GIT_TAG v3.6.0
|
|
|
|
)
|
|
|
|
FetchContent_MakeAvailable(Catch2)
|
|
|
|
|
2024-07-03 02:27:53 -06:00
|
|
|
add_executable(tgi_trtllm_backend_tests tests/infer_test.cpp)
|
2024-07-12 13:24:32 -06:00
|
|
|
target_link_libraries(tgi_trtllm_backend_tests PRIVATE tgi_trtllm_backend_impl Catch2::Catch2WithMain nlohmann_json::nlohmann_json spdlog::spdlog fmt::fmt)
|
2024-06-30 15:37:20 -06:00
|
|
|
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
|
|
|
|
include(CTest)
|
|
|
|
include(Catch)
|
2024-07-03 02:27:53 -06:00
|
|
|
catch_discover_tests(tgi_trtllm_backend_tests)
|
2024-07-03 15:12:24 -06:00
|
|
|
endif ()
|