Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ project(tritoncore LANGUAGES C CXX)
# TRITON_CORE_HEADERS_ONLY=OFF to also build libtritonserver.so.
option(TRITON_CORE_HEADERS_ONLY "Build only headers and stub" ON)

option(TRITON_SKIP_THIRD_PARTY_FETCH
"Skip FetchContent/ExternalProject for third-party deps (provided by Conan)" OFF)

#
# Specifying min required C++ standard
#
Expand Down Expand Up @@ -153,7 +156,7 @@ set_target_properties(
#
# Shared library implementing Triton Server API
#
if(NOT TRITON_CORE_HEADERS_ONLY)
if(NOT TRITON_CORE_HEADERS_ONLY AND NOT TRITON_SKIP_THIRD_PARTY_FETCH)
include(CMakeDependentOption)

set(TRITON_VERSION "0.0.0" CACHE STRING "The version of the Triton shared library" )
Expand Down Expand Up @@ -357,7 +360,12 @@ if(NOT TRITON_CORE_HEADERS_ONLY)
-DTRITON_VERSION:STRING=${TRITON_VERSION}
DEPENDS ${TRITON_DEPENDS}
)
endif() # NOT TRITON_CORE_HEADERS_ONLY
endif() # NOT TRITON_CORE_HEADERS_ONLY AND NOT TRITON_SKIP_THIRD_PARTY_FETCH

if(NOT TRITON_CORE_HEADERS_ONLY AND TRITON_SKIP_THIRD_PARTY_FETCH)
# When called from the parent server build — deps already provided by Conan
add_subdirectory(src)
endif()

#
# Install
Expand Down
4 changes: 4 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"version": 6,
"include": ["cmake/CMakePresets.json"]
}
63 changes: 63 additions & 0 deletions cmake/CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"version": 6,
"cmakeMinimumRequired": { "major": 3, "minor": 31, "patch": 8 },
"$comment": "Standalone build presets for triton-core. For integrated server builds use server/cmake/CMakePresets.json — it includes core via add_subdirectory and its variables take precedence.",
"configurePresets": [
{
"name": "conan-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"toolchainFile": "${sourceDir}/build/${presetName}/conan/conan_toolchain.cmake",
"cacheVariables": { "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" }
},
{
"name": "release",
"inherits": "conan-base",
"displayName": "Release (GPU + Metrics)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"TRITON_ENABLE_GPU": "ON",
"TRITON_ENABLE_METRICS": "ON",
"TRITON_CORE_HEADERS_ONLY": "OFF"
}
},
{
"name": "debug",
"inherits": "conan-base",
"displayName": "Debug (GPU + Metrics)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"TRITON_ENABLE_GPU": "ON",
"TRITON_ENABLE_METRICS": "ON",
"TRITON_CORE_HEADERS_ONLY": "OFF"
}
},
{
"name": "headers-only",
"inherits": "conan-base",
"displayName": "Headers only (no build)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"TRITON_CORE_HEADERS_ONLY": "ON"
}
},
{
"name": "cpu-only",
"inherits": "conan-base",
"displayName": "Release CPU-only",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"TRITON_ENABLE_GPU": "OFF",
"TRITON_ENABLE_METRICS": "ON",
"TRITON_CORE_HEADERS_ONLY": "OFF"
}
}
],
"buildPresets": [
{ "name": "release", "configurePreset": "release" },
{ "name": "debug", "configurePreset": "debug" },
{ "name": "headers-only", "configurePreset": "headers-only" },
{ "name": "cpu-only", "configurePreset": "cpu-only" }
]
}
53 changes: 53 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps, cmake_layout
from conan.errors import ConanInvalidConfiguration


class TritonCoreConan(ConanFile):
name = "triton-core"
version = "2.68.0"
settings = "os", "compiler", "build_type", "arch"
options = {
"enable_gpu": [True, False],
"enable_metrics": [True, False],
"headers_only": [True, False],
}
default_options = {
"enable_gpu": True,
"enable_metrics": True,
"headers_only": False,
}

def validate(self):
if self.settings.os != "Linux":
raise ConanInvalidConfiguration("triton-core only supports Linux")

def requirements(self):
if not self.options.headers_only:
self.requires("protobuf/3.21.12")
self.requires("re2/20230301")
self.requires("rapidjson/cci.20230929")
if self.options.enable_gpu:
self.requires("cnmem/1.0.0")
self.requires("dcgm/4.5.3")
if self.options.enable_metrics:
self.requires("prometheus-cpp/1.2.4")

def configure(self):
if not self.options.headers_only:
if self.options.enable_metrics:
self.options["prometheus-cpp"].shared = False
self.options["prometheus-cpp"].with_pull = False
self.options["prometheus-cpp"].with_push = False

def layout(self):
cmake_layout(self)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["TRITON_CORE_HEADERS_ONLY"] = self.options.headers_only
tc.variables["TRITON_ENABLE_GPU"] = self.options.enable_gpu
tc.variables["TRITON_ENABLE_METRICS"] = self.options.enable_metrics
tc.variables["TRITON_SKIP_THIRD_PARTY_FETCH"] = True
tc.generate()
CMakeDeps(self).generate()
13 changes: 13 additions & 0 deletions profiles/linux-gcc13-debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[settings]
os=Linux
arch=x86_64
compiler=gcc
compiler.version=13
compiler.libcxx=libstdc++11
compiler.cppstd=17
build_type=Debug

[buildenv]
CC=/usr/bin/gcc-13
CXX=/usr/bin/g++-13
PATH=+/home/user/.venv/bin
13 changes: 13 additions & 0 deletions profiles/linux-gcc13-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[settings]
os=Linux
arch=x86_64
compiler=gcc
compiler.version=13
compiler.libcxx=libstdc++11
compiler.cppstd=17
build_type=Release

[buildenv]
CC=/usr/bin/gcc-13
CXX=/usr/bin/g++-13
PATH=+/home/user/.venv/bin
49 changes: 28 additions & 21 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,24 @@ endif()
#
include(FetchContent)

FetchContent_Declare(
repo-common
GIT_REPOSITORY ${TRITON_REPO_ORGANIZATION}/common.git
GIT_TAG ${TRITON_COMMON_REPO_TAG}
)
if(NOT TRITON_SKIP_THIRD_PARTY_FETCH)
FetchContent_Declare(
repo-common
GIT_REPOSITORY ${TRITON_REPO_ORGANIZATION}/common.git
GIT_TAG ${TRITON_COMMON_REPO_TAG}
)

set(TRITON_COMMON_ENABLE_PROTOBUF ON)
set(TRITON_COMMON_ENABLE_PROTOBUF ON)

FetchContent_MakeAvailable(repo-common)
FetchContent_MakeAvailable(repo-common)
endif()

#
# CUDA
#
if(${TRITON_ENABLE_GPU})
find_package(CUDAToolkit REQUIRED)
set(CMAKE_CUDA_RUNTIME_LIBRARY Shared)
endif() # TRITON_ENABLE_GPU

#
Expand Down Expand Up @@ -262,7 +265,7 @@ else()
triton-core
PROPERTIES
LINK_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libtritonserver.ldscript
LINK_FLAGS "-Wl,--version-script libtritonserver.ldscript"
LINK_FLAGS "-Wl,--version-script ${CMAKE_CURRENT_BINARY_DIR}/libtritonserver.ldscript"
)
endif()

Expand All @@ -287,11 +290,13 @@ target_include_directories(
)

if(${TRITON_ENABLE_GPU})
target_include_directories(
triton-core
PRIVATE
${CNMEM_PATH}/include
)
if(NOT TARGET cnmem::cnmem)
target_include_directories(
triton-core
PRIVATE
${CNMEM_PATH}/include
)
endif()
endif() # TRITON_ENABLE_GPU

if(${TRITON_ENABLE_METRICS})
Expand Down Expand Up @@ -503,14 +508,16 @@ if(${TRITON_ENABLE_AZURE_STORAGE})
)
endif() # TRITON_ENABLE_AZURE_STORAGE

if(${TRITON_ENABLE_GPU})
find_library(CNMEM_LIBRARY NAMES cnmem PATHS ${CNMEM_PATH}/lib)
target_link_libraries(
triton-core
PRIVATE
${CNMEM_LIBRARY}
CUDA::cudart
)
if(TRITON_ENABLE_GPU)
if(TARGET cnmem::cnmem)
# Provided by Conan — use imported target
target_link_libraries(triton-core PRIVATE cnmem::cnmem CUDA::cudart)
else()
# Fallback for standalone builds
find_library(CNMEM_LIBRARY cnmem PATHS ${CNMEM_PATH}/lib)
target_include_directories(triton-core PRIVATE ${CNMEM_PATH}/include)
target_link_libraries(triton-core PRIVATE ${CNMEM_LIBRARY} CUDA::cudart)
endif()
endif() # TRITON_ENABLE_GPU

if(${TRITON_ENABLE_METRICS_GPU})
Expand Down
25 changes: 8 additions & 17 deletions src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ if(${TRITON_ENABLE_GPU})
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../include
${GTEST_INCLUDE_DIRS}
${CNMEM_PATH}/include
${Boost_INCLUDE_DIRS}
)

Expand All @@ -137,8 +136,6 @@ if(${TRITON_ENABLE_GPU})
TRITON_MIN_COMPUTE_CAPABILITY=${TRITON_MIN_COMPUTE_CAPABILITY}
)

find_library(CNMEM_LIBRARY NAMES cnmem PATHS ${CNMEM_PATH}/lib)

target_link_libraries(
response_cache_test
PRIVATE
Expand All @@ -150,7 +147,9 @@ if(${TRITON_ENABLE_GPU})
GTest::gtest
GTest::gtest_main
protobuf::libprotobuf
${CNMEM_LIBRARY}
cnmem::cnmem
rapidjson
re2::re2
CUDA::cudart
)

Expand Down Expand Up @@ -240,7 +239,6 @@ if(${TRITON_ENABLE_GPU})
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../include
${GTEST_INCLUDE_DIRS}
${CNMEM_PATH}/include
)

target_compile_definitions(
Expand All @@ -251,8 +249,6 @@ if(${TRITON_ENABLE_GPU})
TRITON_MIN_COMPUTE_CAPABILITY=${TRITON_MIN_COMPUTE_CAPABILITY}
)

find_library(CNMEM_LIBRARY NAMES cnmem PATHS ${CNMEM_PATH}/lib)

target_link_libraries(
memory_test
PRIVATE
Expand All @@ -262,7 +258,7 @@ if(${TRITON_ENABLE_GPU})
GTest::gtest
GTest::gtest_main
protobuf::libprotobuf
${CNMEM_LIBRARY}
cnmem::cnmem
CUDA::cudart
)

Expand Down Expand Up @@ -307,7 +303,6 @@ if(${TRITON_ENABLE_GPU})
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../include
${GTEST_INCLUDE_DIRS}
${CNMEM_PATH}/include
)

target_compile_definitions(
Expand All @@ -318,8 +313,6 @@ if(${TRITON_ENABLE_GPU})
TRITON_MIN_COMPUTE_CAPABILITY=${TRITON_MIN_COMPUTE_CAPABILITY}
)

find_library(CNMEM_LIBRARY NAMES cnmem PATHS ${CNMEM_PATH}/lib)

target_link_libraries(
pinned_memory_manager_test
PRIVATE
Expand All @@ -329,7 +322,7 @@ if(${TRITON_ENABLE_GPU})
GTest::gtest
GTest::gtest_main
protobuf::libprotobuf
${CNMEM_LIBRARY}
cnmem::cnmem
CUDA::cudart
)

Expand Down Expand Up @@ -432,6 +425,7 @@ target_link_libraries(
GTest::gtest
GTest::gtest_main
protobuf::libprotobuf
re2::re2
)

install(
Expand Down Expand Up @@ -499,7 +493,7 @@ if(${TRITON_ENABLE_METRICS})
target_link_libraries(
metrics_api_test
PRIVATE
${CNMEM_LIBRARY}
cnmem::cnmem
CUDA::cudart
)
endif()
Expand Down Expand Up @@ -656,7 +650,6 @@ if(${TRITON_ENABLE_GPU})
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../include
${GTEST_INCLUDE_DIRS}
${CNMEM_PATH}/include
)

target_compile_definitions(
Expand All @@ -667,8 +660,6 @@ if(${TRITON_ENABLE_GPU})
TRITON_MIN_COMPUTE_CAPABILITY=${TRITON_MIN_COMPUTE_CAPABILITY}
)

find_library(CNMEM_LIBRARY NAMES cnmem PATHS ${CNMEM_PATH}/lib)

target_link_libraries(
input_byte_size_test
PRIVATE
Expand All @@ -682,7 +673,7 @@ if(${TRITON_ENABLE_GPU})
GTest::gmock
protobuf::libprotobuf
CUDA::cudart
${CNMEM_LIBRARY}
cnmem::cnmem
)
else()
add_executable(
Expand Down
Loading