Skip to content

Commit 270e9f8

Browse files
committed
build: Support installing tritonclient from an SDK image in build.py
Add an optional "sdk" value to --image so the generated inference Dockerfile copies and installs the tritonclient build carried by the specified SDK image. The behavior is opt-in and leaves images that do not pass --image=sdk unchanged.
1 parent 7eaa5a2 commit 270e9f8

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

build.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,19 @@ def create_dockerfile_linux(
11521152
argmap["GPU_BASE_IMAGE"]
11531153
)
11541154

1155+
# When an SDK image is provided, declare it as a stage so the production
1156+
# image can install the tritonclient build it carries.
1157+
if argmap["SDK_IMAGE"] is not None:
1158+
df += """
1159+
############################################################################
1160+
## SDK image
1161+
############################################################################
1162+
FROM {} AS sdk
1163+
1164+
""".format(
1165+
argmap["SDK_IMAGE"]
1166+
)
1167+
11551168
df += """
11561169
############################################################################
11571170
## Production stage: Create container with just inference server executable
@@ -1178,6 +1191,15 @@ def create_dockerfile_linux(
11781191
11791192
RUN pip3 install -r python/openai/requirements.txt
11801193
1194+
"""
1195+
# Install the tritonclient build carried by the SDK stage.
1196+
if argmap["SDK_IMAGE"] is not None:
1197+
df += """
1198+
COPY --from=sdk /workspace/install/python/ /tmp/tritonclient_pkgs/
1199+
RUN find /tmp/tritonclient_pkgs/ -maxdepth 1 -type f -name "tritonclient-*any*.whl" \\
1200+
-exec pip3 install --upgrade {}[all] \\; \\
1201+
&& rm -rf /tmp/tritonclient_pkgs/
1202+
11811203
"""
11821204
if not FLAGS.no_core_build:
11831205
# Add feature labels for SageMaker endpoint
@@ -1547,6 +1569,7 @@ def create_build_dockerfiles(
15471569
"TRITON_CONTAINER_VERSION": FLAGS.container_version,
15481570
"BASE_IMAGE": base_image,
15491571
"INFERENCE_IMAGE": inference_image,
1572+
"SDK_IMAGE": images["sdk"] if "sdk" in images else None,
15501573
"DCGM_VERSION": FLAGS.dcgm_version,
15511574
}
15521575

@@ -2334,7 +2357,7 @@ def enable_all():
23342357
"--image",
23352358
action="append",
23362359
required=False,
2337-
help='Use specified Docker image in build as <image-name>,<full-image-name>. <image-name> can be "base", "gpu-base", or "pytorch".',
2360+
help='Use specified Docker image in build as <image-name>,<full-image-name>. <image-name> can be "base", "gpu-base", "pytorch", or "sdk". When "sdk" is specified, the tritonclient build it carries is installed into the inference image.',
23382361
)
23392362

23402363
parser.add_argument(
@@ -2684,7 +2707,7 @@ def enable_all():
26842707
len(parts) != 2, "--image must specify <image-name>,<full-image-registry>"
26852708
)
26862709
fail_if(
2687-
parts[0] not in ["base", "gpu-base", "pytorch", "inference"],
2710+
parts[0] not in ["base", "gpu-base", "pytorch", "inference", "sdk"],
26882711
"unsupported value for --image",
26892712
)
26902713
log('image "{}": "{}"'.format(parts[0], parts[1]))

0 commit comments

Comments
 (0)