Repository navigation
ci: Ship trtexec in the QA image when built on an inference-runtime base - #9014
devin-ai-integration[bot] wants to merge 6 commits into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
| # The CUDA inference-runtime base ships the TensorRT runtime libraries but not | ||
| # trtexec or the builder resource libraries. | ||
| COPY --from=cibase /opt/trtexec/ /opt/trtexec/ | ||
| RUN if [ -e /opt/trtexec/trtexec ]; then \ | ||
| if [ ! -e /usr/src/tensorrt/bin/trtexec ]; then \ | ||
| mkdir -p /usr/src/tensorrt/bin && \ | ||
| mv /opt/trtexec/trtexec /usr/src/tensorrt/bin/trtexec; \ | ||
| fi && \ | ||
| rm -f /opt/trtexec/trtexec && \ | ||
| cp -an /opt/trtexec/. / && \ | ||
| ldconfig && \ | ||
| ! ldd /usr/src/tensorrt/bin/trtexec | grep 'not found'; \ | ||
| fi && \ | ||
| rm -rf /opt/trtexec |
There was a problem hiding this comment.
| # The CUDA inference-runtime base ships the TensorRT runtime libraries but not | |
| # trtexec or the builder resource libraries. | |
| COPY --from=cibase /opt/trtexec/ /opt/trtexec/ | |
| RUN if [ -e /opt/trtexec/trtexec ]; then \ | |
| if [ ! -e /usr/src/tensorrt/bin/trtexec ]; then \ | |
| mkdir -p /usr/src/tensorrt/bin && \ | |
| mv /opt/trtexec/trtexec /usr/src/tensorrt/bin/trtexec; \ | |
| fi && \ | |
| rm -f /opt/trtexec/trtexec && \ | |
| cp -an /opt/trtexec/. / && \ | |
| ldconfig && \ | |
| ! ldd /usr/src/tensorrt/bin/trtexec | grep 'not found'; \ | |
| fi && \ | |
| rm -rf /opt/trtexec | |
| # The CUDA inference-runtime base ships the TensorRT runtime libraries but not | |
| # trtexec or the builder resource libraries. | |
| COPY --from=cibase /usr/bin/trtexec /usr/bin/trtexec | |
There was a problem hiding this comment.
0f4e58b switches to a direct COPY --from=cibase /usr/bin/trtexec /usr/bin/trtexec. I couldn't take the suggestion as-is, because on its own it brings back two failures:
- The QA tests (
L0_device_memory_tracker,L0_memory_growth,L0_perf_resnet,L0_perf_deeprecommender) call/usr/src/tensorrt/bin/trtexec, which isn't present in inference-runtime. That was the originalNo such file or directory. TheRUNnow recreates the devel image's symlink to/usr/bin/trtexec. - trtexec dlopens
libnvinfer_builder_resource_sm*.so.<ver>, which inference-runtime also omits. With only the binary, pipeline 73321996 failed withUnable to load library: libnvinfer_builder_resource_sm80.so.11.4.0.lddcan't detect this because the library is loaded at runtime with dlopen.
So the final stage is now:
COPY --from=cibase /usr/bin/trtexec /usr/bin/trtexec
COPY --from=cibase /usr/lib/*-linux-gnu/libnvinfer_builder_resource*.so.*.*.* /usr/local/tensorrt/builder_resource/
RUN mkdir -p /usr/src/tensorrt/bin && \
ln -sf /usr/bin/trtexec /usr/src/tensorrt/bin/trtexec && \
echo /usr/local/tensorrt/builder_resource > /etc/ld.so.conf.d/tensorrt-builder-resource.conf && \
ldconfig && \
! ldd /usr/bin/trtexec | grep 'not found'The builder resources go into a fixed directory registered with ldconfig, because COPY can't compute the arch-specific /usr/lib/<triplet> destination. The .so.*.*.* glob copies only the real versioned files, not the symlinks to them, so their contents aren't duplicated. A scoped DMT re-validation is running; I'll post the pipeline here when it finishes.
There was a problem hiding this comment.
Update: 0f4e58b failed in pipeline 73373859. The image built, and trtexec ran from /usr/src/tensorrt/bin, but it still couldn't find the builder resources: Unable to load library: libnvinfer_builder_resource_sm80.so.11.4.0 (job 483674704). Putting them in a separate directory and registering that with ldconfig doesn't work. TensorRT appears to load them only from libnvinfer's own directory, which is where the earlier passing revision (pipeline 73338571) put them.
960aa53 keeps the direct COPY --from=cibase /usr/bin/trtexec, but stages the builder resources in /tmp and moves them into /usr/lib/{x86_64,aarch64}-linux-gnu based on TARGETPLATFORM. Re-validating in pipeline 73388065 (L0 DMT only).
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
| COPY --from=cibase /usr/bin/trtexec /usr/bin/trtexec | ||
| COPY --from=cibase /usr/lib/*-linux-gnu/libnvinfer_builder_resource*.so.*.*.* /usr/local/tensorrt/builder_resource/ |
There was a problem hiding this comment.
When GPU support is disabled, build.py bases tritonserver_cibase on ubuntu:24.04, which has neither /usr/bin/trtexec nor the builder resource libraries. These unconditional COPY steps now fail instead of skipping the optional files as the previous version did. Restore conditional staging so builds without TensorRT can still produce the QA image.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
|
||
| # The CUDA inference-runtime base ships the TensorRT runtime libraries but not | ||
| # trtexec or the builder resource libraries it dlopens to build engines. The | ||
| # builder resources must sit next to libnvinfer. QA tests call trtexec through | ||
| # the devel image's /usr/src/tensorrt/bin symlink. | ||
| COPY --from=cibase /usr/bin/trtexec /usr/bin/trtexec | ||
| COPY --from=cibase /usr/lib/*-linux-gnu/libnvinfer_builder_resource*.so.*.*.* /tmp/trt_builder_resource/ | ||
| RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ | ||
| TRT_LIB_DIR=/usr/lib/aarch64-linux-gnu; \ | ||
| else \ | ||
| TRT_LIB_DIR=/usr/lib/x86_64-linux-gnu; \ | ||
| fi && \ | ||
| mv /tmp/trt_builder_resource/* ${TRT_LIB_DIR}/ && \ | ||
| rm -rf /tmp/trt_builder_resource && \ | ||
| ls ${TRT_LIB_DIR}/libnvinfer.so.* > /dev/null && \ | ||
| mkdir -p /usr/src/tensorrt/bin && \ | ||
| ln -sf /usr/bin/trtexec /usr/src/tensorrt/bin/trtexec && \ | ||
| ldconfig && \ | ||
| ! ldd /usr/bin/trtexec | grep 'not found' | ||
|
|
There was a problem hiding this comment.
I really think that we need to go with small changes.
Devin overcomplicating the solution IMO.
| # The CUDA inference-runtime base ships the TensorRT runtime libraries but not | |
| # trtexec or the builder resource libraries it dlopens to build engines. The | |
| # builder resources must sit next to libnvinfer. QA tests call trtexec through | |
| # the devel image's /usr/src/tensorrt/bin symlink. | |
| COPY --from=cibase /usr/bin/trtexec /usr/bin/trtexec | |
| COPY --from=cibase /usr/lib/*-linux-gnu/libnvinfer_builder_resource*.so.*.*.* /tmp/trt_builder_resource/ | |
| RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ | |
| TRT_LIB_DIR=/usr/lib/aarch64-linux-gnu; \ | |
| else \ | |
| TRT_LIB_DIR=/usr/lib/x86_64-linux-gnu; \ | |
| fi && \ | |
| mv /tmp/trt_builder_resource/* ${TRT_LIB_DIR}/ && \ | |
| rm -rf /tmp/trt_builder_resource && \ | |
| ls ${TRT_LIB_DIR}/libnvinfer.so.* > /dev/null && \ | |
| mkdir -p /usr/src/tensorrt/bin && \ | |
| ln -sf /usr/bin/trtexec /usr/src/tensorrt/bin/trtexec && \ | |
| ldconfig && \ | |
| ! ldd /usr/bin/trtexec | grep 'not found' | |
| # The CUDA inference-runtime base ships the TensorRT runtime libraries but not | |
| # trtexec or the builder resource libraries it dlopens to build engines. | |
| COPY --from=cibase /usr/bin/trtexec /usr/bin/trtexec |
There was a problem hiding this comment.
Agreed it should be smaller. d267df1 trims it to two COPYs and a three-command RUN. The TARGETPLATFORM branch, the /tmp checks and the ldd check are gone. The mv uses /usr/lib/*-linux-gnu/, so it works on both x86 and sbsa.
The single COPY line on its own isn't enough, though. CI has already shown that:
- Binary only (rev 1, pipeline 73321996, job 483227906): trtexec runs but can't create a builder:
Unable to load library: libnvinfer_builder_resource_sm80.so.11.4.0. Those libraries aren't in inference-runtime. - Builder resources outside libnvinfer's directory (rev 3, pipeline 73373859, job 483674704): same error, even with an
ld.so.conf.dentry. They have to be next to libnvinfer, which is why themvis needed (a COPY destination can't take the arch-specific directory). - The tests call
/usr/src/tensorrt/bin/trtexec(L0_device_memory_tracker, L0_memory_growth, L0_perf_*). Without the symlink they fail with the originalNo such file or directory. The alternative would be changing those test.sh files to call/usr/bin/trtexecdirectly. Let me know if you'd prefer that.
d267df1 is being validated in pipeline 73388065 (L0 DMT only).
There was a problem hiding this comment.
there is a broken link that should recover after the above change
$ docker run --rm -it gitlab-master.nvidia.com:5005/dl/dgx/cuda:13.4-inference-runtime-ubuntu24.04--26.10 ls
lrwxrwxrwx 1 root root 16 Oct 9 07:53 /usr/src/tensorrt/bin/trtexec -> /usr/bin/trtexecThere was a problem hiding this comment.
Thanks, that makes things simpler. Since the base image already has the symlink, copying /usr/bin/trtexec back fixes the path, and my mkdir/ln -s step was redundant. It would also have broken the build, because ln -s without -f can't replace an existing link. 0a03881 drops it. What remains is the trtexec COPY plus the builder-resource COPY and a one-line mv that puts the builder resources next to libnvinfer:
COPY --from=cibase /usr/bin/trtexec /usr/bin/trtexec
COPY --from=cibase /usr/lib/*-linux-gnu/libnvinfer_builder_resource*.so.*.*.* /tmp/trt_builder_resource/
RUN mv /tmp/trt_builder_resource/* /usr/lib/*-linux-gnu/The devel builds in pipeline 73388065 hadn't started when I pushed, so that pipeline validates 0a03881 (L0 DMT only).
There was a problem hiding this comment.
0a03881 passed: all 11 jobs in pipeline 73388065 succeeded, including L0_device_memory_tracker--base (job 483799087). The py3-devel log shows the two COPYs and the single mv, and trtexec built all three engines (vgg19, resnet50, resnet152). That covers the QA-image approach on A100; the DGX-Spark variants haven't run yet. Whether to keep this or move to model generation is your call (see the top-level thread).
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Honestly I don't really like this approach we coming out with. |
|
@mc-nv Fair point. Model generation looks like a better place for this than the QA image:
Building the model inside the job instead would still need trtexec or the TRT builder at test time, so it brings back the same dependency in the job. I'm holding the Dockerfile change while Rini weighs in. If you agree, I'll rework this PR into the model-gen version. |
What does the PR do?
Restores a working
/usr/src/tensorrt/bin/trtexecin the QA/devel image.L0_device_memory_tracker,L0_memory_growth,L0_perf_resnetandL0_perf_deeprecommenderuse it.cibasestage, the real binary is staged withcp -L /usr/src/tensorrt/bin/trtexec, along with thelibnvinfer_builder_resource*.so*libraries that trtexec dlopens to build engines./usr/src/tensorrt/bin/trtexecif the runtime base lacks it. The builder resource libraries are copied in no-clobber (cp -an), thenldconfigruns. The build fails iflddreports any missing library.Checklist
<commit_type>: <Title>Commit Type:
Related PRs:
Supersedes #9005.
Where should the reviewer start?
Dockerfile.QA: the newRUNat the end of thecibasestage, and theCOPY/RUNafter the go installs in the final stage.Test plan:
pre-commit passes locally.
Pipeline 73321996 (first commit only):
py3-develbuilt, and trtexec ran (TensorRT v110400).L0_device_memory_tracker--basethen failed withUnable to load library: libnvinfer_builder_resource_sm80.so.11.4.0. inference-runtime omits the builder resources andlddcan't see dlopen'd libraries, so the second commit stages those libraries too.Pipeline 73338571 (both commits): scoped
py3-base/sdk/devel(x86 + sbsa) +L0_device_memory_tracker--base. All 11 jobs passed.CI Pipeline ID: 73338571
Caveats:
cibasemust carry the same TensorRT version. Today both come from the same CUDA release tag.L0_memory_growth,L0_perf_*) weren't run in the scoped pipeline.Background
$BASE_IMAGEruntime layer was the CUDA devel image (--image=base). That image installs TensorRT withDEVEL=1:libnvinfer-bin(/usr/bin/trtexec, plus the/usr/src/tensorrt/bin/trtexecsymlink) and the full builder libraries.libnvinfer-binand no builder resources.COPY --from=cibase /usr/src/tensorrtbrought over only the symlink, which dangles without/usr/bin/trtexec.test -xthen failed.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Link to Devin session: https://nvidia-cloud.devinenterprise.com/sessions/80a180b0212949f9be74e5230ea9e554
Open in Devin Desktop: https://nvidia-cloud.devinenterprise.com/desktop/session/80a180b0212949f9be74e5230ea9e554?variant=devin