diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2046ed100..585a0aff2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,6 +136,35 @@ jobs: tensorrt.tags=${{ steps.setup.outputs.image-name }}-tensorrt-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 + 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: runs-on: ubuntu-22.04 name: AMD64 Extra Build diff --git a/docker/tensorrt/Dockerfile.arm64 b/docker/tensorrt/Dockerfile.arm64 index 2a71e0882..fe4ad6d09 100644 --- a/docker/tensorrt/Dockerfile.arm64 +++ b/docker/tensorrt/Dockerfile.arm64 @@ -61,6 +61,12 @@ RUN apt-get update \ RUN rm -rf /usr/lib/btbn-ffmpeg/ 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 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 \ diff --git a/docker/tensorrt/Dockerfile.base b/docker/tensorrt/Dockerfile.base index 9db087e21..5e136409a 100644 --- a/docker/tensorrt/Dockerfile.base +++ b/docker/tensorrt/Dockerfile.base @@ -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 \ && rm -rf /var/lib/apt/lists/* 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 # Frigate w/ TensorRT Support as separate image diff --git a/docker/tensorrt/detector/0001-fix-for-tensorrt-v10.3.0.patch b/docker/tensorrt/detector/0001-fix-for-tensorrt-v10.3.0.patch new file mode 100644 index 000000000..d6965431b --- /dev/null +++ b/docker/tensorrt/detector/0001-fix-for-tensorrt-v10.3.0.patch @@ -0,0 +1,40 @@ +From 21eb9bbcd35fd9eed8b5365ed7b43853486fd8a0 Mon Sep 17 00:00:00 2001 +From: Lander Noterman +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 diff --git a/docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/run b/docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/run index a88da89d6..bc014cdf5 100755 --- a/docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/run +++ b/docker/tensorrt/detector/rootfs/etc/s6-overlay/s6-rc.d/trt-model-prepare/run @@ -62,15 +62,14 @@ fi # 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 # 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 [[ ! -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" exit 1 - elif [[ ! -e /usr/lib/aarch64-linux-gnu/libnvinfer.so.8 || - ! -e /usr/lib/aarch64-linux-gnu/libnvinfer_plugin.so.8 || - ! -e /usr/lib/aarch64-linux-gnu/libnvparsers.so.8 || - ! -e /usr/lib/aarch64-linux-gnu/libnvonnxparser.so.8 ]]; then + elif [[ ! -e /usr/lib/aarch64-linux-gnu/libnvinfer.so || + ! -e /usr/lib/aarch64-linux-gnu/libnvinfer_plugin.so || + ! -e /usr/lib/aarch64-linux-gnu/libnvonnxparser.so ]]; then echo "ERROR: Please run the following on the HOST:" echo " sudo apt install libnvinfer8 libnvinfer-plugin8 libnvparsers8 libnvonnxparsers8 nvidia-container" exit 1 diff --git a/docker/tensorrt/detector/tensorrt_libyolo.sh b/docker/tensorrt/detector/tensorrt_libyolo.sh index 96a3cc48a..0c2a3c950 100755 --- a/docker/tensorrt/detector/tensorrt_libyolo.sh +++ b/docker/tensorrt/detector/tensorrt_libyolo.sh @@ -7,8 +7,9 @@ SCRIPT_DIR="/usr/local/src/tensorrt_demos" # Clone tensorrt_demos repo git clone --depth 1 https://github.com/NateMeyer/tensorrt_demos.git -b conditional_download -# remove -lnvparsers -sed -i 's/-lnvparsers//g' ./tensorrt_demos/plugins/Makefile +# Should probably upstream this patch or fork the repo +# 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 if [ ! -e /usr/local/cuda ]; then diff --git a/docker/tensorrt/trt.mk b/docker/tensorrt/trt.mk index 5e4e98cf6..ef7036228 100644 --- a/docker/tensorrt/trt.mk +++ b/docker/tensorrt/trt.mk @@ -35,6 +35,8 @@ build-trt: --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp4 $(JETPACK5_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \ --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 $(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 \ --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp5 \ --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