diff --git a/CMakeLists.txt b/CMakeLists.txt index ff578c9724..0e0314882d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,18 @@ set(TRITON_COMMON_REPO_TAG "main" CACHE STRING "Tag for triton-inference-server/ set(TRITON_CORE_REPO_TAG "main" CACHE STRING "Tag for triton-inference-server/core repo") set(TRITON_BACKEND_REPO_TAG "main" CACHE STRING "Tag for triton-inference-server/backend repo") +# Git Repos +set(TRITON_THIRD_PARTY_GIT_REPO "https://github.com/triton-inference-server/third_party.git" CACHE STRING + "Git repository for third_party library.") +set(TRITON_COMMON_GIT_REPO "https://github.com/triton-inference-server/common.git" CACHE STRING + "Git repository for common library.") +set(TRITON_CORE_GIT_REPO "https://github.com/triton-inference-server/core.git" CACHE STRING + "Git repository for core library.") +set(TRITON_BACKEND_GIT_REPO "https://github.com/triton-inference-server/backend.git" CACHE STRING + "Git repository for backend library.") + + + # Third-party location set(TRITON_THIRD_PARTY_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/third-party" CACHE STRING "Location of third-party build") set(TRITON_THIRD_PARTY_SRC_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/third-party-src" CACHE STRING "Location of third-party source") @@ -114,12 +126,12 @@ include(FetchContent) FetchContent_Declare( repo-core - GIT_REPOSITORY ${TRITON_REPO_ORGANIZATION}/core.git + GIT_REPOSITORY ${TRITON_CORE_GIT_REPO} GIT_TAG ${TRITON_CORE_REPO_TAG} ) FetchContent_Declare( repo-third-party - GIT_REPOSITORY ${TRITON_REPO_ORGANIZATION}/third_party.git + GIT_REPOSITORY ${TRITON_THIRD_PARTY_GIT_REPO} GIT_TAG ${TRITON_THIRD_PARTY_REPO_TAG} ) @@ -240,9 +252,13 @@ ExternalProject_Add(triton-server -Dopentelemetry-cpp_DIR:PATH=${_FINDPACKAGE_OPENTELEMETRY_CONFIG_DIR} -DTRITON_REPO_ORGANIZATION:STRING=${TRITON_REPO_ORGANIZATION} -DTRITON_IGPU_BUILD:BOOL=${TRITON_IGPU_BUILD} + -DTRITON_THIRD_PARTY_GIT_REPO:STRING=${TRITON_THIRD_PARTY_GIT_REPO} -DTRITON_THIRD_PARTY_REPO_TAG:STRING=${TRITON_THIRD_PARTY_REPO_TAG} + -DTRITON_COMMON_GIT_REPO:STRING=${TRITON_COMMON_GIT_REPO} -DTRITON_COMMON_REPO_TAG:STRING=${TRITON_COMMON_REPO_TAG} + -DTRITON_CORE_GIT_REPO:STRING=${TRITON_CORE_GIT_REPO} -DTRITON_CORE_REPO_TAG:STRING=${TRITON_CORE_REPO_TAG} + -DTRITON_BACKEND_GIT_REPO:STRING=${TRITON_BACKEND_GIT_REPO} -DTRITON_BACKEND_REPO_TAG:STRING=${TRITON_BACKEND_REPO_TAG} -DTRITON_EXTRA_LIB_PATHS:PATH=${TRITON_EXTRA_LIB_PATHS} -DTRITON_ENABLE_ASAN:BOOL=${TRITON_ENABLE_ASAN} diff --git a/build.py b/build.py index 283f959001..4d52c34f8c 100755 --- a/build.py +++ b/build.py @@ -92,6 +92,11 @@ THIS_SCRIPT_DIR = os.path.dirname(os.path.abspath(getsourcefile(lambda: 0))) +DEFAULT_GIT_ORG = "https://github.com/triton-inference-server/" + +COMPONENTS_KEYS = ["common", "core", "backend", "thirdparty"] +COMPONENTS_GIT_ORG_KEYS = ["agent", "cache", "common", "core", "backend", "thirdparty"] + def log(msg, force=False): if force or not FLAGS.quiet: @@ -325,6 +330,7 @@ def gitclone(self, repo, tag, subdir, org): f" git clone --recursive --single-branch --depth=1 -b {tag} {org}/{repo}.git {subdir};", check_exitcode=True, ) + print(f"Cloned {tag} {org} {repo}") self.cmd("}" if target_platform() == "windows" else "fi") @@ -434,18 +440,36 @@ def cmake_cache_extra_args(): return args -def core_cmake_args(components, backends, cmake_dir, install_dir): +def core_cmake_args(components, components_git_orgs, backends, cmake_dir, install_dir): cargs = [ cmake_core_arg("CMAKE_BUILD_TYPE", None, FLAGS.build_type), cmake_core_arg("CMAKE_INSTALL_PREFIX", "PATH", install_dir), cmake_core_arg("TRITON_VERSION", "STRING", FLAGS.version), cmake_core_arg("TRITON_REPO_ORGANIZATION", "STRING", FLAGS.github_organization), cmake_core_arg("TRITON_COMMON_REPO_TAG", "STRING", components["common"]), + cmake_core_arg( + "TRITON_COMMON_GIT_REPO", + "STRING", + components_git_orgs["common"] + "common.git", + ), cmake_core_arg("TRITON_CORE_REPO_TAG", "STRING", components["core"]), + cmake_core_arg( + "TRITON_CORE_GIT_REPO", "STRING", components_git_orgs["core"] + "core.git" + ), cmake_core_arg("TRITON_BACKEND_REPO_TAG", "STRING", components["backend"]), + cmake_core_arg( + "TRITON_BACKEND_GIT_REPO", + "STRING", + components_git_orgs["backend"] + "backend.git", + ), cmake_core_arg( "TRITON_THIRD_PARTY_REPO_TAG", "STRING", components["thirdparty"] ), + cmake_core_arg( + "TRITON_THIRD_PARTY_GIT_REPO", + "STRING", + components_git_orgs["thirdparty"] + "third_party.git", + ), ] cargs.append(cmake_core_enable("TRITON_ENABLE_LOGGING", FLAGS.enable_logging)) @@ -498,7 +522,7 @@ def repoagent_repo(ra): return "{}_repository_agent".format(ra) -def repoagent_cmake_args(images, components, ra, install_dir): +def repoagent_cmake_args(images, components, components_git_orgs, ra, install_dir): args = [] cargs = args + [ @@ -508,7 +532,15 @@ def repoagent_cmake_args(images, components, ra, install_dir): "TRITON_REPO_ORGANIZATION", "STRING", FLAGS.github_organization ), cmake_repoagent_arg("TRITON_COMMON_REPO_TAG", "STRING", components["common"]), + cmake_repoagent_arg( + "TRITON_COMMON_GIT_REPO", + "STRING", + components_git_orgs["common"] + "common.git", + ), cmake_repoagent_arg("TRITON_CORE_REPO_TAG", "STRING", components["core"]), + cmake_repoagent_arg( + "TRITON_CORE_GIT_REPO", "STRING", components_git_orgs["core"] + "core.git" + ), ] cargs.append(cmake_repoagent_enable("TRITON_ENABLE_GPU", FLAGS.enable_gpu)) @@ -522,7 +554,7 @@ def cache_repo(cache): return "{}_cache".format(cache) -def cache_cmake_args(images, components, cache, install_dir): +def cache_cmake_args(images, components, components_git_orgs, cache, install_dir): args = [] cargs = args + [ @@ -532,7 +564,15 @@ def cache_cmake_args(images, components, cache, install_dir): "TRITON_REPO_ORGANIZATION", "STRING", FLAGS.github_organization ), cmake_cache_arg("TRITON_COMMON_REPO_TAG", "STRING", components["common"]), + cmake_cache_arg( + "TRITON_COMMON_GIT_REPO", + "STRING", + components_git_orgs["common"] + "common.git", + ), cmake_cache_arg("TRITON_CORE_REPO_TAG", "STRING", components["core"]), + cmake_cache_arg( + "TRITON_CORE_GIT_REPO", "STRING", components_git_orgs["core"] + "core.git" + ), ] cargs.append(cmake_cache_enable("TRITON_ENABLE_GPU", FLAGS.enable_gpu)) @@ -545,7 +585,9 @@ def backend_repo(be): return "{}_backend".format(be) -def backend_cmake_args(images, components, be, install_dir, library_paths): +def backend_cmake_args( + images, components, components_git_orgs, be, install_dir, library_paths +): cmake_build_type = FLAGS.build_type if be == "onnxruntime": @@ -553,7 +595,9 @@ def backend_cmake_args(images, components, be, install_dir, library_paths): elif be == "openvino": args = openvino_cmake_args() elif be == "tensorflow": - args = tensorflow_cmake_args(images, library_paths) + args = tensorflow_cmake_args( + images, library_paths, components, components_git_orgs + ) elif be == "python": args = [] elif be == "dali": @@ -582,10 +626,28 @@ def backend_cmake_args(images, components, be, install_dir, library_paths): be, "TRITON_REPO_ORGANIZATION", "STRING", FLAGS.github_organization ), cmake_backend_arg(be, "TRITON_COMMON_REPO_TAG", "STRING", components["common"]), + cmake_backend_arg( + be, + "TRITON_COMMON_GIT_REPO", + "STRING", + components_git_orgs["common"] + "common.git", + ), cmake_backend_arg(be, "TRITON_CORE_REPO_TAG", "STRING", components["core"]), + cmake_backend_arg( + be, + "TRITON_CORE_GIT_REPO", + "STRING", + components_git_orgs["core"] + "core.git", + ), cmake_backend_arg( be, "TRITON_BACKEND_REPO_TAG", "STRING", components["backend"] ), + cmake_backend_arg( + be, + "TRITON_BACKEND_GIT_REPO", + "STRING", + components_git_orgs["backend"] + "backend.git", + ), ] cargs.append(cmake_backend_enable(be, "TRITON_ENABLE_GPU", FLAGS.enable_gpu)) @@ -761,9 +823,8 @@ def tensorrt_cmake_args(): return cargs -def tensorflow_cmake_args(images, library_paths): +def tensorflow_cmake_args(images, library_paths, components, components_git_orgs): backend_name = "tensorflow" - extra_args = [] # If a specific TF image is specified use it, otherwise pull from NGC. if backend_name in images: @@ -772,8 +833,36 @@ def tensorflow_cmake_args(images, library_paths): image = "nvcr.io/nvidia/tensorflow:{}-tf2-py3".format( FLAGS.upstream_container_version ) + extra_args = [ - cmake_backend_arg(backend_name, "TRITON_TENSORFLOW_DOCKER_IMAGE", None, image) + cmake_backend_arg( + "tensorflow", "TRITON_COMMON_REPO_TAG", "STRING", components["common"] + ), + cmake_backend_arg( + "tensorflow", + "TRITON_COMMON_GIT_REPO", + "STRING", + components_git_orgs["common"] + "common.git", + ), + cmake_backend_arg( + "tensorflow", "TRITON_CORE_REPO_TAG", "STRING", components["core"] + ), + cmake_backend_arg( + "tensorflow", + "TRITON_CORE_GIT_REPO", + "STRING", + components_git_orgs["core"] + "core.git", + ), + cmake_backend_arg( + "tensorflow", "TRITON_BACKEND_REPO_TAG", "STRING", components["backend"] + ), + cmake_backend_arg( + "tensorflow", + "TRITON_BACKEND_GIT_REPO", + "STRING", + components_git_orgs["backend"] + "backend.git", + ), + cmake_backend_arg(backend_name, "TRITON_TENSORFLOW_DOCKER_IMAGE", None, image), ] return extra_args @@ -1655,7 +1744,14 @@ def create_docker_build_script(script_name, container_install_dir, container_ci_ def core_build( - cmake_script, repo_dir, cmake_dir, build_dir, install_dir, components, backends + cmake_script, + repo_dir, + cmake_dir, + build_dir, + install_dir, + components, + components_git_orgs, + backends, ): repo_build_dir = os.path.join(build_dir, "tritonserver", "build") repo_install_dir = os.path.join(build_dir, "tritonserver", "install") @@ -1663,10 +1759,13 @@ def core_build( cmake_script.commentln(8) cmake_script.comment("Triton core library and tritonserver executable") cmake_script.comment() + cmake_script.mkdir(repo_build_dir) cmake_script.cwd(repo_build_dir) cmake_script.cmake( - core_cmake_args(components, backends, cmake_dir, repo_install_dir) + core_cmake_args( + components, components_git_orgs, backends, cmake_dir, repo_install_dir + ) ) cmake_script.makeinstall() @@ -1746,9 +1845,10 @@ def backend_build( tag, build_dir, install_dir, - github_organization, images, components, + components_git_orgs, + github_org, library_paths, ): repo_build_dir = os.path.join(build_dir, be, "build") @@ -1760,7 +1860,7 @@ def backend_build( cmake_script.comment() cmake_script.mkdir(build_dir) cmake_script.cwd(build_dir) - cmake_script.gitclone(backend_repo(be), tag, be, github_organization) + cmake_script.gitclone(backend_repo(be), tag, be, github_org) if be == "tensorrtllm": tensorrtllm_prebuild(cmake_script) @@ -1768,7 +1868,14 @@ def backend_build( cmake_script.mkdir(repo_build_dir) cmake_script.cwd(repo_build_dir) cmake_script.cmake( - backend_cmake_args(images, components, be, repo_install_dir, library_paths) + backend_cmake_args( + images, + components, + components_git_orgs, + be, + repo_install_dir, + library_paths, + ) ) cmake_script.makeinstall() @@ -1820,7 +1927,13 @@ def backend_clone( def repo_agent_build( - ra, cmake_script, build_dir, install_dir, repoagent_repo, repoagents + ra, + cmake_script, + build_dir, + install_dir, + repoagent_repo, + repoagents, + components_git_orgs, ): repo_build_dir = os.path.join(build_dir, ra, "build") repo_install_dir = os.path.join(build_dir, ra, "install") @@ -1832,12 +1945,16 @@ def repo_agent_build( cmake_script.mkdir(build_dir) cmake_script.cwd(build_dir) cmake_script.gitclone( - repoagent_repo(ra), repoagents[ra], ra, FLAGS.github_organization + repoagent_repo(ra), repoagents[ra], ra, components_git_orgs["agent"] ) cmake_script.mkdir(repo_build_dir) cmake_script.cwd(repo_build_dir) - cmake_script.cmake(repoagent_cmake_args(images, components, ra, repo_install_dir)) + cmake_script.cmake( + repoagent_cmake_args( + images, components, components_git_orgs, ra, repo_install_dir + ) + ) cmake_script.makeinstall() cmake_script.mkdir(os.path.join(install_dir, "repoagents")) @@ -1852,7 +1969,15 @@ def repo_agent_build( cmake_script.blankln() -def cache_build(cache, cmake_script, build_dir, install_dir, cache_repo, caches): +def cache_build( + cache, + cmake_script, + build_dir, + install_dir, + cache_repo, + caches, + components_git_orgs, +): repo_build_dir = os.path.join(build_dir, cache, "build") repo_install_dir = os.path.join(build_dir, cache, "install") @@ -1863,12 +1988,16 @@ def cache_build(cache, cmake_script, build_dir, install_dir, cache_repo, caches) cmake_script.mkdir(build_dir) cmake_script.cwd(build_dir) cmake_script.gitclone( - cache_repo(cache), caches[cache], cache, FLAGS.github_organization + cache_repo(cache), caches[cache], cache, components_git_orgs["cache"] ) cmake_script.mkdir(repo_build_dir) cmake_script.cwd(repo_build_dir) - cmake_script.cmake(cache_cmake_args(images, components, cache, repo_install_dir)) + cmake_script.cmake( + cache_cmake_args( + images, components, components_git_orgs, cache, repo_install_dir + ) + ) cmake_script.makeinstall() cmake_script.mkdir(os.path.join(install_dir, "caches")) @@ -2326,6 +2455,14 @@ def enable_all(): required=False, help='The version of a component to use in the build as :. can be "common", "core", "backend" or "thirdparty". indicates the git tag/branch to use for the build. Currently does not support pull-request reference. If the version is non-development then the default is the release branch matching the container version (e.g. version YY.MM -> branch rYY.MM); otherwise the default is "main" (e.g. version YY.MMdev -> branch main).', ) + parser.add_argument( + "--git-org", + action="append", + required=False, + help="The org to use for a component as :. can be one of {}".format( + COMPONENTS_GIT_ORG_KEYS + ), + ) parser.add_argument( "--repoagent", action="append", @@ -2375,6 +2512,8 @@ def enable_all(): FLAGS.image = [] if FLAGS.repo_tag is None: FLAGS.repo_tag = [] + if FLAGS.git_org is None: + FLAGS.git_org = [] if FLAGS.backend is None: FLAGS.backend = [] if FLAGS.endpoint is None: @@ -2602,22 +2741,37 @@ def enable_all(): OVERRIDE_BACKEND_CMAKE_FLAGS[be][parts[0]] = parts[1] # Initialize map of common components and repo-tag for each. - components = { - "common": default_repo_tag, - "core": default_repo_tag, - "backend": default_repo_tag, - "thirdparty": default_repo_tag, - } + components = {key: default_repo_tag for key in COMPONENTS_KEYS} for be in FLAGS.repo_tag: parts = be.split(":") fail_if(len(parts) != 2, "--repo-tag must specify :") fail_if( parts[0] not in components, - '--repo-tag must be "common", "core", "backend", or "thirdparty"', + '--repo-tag must be one of "{}"'.format(components.keys()), ) components[parts[0]] = parts[1] + + # Initialize map of common components and git repository for each. + components_git_orgs = {key: DEFAULT_GIT_ORG for key in COMPONENTS_GIT_ORG_KEYS} + for git_org in FLAGS.git_org: + parts = git_org.split("!") + fail_if( + len(parts) != 2, + "--git-org must specify !, note '!' separator.", + ) + fail_if( + parts[0] not in components_git_orgs, + '--git-org must be one of "{}"'.format( + components_git_orgs.keys() + ), + ) + components_git_orgs[parts[0]] = parts[1] for c in components: - log('component "{}" at tag/branch "{}"'.format(c, components[c])) + log( + 'component "{}" at tag/branch "{}" from repository "{}"'.format( + c, components[c], components_git_orgs[c] + ) + ) # Set the build, install, and cmake directories to use for the # generated build scripts and Dockerfiles. If building without @@ -2634,8 +2788,11 @@ def enable_all(): script_build_dir = os.path.normpath( os.path.join(FLAGS.tmp_dir, "tritonbuild").replace("\\", "/") ) + log(f"script build dir: {script_build_dir}") script_install_dir = os.path.normpath(os.path.join(script_build_dir, "install")) + log(f"script install dir: {script_install_dir}") script_ci_dir = os.path.normpath(os.path.join(script_build_dir, "ci")) + log(f"script ci dir: {script_ci_dir}") if target_platform() == "windows": script_repo_dir = script_cmake_dir = os.path.normpath("c:/workspace") else: @@ -2659,16 +2816,17 @@ def enable_all(): cmake_script.blankln() # Commands to build the core shared library and the server executable. - if not FLAGS.no_core_build: - core_build( - cmake_script, - script_repo_dir, - script_cmake_dir, - script_build_dir, - script_install_dir, - components, - backends, - ) + # if not FLAGS.no_core_build: + core_build( + cmake_script, + script_repo_dir, + script_cmake_dir, + script_build_dir, + script_install_dir, + components, + components_git_orgs, + backends, + ) # Commands to build each backend... for be in backends: @@ -2676,11 +2834,10 @@ def enable_all(): if be in CORE_BACKENDS: continue + github_org = components_git_orgs["backend"] # If armnn_tflite backend, source from external repo for git clone if be == "armnn_tflite": - github_organization = "https://gitlab.com/arm-research/smarter/" - else: - github_organization = FLAGS.github_organization + github_org = "https://gitlab.com/arm-research/smarter/" if be == "vllm": backend_clone( @@ -2689,7 +2846,7 @@ def enable_all(): backends[be], script_build_dir, script_install_dir, - github_organization, + github_org, ) else: backend_build( @@ -2698,9 +2855,10 @@ def enable_all(): backends[be], script_build_dir, script_install_dir, - github_organization, images, components, + components_git_orgs, + github_org, library_paths, ) @@ -2713,6 +2871,7 @@ def enable_all(): script_install_dir, repoagent_repo, repoagents, + components_git_orgs, ) # Commands to build each cache... @@ -2724,6 +2883,7 @@ def enable_all(): script_install_dir, cache_repo, caches, + components_git_orgs, ) # Commands needed only when building with Docker... diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 783275d8d7..8e484ca650 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -40,17 +40,17 @@ include(FetchContent) FetchContent_Declare( repo-common - GIT_REPOSITORY ${TRITON_REPO_ORGANIZATION}/common.git + GIT_REPOSITORY ${TRITON_COMMON_GIT_REPO} GIT_TAG ${TRITON_COMMON_REPO_TAG} ) FetchContent_Declare( repo-core - GIT_REPOSITORY ${TRITON_REPO_ORGANIZATION}/core.git + GIT_REPOSITORY ${TRITON_CORE_GIT_REPO} GIT_TAG ${TRITON_CORE_REPO_TAG} ) FetchContent_Declare( repo-backend - GIT_REPOSITORY ${TRITON_REPO_ORGANIZATION}/backend.git + GIT_REPOSITORY ${TRITON_BACKEND_GIT_REPO} GIT_TAG ${TRITON_BACKEND_REPO_TAG} )