From 9b84304e2d18190001de2b467e7dccaf42229761 Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Sat, 30 Sep 2023 21:58:16 -0700 Subject: [PATCH 1/8] Split build per backend --- build.py | 140 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 87 insertions(+), 53 deletions(-) diff --git a/build.py b/build.py index 2626dd4986..5f3d9b53b2 100755 --- a/build.py +++ b/build.py @@ -1093,6 +1093,7 @@ def create_dockerfile_linux( if "tensorrtllm" in backends: df += """ # Remove TRT contents that are not needed in runtime +ENV TRT_ROOT=/usr/local/tensorrt RUN ARCH="$(uname -i)" \\ && rm -fr ${TRT_ROOT}/bin ${TRT_ROOT}/targets/${ARCH}-linux-gnu/bin ${TRT_ROOT}/data \\ && rm -fr ${TRT_ROOT}/doc ${TRT_ROOT}/onnx_graphsurgeon ${TRT_ROOT}/python \\ @@ -1253,7 +1254,11 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach """ if "vllm" in backends: - df += """ + # [DLIS-5606] Build Conda environment for vLLM backend + # Remove Pip install once vLLM backend moves to Conda environment. + # TODO: remove condition on architecutre once the vLLM backend is supports arm64 + if platform.machine() == "x86_64": + df += """ # vLLM needed for vLLM backend RUN pip3 install vllm=={} """.format( @@ -1480,11 +1485,7 @@ def create_docker_build_script(script_name, container_install_dir, container_ci_ ) docker_script.comment() - cachefrommap = [ - "tritonserver_buildbase", - "tritonserver_buildbase_cache0", - "tritonserver_buildbase_cache1", - ] + cachefrommap = FLAGS.cache_from_map baseargs = [ "docker", @@ -1557,7 +1558,7 @@ def create_docker_build_script(script_name, container_install_dir, container_ci_ docker_script.cmd(["docker", "rm", "tritonserver_builder"]) else: docker_script._file.write( - 'if [ "$(docker ps -a | grep tritonserver_builder)" ]; then docker rm -f tritonserver_builder; fi\n' + 'if [ ! -z $( docker ps -a --filter "name=tritonserver_builder$" -q ) ]; then docker rm tritonserver_builder; fi\n' ) docker_script.cmd(runargs, check_exitcode=True) @@ -1571,57 +1572,59 @@ def create_docker_build_script(script_name, container_install_dir, container_ci_ ], check_exitcode=True, ) - docker_script.cmd( - [ - "docker", - "cp", - "tritonserver_builder:/tmp/tritonbuild/ci", - FLAGS.build_dir, - ], - check_exitcode=True, - ) + + if not FLAGS.ci_split: + docker_script.cmd( + [ + "docker", + "cp", + "tritonserver_builder:/tmp/tritonbuild/ci", + FLAGS.build_dir, + ], + check_exitcode=True, + ) - # - # Final image... tritonserver - # - docker_script.blankln() - docker_script.commentln(8) - docker_script.comment("Create final tritonserver image") - docker_script.comment() + # + # Final image... tritonserver + # + docker_script.blankln() + docker_script.commentln(8) + docker_script.comment("Create final tritonserver image") + docker_script.comment() - finalargs = [ - "docker", - "build", - "-t", - "tritonserver", - "-f", - os.path.join(FLAGS.build_dir, "Dockerfile"), - ".", - ] + finalargs = [ + "docker", + "build", + "-t", + "tritonserver", + "-f", + os.path.join(FLAGS.build_dir, "Dockerfile"), + ".", + ] - docker_script.cwd(THIS_SCRIPT_DIR) - docker_script.cmd(finalargs, check_exitcode=True) + docker_script.cwd(THIS_SCRIPT_DIR) + docker_script.cmd(finalargs, check_exitcode=True) - # - # CI base image... tritonserver_cibase - # - docker_script.blankln() - docker_script.commentln(8) - docker_script.comment("Create CI base image") - docker_script.comment() + # + # CI base image... tritonserver_cibase + # + docker_script.blankln() + docker_script.commentln(8) + docker_script.comment("Create CI base image") + docker_script.comment() - cibaseargs = [ - "docker", - "build", - "-t", - "tritonserver_cibase", - "-f", - os.path.join(FLAGS.build_dir, "Dockerfile.cibase"), - ".", - ] + cibaseargs = [ + "docker", + "build", + "-t", + "tritonserver_cibase", + "-f", + os.path.join(FLAGS.build_dir, "Dockerfile.cibase"), + ".", + ] - docker_script.cwd(THIS_SCRIPT_DIR) - docker_script.cmd(cibaseargs, check_exitcode=True) + docker_script.cwd(THIS_SCRIPT_DIR) + docker_script.cmd(cibaseargs, check_exitcode=True) def core_build( @@ -2046,6 +2049,15 @@ def enable_all(): if ep not in FLAGS.endpoint: FLAGS.endpoint += [ep] +def split_cmake_script(script_name): + if target_platform() == "windows": + script_name += ".ps1" + return BuildScript( + os.path.join(FLAGS.build_dir, script_name), + verbose=FLAGS.verbose, + desc=("Build script for Triton Inference Server"), + ) + if __name__ == "__main__": parser = argparse.ArgumentParser() @@ -2338,6 +2350,19 @@ def enable_all(): required=False, help="Override specified backend CMake argument in the build as :=. The argument is passed to CMake as -D=. This flag only impacts CMake arguments that are used by build.py. To unconditionally add a CMake argument to the backend build use --extra-backend-cmake-arg.", ) + parser.add_argument( + "--ci-split", + action="store_true", + required=False, + help="Requires to split CI build into multiple builds. Will generate cmake build script separatelly for each backend", + ) + parser.add_argument( + "--cache-from-map", + action="append", + required=False, + help="Requires to split CI build into multiple builds. Will generate cmake build script separatelly for each backend", + default = [ "tritonserver_buildbase", "tritonserver_buildbase_cache0", "tritonserver_buildbase_cache1", ], + ) FLAGS = parser.parse_args() @@ -2639,9 +2664,12 @@ def enable_all(): components, backends, ) - # Commands to build each backend... for be in backends: + # Define fucntion to create cmake_script with backend name as suffix + if FLAGS.ci_split: + cmake_script = split_cmake_script("cmake_build_backend_" + be) + # Core backends are not built separately from core so skip... if be in CORE_BACKENDS: continue @@ -2676,6 +2704,8 @@ def enable_all(): # Commands to build each repo agent... for ra in repoagents: + if FLAGS.ci_split: + cmake_script = split_cmake_script("cmake_build_agent_" + ra) repo_agent_build( ra, cmake_script, @@ -2687,6 +2717,8 @@ def enable_all(): # Commands to build each cache... for cache in caches: + if FLAGS.ci_split: + cmake_script = split_cmake_script("cmake_build_cache_" + cache) cache_build( cache, cmake_script, @@ -2700,6 +2732,8 @@ def enable_all(): if not FLAGS.no_container_build: # Commands to collect all the build artifacts needed for CI # testing. + if FLAGS.ci_split: + cmake_script = split_cmake_script("cmake_build_collect" ) cibase_build( cmake_script, script_repo_dir, From e656c889082872e2a3d4b450c5df5e12bd74d06b Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Tue, 19 Mar 2024 14:48:42 -0700 Subject: [PATCH 2/8] remove unused values --- build.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/build.py b/build.py index 5f3d9b53b2..20ad2c3219 100755 --- a/build.py +++ b/build.py @@ -1093,7 +1093,6 @@ def create_dockerfile_linux( if "tensorrtllm" in backends: df += """ # Remove TRT contents that are not needed in runtime -ENV TRT_ROOT=/usr/local/tensorrt RUN ARCH="$(uname -i)" \\ && rm -fr ${TRT_ROOT}/bin ${TRT_ROOT}/targets/${ARCH}-linux-gnu/bin ${TRT_ROOT}/data \\ && rm -fr ${TRT_ROOT}/doc ${TRT_ROOT}/onnx_graphsurgeon ${TRT_ROOT}/python \\ @@ -1256,9 +1255,7 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach if "vllm" in backends: # [DLIS-5606] Build Conda environment for vLLM backend # Remove Pip install once vLLM backend moves to Conda environment. - # TODO: remove condition on architecutre once the vLLM backend is supports arm64 - if platform.machine() == "x86_64": - df += """ + df += """ # vLLM needed for vLLM backend RUN pip3 install vllm=={} """.format( From 579665c97ed48c651b30517602066d77ba2ea3dd Mon Sep 17 00:00:00 2001 From: Misha Chornyi <99709299+mc-nv@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:05:54 -0700 Subject: [PATCH 3/8] Update build.py Co-authored-by: Ryan McCormick --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index 20ad2c3219..634ec54607 100755 --- a/build.py +++ b/build.py @@ -2351,7 +2351,7 @@ def split_cmake_script(script_name): "--ci-split", action="store_true", required=False, - help="Requires to split CI build into multiple builds. Will generate cmake build script separatelly for each backend", + help="Split the intermediate build artifacts into independently build-able targets", ) parser.add_argument( "--cache-from-map", From ffe4c1eec07372431b9ea3c6e0a9cfcddf400d39 Mon Sep 17 00:00:00 2001 From: Misha Chornyi <99709299+mc-nv@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:06:01 -0700 Subject: [PATCH 4/8] Update build.py Co-authored-by: Ryan McCormick --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index 634ec54607..4aee32d2ee 100755 --- a/build.py +++ b/build.py @@ -2357,7 +2357,7 @@ def split_cmake_script(script_name): "--cache-from-map", action="append", required=False, - help="Requires to split CI build into multiple builds. Will generate cmake build script separatelly for each backend", + help="A set of docker images to `--cache-from` where applicable to help speedup builds", default = [ "tritonserver_buildbase", "tritonserver_buildbase_cache0", "tritonserver_buildbase_cache1", ], ) From 2bacc08987840a852cefa65653a9d18a9c7e4920 Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Fri, 5 Apr 2024 21:19:05 -0700 Subject: [PATCH 5/8] Fix pre-commit issue --- build.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index 4aee32d2ee..94d9d3b296 100755 --- a/build.py +++ b/build.py @@ -1569,7 +1569,7 @@ def create_docker_build_script(script_name, container_install_dir, container_ci_ ], check_exitcode=True, ) - + if not FLAGS.ci_split: docker_script.cmd( [ @@ -2046,6 +2046,7 @@ def enable_all(): if ep not in FLAGS.endpoint: FLAGS.endpoint += [ep] + def split_cmake_script(script_name): if target_platform() == "windows": script_name += ".ps1" @@ -2358,7 +2359,11 @@ def split_cmake_script(script_name): action="append", required=False, help="A set of docker images to `--cache-from` where applicable to help speedup builds", - default = [ "tritonserver_buildbase", "tritonserver_buildbase_cache0", "tritonserver_buildbase_cache1", ], + default=[ + "tritonserver_buildbase", + "tritonserver_buildbase_cache0", + "tritonserver_buildbase_cache1", + ], ) FLAGS = parser.parse_args() @@ -2730,7 +2735,7 @@ def split_cmake_script(script_name): # Commands to collect all the build artifacts needed for CI # testing. if FLAGS.ci_split: - cmake_script = split_cmake_script("cmake_build_collect" ) + cmake_script = split_cmake_script("cmake_build_collect") cibase_build( cmake_script, script_repo_dir, From 3bcf4d4c930608b00ca8e9e8a78cdc7149ef6304 Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Fri, 5 Apr 2024 21:24:36 -0700 Subject: [PATCH 6/8] Fix commit typo --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index 94d9d3b296..fa1d204771 100755 --- a/build.py +++ b/build.py @@ -2668,7 +2668,7 @@ def split_cmake_script(script_name): ) # Commands to build each backend... for be in backends: - # Define fucntion to create cmake_script with backend name as suffix + # Define function to create cmake_script with backend name as suffix if FLAGS.ci_split: cmake_script = split_cmake_script("cmake_build_backend_" + be) From 45f893c945bc0198d6926d2e84c72a6106804776 Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Mon, 8 Apr 2024 12:49:47 -0700 Subject: [PATCH 7/8] Change the name of the flag --- build.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build.py b/build.py index fa1d204771..20da7d2647 100755 --- a/build.py +++ b/build.py @@ -1570,7 +1570,7 @@ def create_docker_build_script(script_name, container_install_dir, container_ci_ check_exitcode=True, ) - if not FLAGS.ci_split: + if not FLAGS.split_build: docker_script.cmd( [ "docker", @@ -2349,7 +2349,7 @@ def split_cmake_script(script_name): help="Override specified backend CMake argument in the build as :=. The argument is passed to CMake as -D=. This flag only impacts CMake arguments that are used by build.py. To unconditionally add a CMake argument to the backend build use --extra-backend-cmake-arg.", ) parser.add_argument( - "--ci-split", + "--split-build", action="store_true", required=False, help="Split the intermediate build artifacts into independently build-able targets", @@ -2669,7 +2669,7 @@ def split_cmake_script(script_name): # Commands to build each backend... for be in backends: # Define function to create cmake_script with backend name as suffix - if FLAGS.ci_split: + if FLAGS.split_build: cmake_script = split_cmake_script("cmake_build_backend_" + be) # Core backends are not built separately from core so skip... @@ -2706,7 +2706,7 @@ def split_cmake_script(script_name): # Commands to build each repo agent... for ra in repoagents: - if FLAGS.ci_split: + if FLAGS.split_build: cmake_script = split_cmake_script("cmake_build_agent_" + ra) repo_agent_build( ra, @@ -2719,7 +2719,7 @@ def split_cmake_script(script_name): # Commands to build each cache... for cache in caches: - if FLAGS.ci_split: + if FLAGS.split_build: cmake_script = split_cmake_script("cmake_build_cache_" + cache) cache_build( cache, @@ -2734,7 +2734,7 @@ def split_cmake_script(script_name): if not FLAGS.no_container_build: # Commands to collect all the build artifacts needed for CI # testing. - if FLAGS.ci_split: + if FLAGS.split_build: cmake_script = split_cmake_script("cmake_build_collect") cibase_build( cmake_script, From 4d2f458e19901bf9546655bc6ff7028829655b4b Mon Sep 17 00:00:00 2001 From: Misha Chornyi <99709299+mc-nv@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:15:19 -0700 Subject: [PATCH 8/8] Update build.py Co-authored-by: Kyle McGill <101670481+nv-kmcgill53@users.noreply.github.com> --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index 20da7d2647..f11d7cfb85 100755 --- a/build.py +++ b/build.py @@ -2352,7 +2352,7 @@ def split_cmake_script(script_name): "--split-build", action="store_true", required=False, - help="Split the intermediate build artifacts into independently build-able targets", + help="Split the intermediate build artifacts into independent build-able targets", ) parser.add_argument( "--cache-from-map",