Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have ability to split the build in CI #7076

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
135 changes: 83 additions & 52 deletions build.py
Expand Up @@ -1253,6 +1253,8 @@ 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.
df += """
# vLLM needed for vLLM backend
RUN pip3 install vllm=={}
Expand Down Expand Up @@ -1480,11 +1482,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",
Expand Down Expand Up @@ -1557,7 +1555,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)
Expand All @@ -1571,57 +1569,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(
Expand Down Expand Up @@ -2046,6 +2046,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()
Expand Down Expand Up @@ -2338,6 +2347,19 @@ def enable_all():
required=False,
help="Override specified backend CMake argument in the build as <backend>:<name>=<value>. The argument is passed to CMake as -D<name>=<value>. 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",
mc-nv marked this conversation as resolved.
Show resolved Hide resolved
action="store_true",
required=False,
help="Requires to split CI build into multiple builds. Will generate cmake build script separatelly for each backend",
mc-nv marked this conversation as resolved.
Show resolved Hide resolved
)
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",
mc-nv marked this conversation as resolved.
Show resolved Hide resolved
default = [ "tritonserver_buildbase", "tritonserver_buildbase_cache0", "tritonserver_buildbase_cache1", ],
)

FLAGS = parser.parse_args()

Expand Down Expand Up @@ -2639,9 +2661,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
mc-nv marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down Expand Up @@ -2676,6 +2701,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,
Expand All @@ -2687,6 +2714,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,
Expand All @@ -2700,6 +2729,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,
Expand Down