mirror of
				https://github.com/blakeblackshear/frigate.git
				synced 2025-10-27 10:52:11 +01:00 
			
		
		
		
	* Remove imutils * Ensure that state is maintained when setting search params * Change script for version of setuptools * Fix * Fix
		
			
				
	
	
		
			104 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
			
		
		
	
	
			104 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
| # syntax=docker/dockerfile:1.4
 | |
| 
 | |
| # https://askubuntu.com/questions/972516/debian-frontend-environment-variable
 | |
| ARG DEBIAN_FRONTEND=noninteractive
 | |
| 
 | |
| ARG BASE_IMAGE
 | |
| FROM ${BASE_IMAGE} AS build-wheels
 | |
| ARG DEBIAN_FRONTEND
 | |
| 
 | |
| # Add deadsnakes PPA for python3.11
 | |
| RUN apt-get -qq update && \
 | |
|     apt-get -qq install -y --no-install-recommends \
 | |
|     software-properties-common \
 | |
|     && add-apt-repository ppa:deadsnakes/ppa
 | |
| 
 | |
| # Use a separate container to build wheels to prevent build dependencies in final image
 | |
| RUN apt-get -qq update \
 | |
|     && apt-get -qq install -y --no-install-recommends \
 | |
|     python3.11 python3.11-dev \
 | |
|     wget build-essential cmake git \
 | |
|     && rm -rf /var/lib/apt/lists/*
 | |
| 
 | |
| # Ensure python3 defaults to python3.11
 | |
| RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
 | |
| 
 | |
| RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \
 | |
|     && sed -i 's/args.append("setuptools")/args.append("setuptools==77.0.3")/' get-pip.py \
 | |
|     && python3 get-pip.py "pip"
 | |
| 
 | |
| FROM build-wheels AS trt-wheels
 | |
| ARG DEBIAN_FRONTEND
 | |
| ARG TARGETARCH
 | |
| 
 | |
| # python-tensorrt build deps are 3.4 GB!
 | |
| RUN apt-get update \
 | |
|     && apt-get install -y ccache cuda-cudart-dev-* cuda-nvcc-* libnvonnxparsers-dev libnvparsers-dev libnvinfer-plugin-dev \
 | |
|     && ([ -e /usr/local/cuda ] || ln -s /usr/local/cuda-* /usr/local/cuda) \
 | |
|     && rm -rf /var/lib/apt/lists/*;
 | |
| 
 | |
| # Determine version of tensorrt already installed in base image, e.g. "Version: 8.4.1-1+cuda11.4"
 | |
| RUN NVINFER_VER=$(dpkg -s libnvinfer8 | grep -Po "Version: \K.*") \
 | |
|     && echo $NVINFER_VER | grep -Po "^\d+\.\d+\.\d+" > /etc/TENSORRT_VER
 | |
| 
 | |
| RUN --mount=type=bind,source=docker/tensorrt/detector/build_python_tensorrt.sh,target=/deps/build_python_tensorrt.sh \
 | |
|     --mount=type=cache,target=/root/.ccache \
 | |
|     export PATH="/usr/lib/ccache:$PATH" CCACHE_DIR=/root/.ccache CCACHE_MAXSIZE=2G \
 | |
|     && TENSORRT_VER=$(cat /etc/TENSORRT_VER) /deps/build_python_tensorrt.sh
 | |
| 
 | |
| COPY docker/tensorrt/requirements-arm64.txt /requirements-tensorrt.txt
 | |
| # See https://elinux.org/Jetson_Zoo#ONNX_Runtime
 | |
| ADD https://nvidia.box.com/shared/static/9yvw05k6u343qfnkhdv2x6xhygze0aq1.whl /tmp/onnxruntime_gpu-1.19.0-cp311-cp311-linux_aarch64.whl
 | |
| 
 | |
| RUN pip3 uninstall -y onnxruntime-openvino \
 | |
|     && pip3 wheel --wheel-dir=/trt-wheels -r /requirements-tensorrt.txt \
 | |
|     && pip3 install --no-deps /tmp/onnxruntime_gpu-1.19.0-cp311-cp311-linux_aarch64.whl
 | |
| 
 | |
| FROM build-wheels AS trt-model-wheels
 | |
| ARG DEBIAN_FRONTEND
 | |
| 
 | |
| RUN apt-get update \
 | |
|     && apt-get install -y protobuf-compiler libprotobuf-dev \
 | |
|     && rm -rf /var/lib/apt/lists/*
 | |
| RUN --mount=type=bind,source=docker/tensorrt/requirements-models-arm64.txt,target=/requirements-tensorrt-models.txt \
 | |
|     pip3 wheel --wheel-dir=/trt-model-wheels -r /requirements-tensorrt-models.txt
 | |
| 
 | |
| FROM wget AS jetson-ffmpeg
 | |
| ARG DEBIAN_FRONTEND
 | |
| ENV CCACHE_DIR /root/.ccache
 | |
| ENV CCACHE_MAXSIZE 2G
 | |
| RUN --mount=type=bind,source=docker/tensorrt/build_jetson_ffmpeg.sh,target=/deps/build_jetson_ffmpeg.sh \
 | |
|     --mount=type=cache,target=/root/.ccache \
 | |
|     /deps/build_jetson_ffmpeg.sh
 | |
| 
 | |
| # Frigate w/ TensorRT for NVIDIA Jetson platforms
 | |
| FROM tensorrt-base AS frigate-tensorrt
 | |
| RUN apt-get update \
 | |
|     && apt-get install -y python-is-python3 libprotobuf23  \
 | |
|     && rm -rf /var/lib/apt/lists/*
 | |
| 
 | |
| COPY --from=jetson-ffmpeg /rootfs /
 | |
| ENV DEFAULT_FFMPEG_VERSION="jetson"
 | |
| ENV INCLUDED_FFMPEG_VERSIONS="${DEFAULT_FFMPEG_VERSION}:${INCLUDED_FFMPEG_VERSIONS}"
 | |
| 
 | |
| # 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/*
 | |
| 
 | |
| # Fixes "Error loading shared libs"
 | |
| RUN mkdir -p /etc/ld.so.conf.d && echo /usr/lib/ffmpeg/jetson/lib/ > /etc/ld.so.conf.d/ffmpeg.conf
 | |
| 
 | |
| 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 \
 | |
|     pip3 install -U /deps/trt-wheels/*.whl /deps/trt-model-wheels/*.whl \
 | |
|     && ldconfig
 | |
| 
 | |
| WORKDIR /opt/frigate/
 | |
| COPY --from=rootfs / /
 | |
| 
 | |
| # Fixes "Error importing detector runtime: /usr/lib/aarch64-linux-gnu/libstdc++.so.6: cannot allocate memory in static TLS block"
 | |
| ENV LD_PRELOAD /usr/lib/aarch64-linux-gnu/libstdc++.so.6
 |