From 60b23150286a54ab0ec14d0d8abf98c4680f919b Mon Sep 17 00:00:00 2001 From: Nate Meyer Date: Sat, 14 Jan 2023 14:14:27 -0500 Subject: [PATCH] Update library loading for tensorrt (#5087) * Update library loading for tensorrt * Add symlink to libnvrtc --- Dockerfile | 4 +++- docker/rootfs/etc/ld.so.conf.d/cuda_tensorrt.conf | 5 +++++ frigate/detectors/plugins/tensorrt.py | 6 ------ requirements-tensorrt.txt | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 docker/rootfs/etc/ld.so.conf.d/cuda_tensorrt.conf diff --git a/Dockerfile b/Dockerfile index d03576919..18f528cc6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -269,7 +269,9 @@ COPY --from=rootfs / / # Frigate w/ TensorRT Support as separate image FROM frigate AS frigate-tensorrt RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \ - pip3 install -U /deps/trt-wheels/*.whl + pip3 install -U /deps/trt-wheels/*.whl && \ + ln -s libnvrtc.so.11.2 /usr/local/lib/python3.9/dist-packages/nvidia/cuda_nvrtc/lib/libnvrtc.so && \ + ldconfig # Dev Container w/ TRT FROM devcontainer AS devcontainer-trt diff --git a/docker/rootfs/etc/ld.so.conf.d/cuda_tensorrt.conf b/docker/rootfs/etc/ld.so.conf.d/cuda_tensorrt.conf new file mode 100644 index 000000000..d4248d047 --- /dev/null +++ b/docker/rootfs/etc/ld.so.conf.d/cuda_tensorrt.conf @@ -0,0 +1,5 @@ +/usr/local/lib/python3.9/dist-packages/nvidia/cudnn/lib +/usr/local/lib/python3.9/dist-packages/nvidia/cuda_runtime/lib +/usr/local/lib/python3.9/dist-packages/nvidia/cublas/lib +/usr/local/lib/python3.9/dist-packages/nvidia/cuda_nvrtc/lib +/usr/local/lib/python3.9/dist-packages/tensorrt \ No newline at end of file diff --git a/frigate/detectors/plugins/tensorrt.py b/frigate/detectors/plugins/tensorrt.py index 71ce9b048..2d2a6788f 100644 --- a/frigate/detectors/plugins/tensorrt.py +++ b/frigate/detectors/plugins/tensorrt.py @@ -75,12 +75,6 @@ class TensorRtDetector(DetectionApi): def _load_engine(self, model_path): try: - ctypes.cdll.LoadLibrary( - "/usr/local/lib/python3.9/dist-packages/nvidia/cuda_runtime/lib/libcudart.so.11.0" - ) - ctypes.cdll.LoadLibrary( - "/usr/local/lib/python3.9/dist-packages/tensorrt/libnvinfer.so.8" - ) trt.init_libnvinfer_plugins(self.trt_logger, "") ctypes.cdll.LoadLibrary("/trt-models/libyolo_layer.so") diff --git a/requirements-tensorrt.txt b/requirements-tensorrt.txt index 1a53892c0..90517babd 100644 --- a/requirements-tensorrt.txt +++ b/requirements-tensorrt.txt @@ -5,4 +5,5 @@ cuda-python == 11.7; platform_machine == 'x86_64' cython == 0.29.*; platform_machine == 'x86_64' nvidia-cuda-runtime-cu11 == 11.7.*; platform_machine == 'x86_64' nvidia-cublas-cu11 == 11.11.*; platform_machine == 'x86_64' -nvidia-cudnn-cu11 == 8.7.*; platform_machine == 'x86_64' \ No newline at end of file +nvidia-cudnn-cu11 == 8.7.*; platform_machine == 'x86_64' +nvidia-cuda-nvrtc-cu11 == 11.7.*; platform_machine == 'x86_64' \ No newline at end of file