some fixes

This commit is contained in:
Lander Noterman 2025-02-13 14:18:52 +01:00
parent 200d08871b
commit 2a05429a6d
7 changed files with 89 additions and 8 deletions

View File

@ -136,6 +136,35 @@ jobs:
tensorrt.tags=${{ steps.setup.outputs.image-name }}-tensorrt-jp5 tensorrt.tags=${{ steps.setup.outputs.image-name }}-tensorrt-jp5
*.cache-from=type=registry,ref=${{ steps.setup.outputs.cache-name }}-jp5 *.cache-from=type=registry,ref=${{ steps.setup.outputs.cache-name }}-jp5
*.cache-to=type=registry,ref=${{ steps.setup.outputs.cache-name }}-jp5,mode=max *.cache-to=type=registry,ref=${{ steps.setup.outputs.cache-name }}-jp5,mode=max
jetson_jp6_build:
runs-on: ubuntu-22.04
name: Jetson Jetpack 6
steps:
- name: Check out code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up QEMU and Buildx
id: setup
uses: ./.github/actions/setup
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push TensorRT (Jetson, Jetpack 6)
env:
ARCH: arm64
BASE_IMAGE: nvcr.io/nvidia/tensorrt:24.08-py3-igpu
SLIM_BASE: nvcr.io/nvidia/tensorrt:24.08-py3-igpu
TRT_BASE: nvcr.io/nvidia/tensorrt:24.08-py3-igpu
uses: docker/bake-action@v6
with:
source: .
push: true
targets: tensorrt
files: docker/tensorrt/trt.hcl
set: |
tensorrt.tags=${{ steps.setup.outputs.image-name }}-tensorrt-jp6
*.cache-from=type=registry,ref=${{ steps.setup.outputs.cache-name }}-jp6
*.cache-to=type=registry,ref=${{ steps.setup.outputs.cache-name }}-jp6,mode=max
amd64_extra_builds: amd64_extra_builds:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
name: AMD64 Extra Build name: AMD64 Extra Build

View File

@ -61,6 +61,12 @@ RUN apt-get update \
RUN rm -rf /usr/lib/btbn-ffmpeg/ RUN rm -rf /usr/lib/btbn-ffmpeg/
COPY --from=jetson-ffmpeg /rootfs / COPY --from=jetson-ffmpeg /rootfs /
# ffmpeg runtime dependencies
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends \
libx264-163 libx265-199 libegl1 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=trt-wheels /etc/TENSORRT_VER /etc/TENSORRT_VER COPY --from=trt-wheels /etc/TENSORRT_VER /etc/TENSORRT_VER
RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \ RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \
--mount=type=bind,from=trt-model-wheels,source=/trt-model-wheels,target=/deps/trt-model-wheels \ --mount=type=bind,from=trt-model-wheels,source=/trt-model-wheels,target=/deps/trt-model-wheels \

View File

@ -14,6 +14,7 @@ RUN apt-get update \
&& apt-get install -y git build-essential cuda-nvcc-* cuda-nvtx-* libnvinfer-dev libnvinfer-plugin-dev libnvonnxparsers-dev \ && apt-get install -y git build-essential cuda-nvcc-* cuda-nvtx-* libnvinfer-dev libnvinfer-plugin-dev libnvonnxparsers-dev \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
RUN --mount=type=bind,source=docker/tensorrt/detector/tensorrt_libyolo.sh,target=/tensorrt_libyolo.sh \ RUN --mount=type=bind,source=docker/tensorrt/detector/tensorrt_libyolo.sh,target=/tensorrt_libyolo.sh \
--mount=type=bind,source=docker/tensorrt/detector/0001-fix-for-tensorrt-v10.3.0.patch,target=/0001-fix-for-tensorrt-v10.3.0.patch \
/tensorrt_libyolo.sh /tensorrt_libyolo.sh
# Frigate w/ TensorRT Support as separate image # Frigate w/ TensorRT Support as separate image

View File

@ -0,0 +1,40 @@
From 21eb9bbcd35fd9eed8b5365ed7b43853486fd8a0 Mon Sep 17 00:00:00 2001
From: Lander Noterman <lander.noterman@basalte.be>
Date: Thu, 13 Feb 2025 13:52:19 +0100
Subject: [PATCH] fix for tensorrt v10.3.0
---
plugins/Makefile | 2 +-
yolo/onnx_to_tensorrt.py | 9 +++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/plugins/Makefile b/plugins/Makefile
index 51af1cd..d7cea4c 100644
--- a/plugins/Makefile
+++ b/plugins/Makefile
@@ -21,7 +21,7 @@ TENSORRT_LIBS=-L"/usr/local/TensorRT-7.1.3.4/lib"
# INCS and LIBS
INCS=-I"/usr/local/cuda/include" $(TENSORRT_INCS) -I"/usr/local/include" -I"plugin"
-LIBS=-L"/usr/local/cuda/lib64" $(TENSORRT_LIBS) -L"/usr/local/lib" -Wl,--start-group -lnvinfer -lnvparsers -lnvinfer_plugin -lcudnn -lcublas -lnvToolsExt -lcudart -lrt -ldl -lpthread -Wl,--end-group
+LIBS=-L"/usr/local/cuda/lib64" $(TENSORRT_LIBS) -L"/usr/local/lib" -Wl,--start-group -lnvinfer -lnvinfer_plugin -lcudnn -lcublas -lnvToolsExt -lcudart -lrt -ldl -lpthread -Wl,--end-group
.PHONY: all clean
diff --git a/yolo/onnx_to_tensorrt.py b/yolo/onnx_to_tensorrt.py
index 77862db..06d0759 100644
--- a/yolo/onnx_to_tensorrt.py
+++ b/yolo/onnx_to_tensorrt.py
@@ -194,7 +193,9 @@ def build_engine(model_name, do_int8, dla_core, verbose=False):
if dla_core >= 0:
config.default_device_type = trt.DeviceType.DLA
config.DLA_core = dla_core
- config.set_flag(trt.BuilderFlag.STRICT_TYPES)
+ config.set_flag(trt.BuilderFlag.PREFER_PRECISION_CONSTRAINTS)
+ config.set_flag(trt.BuilderFlag.DIRECT_IO)
+ config.set_flag(trt.BuilderFlag.REJECT_EMPTY_ALGORITHMS)
print('Using DLA core %d.' % dla_core)
engine = builder.build_serialized_network(network, config)
--
2.48.1

View File

@ -62,15 +62,14 @@ fi
# container which should not be present in the image - if they are, TRT model generation will # container which should not be present in the image - if they are, TRT model generation will
# fail or produce invalid models. Thus we must request the user to install them on the host in # fail or produce invalid models. Thus we must request the user to install them on the host in
# order to run libyolo here. # order to run libyolo here.
# On Jetpack 5.0, these libraries are not mounted by the runtime and are supplied by the image. # On Jetpack 5.0+, these libraries are not mounted by the runtime and are supplied by the image.
if [[ "$(arch)" == "aarch64" ]]; then if [[ "$(arch)" == "aarch64" ]]; then
if [[ ! -e /usr/lib/aarch64-linux-gnu/tegra ]]; then if [[ ! -e /usr/lib/aarch64-linux-gnu/tegra && ! -e /usr/lib/aarch64-linux-gnu/tegra-egl ]]; then
echo "ERROR: Container must be launched with nvidia runtime" echo "ERROR: Container must be launched with nvidia runtime"
exit 1 exit 1
elif [[ ! -e /usr/lib/aarch64-linux-gnu/libnvinfer.so.8 || elif [[ ! -e /usr/lib/aarch64-linux-gnu/libnvinfer.so ||
! -e /usr/lib/aarch64-linux-gnu/libnvinfer_plugin.so.8 || ! -e /usr/lib/aarch64-linux-gnu/libnvinfer_plugin.so ||
! -e /usr/lib/aarch64-linux-gnu/libnvparsers.so.8 || ! -e /usr/lib/aarch64-linux-gnu/libnvonnxparser.so ]]; then
! -e /usr/lib/aarch64-linux-gnu/libnvonnxparser.so.8 ]]; then
echo "ERROR: Please run the following on the HOST:" echo "ERROR: Please run the following on the HOST:"
echo " sudo apt install libnvinfer8 libnvinfer-plugin8 libnvparsers8 libnvonnxparsers8 nvidia-container" echo " sudo apt install libnvinfer8 libnvinfer-plugin8 libnvparsers8 libnvonnxparsers8 nvidia-container"
exit 1 exit 1

View File

@ -7,8 +7,9 @@ SCRIPT_DIR="/usr/local/src/tensorrt_demos"
# Clone tensorrt_demos repo # Clone tensorrt_demos repo
git clone --depth 1 https://github.com/NateMeyer/tensorrt_demos.git -b conditional_download git clone --depth 1 https://github.com/NateMeyer/tensorrt_demos.git -b conditional_download
# remove -lnvparsers # Should probably upstream this patch or fork the repo
sed -i 's/-lnvparsers//g' ./tensorrt_demos/plugins/Makefile # See: https://developer.nvidia.com/docs/drive/drive-os/6.0.8/public/drive-os-tensorrt/api-reference/docs/python/infer/Core/BuilderConfig.html#tensorrt.BuilderFlag
git apply --directory tensorrt_demos /0001-fix-for-tensorrt-v10.3.0.patch
# Build libyolo # Build libyolo
if [ ! -e /usr/local/cuda ]; then if [ ! -e /usr/local/cuda ]; then

View File

@ -35,6 +35,8 @@ build-trt:
--set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp4 --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp4
$(JETPACK5_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \ $(JETPACK5_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \
--set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp5 --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp5
$(JETPACK6_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \
--set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp6
push-trt: build-trt push-trt: build-trt
$(X86_DGPU_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \ $(X86_DGPU_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \
@ -46,3 +48,6 @@ push-trt: build-trt
$(JETPACK5_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \ $(JETPACK5_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \
--set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp5 \ --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp5 \
--push --push
$(JETPACK6_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \
--set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp6 \
--push