Skip to content

Commit

Permalink
Simplify tensorrt (#16835)
Browse files Browse the repository at this point in the history
* Remove unneccessary trt wheels build

* Cleanup

* Try without local cuda

* Keep specific cuda libs only

* Cleanup

* Add newer libcufft

* remove target

* Include more
  • Loading branch information
NickM-27 authored Feb 26, 2025
1 parent d0e9bcb commit 4f855f8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
20 changes: 7 additions & 13 deletions docker/tensorrt/Dockerfile.amd64
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,16 @@
# https://askubuntu.com/questions/972516/debian-frontend-environment-variable
ARG DEBIAN_FRONTEND=noninteractive

# Make this a separate target so it can be built/cached optionally
FROM wheels as trt-wheels
ARG DEBIAN_FRONTEND
ARG TARGETARCH
RUN python3 -m pip config set global.break-system-packages true

# Add TensorRT wheels to another folder
COPY docker/tensorrt/requirements-amd64.txt /requirements-tensorrt.txt
RUN mkdir -p /trt-wheels && pip3 wheel --wheel-dir=/trt-wheels -r /requirements-tensorrt.txt
# Globally set pip break-system-packages option to avoid having to specify it every time
ARG PIP_BREAK_SYSTEM_PACKAGES=1

FROM tensorrt-base AS frigate-tensorrt
ARG PIP_BREAK_SYSTEM_PACKAGES
ENV TRT_VER=8.6.1
RUN python3 -m pip config set global.break-system-packages true
RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \
pip3 install -U /deps/trt-wheels/*.whl && \
ldconfig

# Install TensorRT wheels
COPY docker/tensorrt/requirements-amd64.txt /requirements-tensorrt.txt
RUN pip3 install -U -r /requirements-tensorrt.txt && ldconfig

WORKDIR /opt/frigate/
COPY --from=rootfs / /
Expand Down
7 changes: 6 additions & 1 deletion docker/tensorrt/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ FROM deps AS tensorrt-base
#Disable S6 Global timeout
ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0

# COPY TensorRT Model Generation Deps
COPY --from=trt-deps /usr/local/lib/libyolo_layer.so /usr/local/lib/libyolo_layer.so
COPY --from=trt-deps /usr/local/src/tensorrt_demos /usr/local/src/tensorrt_demos
COPY --from=trt-deps /usr/local/cuda-12.* /usr/local/cuda

# COPY Individual CUDA deps
COPY --from=trt-deps /usr/local/cuda-12.3/targets/x86_64-linux/lib/libcurand.so.* /usr/local/cuda/
COPY --from=trt-deps /usr/local/cuda-12.3/targets/x86_64-linux/lib/libnvrtc.so.* /usr/local/cuda/

COPY docker/tensorrt/detector/rootfs/ /
ENV YOLO_MODELS=""

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/usr/local/lib
/usr/local/cuda/lib64
/usr/local/cuda
/usr/local/lib/python3.11/dist-packages/nvidia/cudnn/lib
/usr/local/lib/python3.11/dist-packages/nvidia/cuda_runtime/lib
/usr/local/lib/python3.11/dist-packages/nvidia/cublas/lib
Expand Down
1 change: 1 addition & 0 deletions docker/tensorrt/requirements-amd64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ nvidia-cublas-cu11 == 11.11.3.6; platform_machine == 'x86_64'
nvidia-cudnn-cu11 == 8.6.0.*; platform_machine == 'x86_64'
nvidia-cudnn-cu12 == 9.5.0.*; platform_machine == 'x86_64'
nvidia-cufft-cu11==10.*; platform_machine == 'x86_64'
nvidia-cufft-cu12==11.*; platform_machine == 'x86_64'
onnx==1.16.*; platform_machine == 'x86_64'
onnxruntime-gpu==1.20.*; platform_machine == 'x86_64'
protobuf==3.20.3; platform_machine == 'x86_64'
1 change: 0 additions & 1 deletion docker/tensorrt/trt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ target "tensorrt" {
wget = "target:wget",
tensorrt-base = "target:tensorrt-base",
rootfs = "target:rootfs"
wheels = "target:wheels"
}
target = "frigate-tensorrt"
inherits = ["_build_args"]
Expand Down

0 comments on commit 4f855f8

Please sign in to comment.