Skip to content

Commit bca98c2

Browse files
author
deadeyegoodwin
authored
Fix build when --upstream-container-version not specified (#2175)
1 parent a6d95fd commit bca98c2

File tree

1 file changed

+49
-17
lines changed

1 file changed

+49
-17
lines changed

build.py

+49-17
Original file line numberDiff line numberDiff line change
@@ -701,19 +701,6 @@ def create_dockerfile(ddir, dockerfile_name, argmap):
701701

702702

703703
def container_build(images):
704-
# Set the docker build-args based on container version
705-
if FLAGS.container_version in CONTAINER_VERSION_MAP:
706-
if FLAGS.upstream_container_version is not None:
707-
upstream_container_version = FLAGS.upstream_container_version
708-
else:
709-
upstream_container_version = CONTAINER_VERSION_MAP[
710-
FLAGS.container_version][0]
711-
onnx_runtime_version = CONTAINER_VERSION_MAP[FLAGS.container_version][1]
712-
onnx_runtime_openvino_version = CONTAINER_VERSION_MAP[
713-
FLAGS.container_version][2]
714-
else:
715-
fail('unsupported container version {}'.format(FLAGS.container_version))
716-
717704
# The build and install directories within the container.
718705
build_dir = os.path.join(os.sep, 'tmp', 'tritonbuild')
719706
install_dir = os.path.join(os.sep, 'tmp', 'tritonbuild', 'install')
@@ -726,21 +713,21 @@ def container_build(images):
726713
base_image = images['base']
727714
else:
728715
base_image = 'nvcr.io/nvidia/tritonserver:{}-py3'.format(
729-
upstream_container_version)
716+
FLAGS.upstream_container_version)
730717

731718
if 'pytorch' in images:
732719
pytorch_image = images['pytorch']
733720
else:
734721
pytorch_image = 'nvcr.io/nvidia/pytorch:{}-py3'.format(
735-
upstream_container_version)
722+
FLAGS.upstream_container_version)
736723

737724
dockerfileargmap = {
738725
'TRITON_VERSION': FLAGS.version,
739726
'TRITON_CONTAINER_VERSION': FLAGS.container_version,
740727
'BASE_IMAGE': base_image,
741728
'PYTORCH_IMAGE': pytorch_image,
742-
'ONNX_RUNTIME_VERSION': onnx_runtime_version,
743-
'ONNX_RUNTIME_OPENVINO_VERSION': onnx_runtime_openvino_version
729+
'ONNX_RUNTIME_VERSION': FLAGS.onnx_runtime_version,
730+
'ONNX_RUNTIME_OPENVINO_VERSION': FLAGS.onnx_runtime_openvino_version
744731
}
745732

746733
cachefrommap = [
@@ -804,6 +791,10 @@ def container_build(images):
804791
# --container-version is removed so that a direct build is
805792
# performed within the container
806793
#
794+
# Add --upstream-container-version, --onnx-runtime-version and
795+
# --onnx-runtime-openvino-version if necessary since these
796+
# FLAGS can be set manually and so may not be in sys.argv
797+
#
807798
# --build-dir is added/overridden to 'build_dir'
808799
#
809800
# --install-dir is added/overridden to 'install_dir'
@@ -822,6 +813,18 @@ def container_build(images):
822813
continue
823814
runargs.append(a)
824815

816+
if FLAGS.upstream_container_version is not None:
817+
runargs += [
818+
'--upstream-container-version', FLAGS.upstream_container_version
819+
]
820+
if FLAGS.onnx_runtime_version is not None:
821+
runargs += ['--onnx-runtime-version', FLAGS.onnx_runtime_version]
822+
if FLAGS.onnx_runtime_openvino_version is not None:
823+
runargs += [
824+
'--onnx-runtime-openvino-version',
825+
FLAGS.onnx_runtime_openvino_version
826+
]
827+
825828
runargs += ['--build-dir', build_dir]
826829
runargs += ['--install-dir', install_dir]
827830

@@ -971,6 +974,20 @@ def container_build(images):
971974
help=
972975
'The upstream container version to use when performing a container build. If not specified the upstream container version will be chosen automaticallly based on --container-version.'
973976
)
977+
parser.add_argument(
978+
'--onnx-runtime-version',
979+
type=str,
980+
required=False,
981+
help=
982+
'The ONNX Runtime version to use. If not specified the upstream container version will be chosen automaticallly based on --container-version.'
983+
)
984+
parser.add_argument(
985+
'--onnx-runtime-openvino-version',
986+
type=str,
987+
required=False,
988+
help=
989+
'The ONNX Runtime OpenVINO version to use. If not specified the upstream container version will be chosen automaticallly based on --container-version.'
990+
)
974991
parser.add_argument(
975992
'--container-prebuild-command',
976993
type=str,
@@ -1066,6 +1083,21 @@ def container_build(images):
10661083
if FLAGS.filesystem is None:
10671084
FLAGS.filesystem = []
10681085

1086+
if FLAGS.container_version is not None:
1087+
if FLAGS.container_version in CONTAINER_VERSION_MAP:
1088+
if FLAGS.upstream_container_version is None:
1089+
FLAGS.upstream_container_version = CONTAINER_VERSION_MAP[
1090+
FLAGS.container_version][0]
1091+
if FLAGS.onnx_runtime_version is None:
1092+
FLAGS.onnx_runtime_version = CONTAINER_VERSION_MAP[
1093+
FLAGS.container_version][1]
1094+
if FLAGS.onnx_runtime_openvino_version is None:
1095+
FLAGS.onnx_runtime_openvino_version = CONTAINER_VERSION_MAP[
1096+
FLAGS.container_version][2]
1097+
else:
1098+
fail('unsupported container version {}'.format(
1099+
FLAGS.container_version))
1100+
10691101
# Initialize map of docker images.
10701102
images = {}
10711103
for img in FLAGS.image:

0 commit comments

Comments
 (0)