From d052a9d04b75249dc38d933a806066194ce2f891 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sun, 3 Nov 2024 09:34:48 -0700 Subject: [PATCH] replace pip3 with uv --- docker/hailo8l/Dockerfile | 4 ++-- docker/main/Dockerfile | 10 ++++++---- docker/rockchip/Dockerfile | 3 ++- docker/rocm/Dockerfile | 3 +++ docker/tensorrt/Dockerfile.amd64 | 5 +++-- docker/tensorrt/Dockerfile.arm64 | 6 +++--- docker/tensorrt/detector/build_python_tensorrt.sh | 2 +- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/docker/hailo8l/Dockerfile b/docker/hailo8l/Dockerfile index 959e7692e..ade2404c0 100644 --- a/docker/hailo8l/Dockerfile +++ b/docker/hailo8l/Dockerfile @@ -30,8 +30,8 @@ COPY --from=hailort /hailo-wheels /deps/hailo-wheels COPY --from=hailort /rootfs/ / # Install the wheels -RUN pip3 install -U /deps/h8l-wheels/*.whl -RUN pip3 install -U /deps/hailo-wheels/*.whl +RUN uv pip install --system -U /deps/h8l-wheels/*.whl +RUN uv pip install --system -U /deps/hailo-wheels/*.whl # Copy base files from the rootfs stage COPY --from=rootfs / / diff --git a/docker/main/Dockerfile b/docker/main/Dockerfile index e7c786599..814e0f54c 100644 --- a/docker/main/Dockerfile +++ b/docker/main/Dockerfile @@ -166,17 +166,19 @@ RUN apt-get -qq update \ # Ensure python3 defaults to python3.9 RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 -RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \ - && python3 get-pip.py "pip" +# install uv +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ +# install required python deps COPY docker/main/requirements.txt /requirements.txt -RUN pip3 install -r /requirements.txt +RUN uv pip install --system -r /requirements.txt # Build pysqlite3 from source COPY docker/main/build_pysqlite3.sh /build_pysqlite3.sh RUN /build_pysqlite3.sh COPY docker/main/requirements-wheels.txt /requirements-wheels.txt +# we still have to use pip to build wheel RUN pip3 wheel --wheel-dir=/wheels -r /requirements-wheels.txt @@ -269,7 +271,7 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* RUN --mount=type=bind,source=./docker/main/requirements-dev.txt,target=/workspace/frigate/requirements-dev.txt \ - pip3 install -r requirements-dev.txt + uv pip install --system -r requirements-dev.txt HEALTHCHECK NONE diff --git a/docker/rockchip/Dockerfile b/docker/rockchip/Dockerfile index e1b43c255..4143ccc23 100644 --- a/docker/rockchip/Dockerfile +++ b/docker/rockchip/Dockerfile @@ -7,13 +7,14 @@ FROM wheels as rk-wheels COPY docker/main/requirements-wheels.txt /requirements-wheels.txt COPY docker/rockchip/requirements-wheels-rk.txt /requirements-wheels-rk.txt RUN sed -i "/https:\/\//d" /requirements-wheels.txt +# we have to use pip to build wheel RUN pip3 wheel --wheel-dir=/rk-wheels -c /requirements-wheels.txt -r /requirements-wheels-rk.txt FROM deps AS rk-frigate ARG TARGETARCH RUN --mount=type=bind,from=rk-wheels,source=/rk-wheels,target=/deps/rk-wheels \ - pip3 install -U /deps/rk-wheels/*.whl + uv pip install -U /deps/rk-wheels/*.whl WORKDIR /opt/frigate/ COPY --from=rootfs / / diff --git a/docker/rocm/Dockerfile b/docker/rocm/Dockerfile index ab0fe3d0e..dd83291c7 100644 --- a/docker/rocm/Dockerfile +++ b/docker/rocm/Dockerfile @@ -70,7 +70,10 @@ RUN apt-get -y install libnuma1 WORKDIR /opt/frigate/ COPY --from=rootfs / / +# install uv COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ + +# install required rocm deps COPY docker/rocm/requirements-wheels-rocm.txt /requirements.txt RUN uv pip uninstall --system -y onnxruntime-openvino \ && uv pip install --system -r /requirements.txt diff --git a/docker/tensorrt/Dockerfile.amd64 b/docker/tensorrt/Dockerfile.amd64 index 3dcb42658..ce4167db7 100644 --- a/docker/tensorrt/Dockerfile.amd64 +++ b/docker/tensorrt/Dockerfile.amd64 @@ -10,6 +10,7 @@ ARG TARGETARCH # Add TensorRT wheels to another folder COPY docker/tensorrt/requirements-amd64.txt /requirements-tensorrt.txt +# we have to use pip here to build full dependency RUN mkdir -p /trt-wheels && pip3 wheel --wheel-dir=/trt-wheels -r /requirements-tensorrt.txt # Build CuDNN @@ -29,7 +30,7 @@ RUN wget https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_6 FROM tensorrt-base AS frigate-tensorrt ENV TRT_VER=8.5.3 RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \ - pip3 install -U /deps/trt-wheels/*.whl && \ + uv pip install --system -U /deps/trt-wheels/*.whl && \ ldconfig COPY --from=cudnn-deps /usr/local/cuda-12.6 /usr/local/cuda @@ -46,4 +47,4 @@ COPY --from=cudnn-deps /usr/local/cuda-12.6 /usr/local/cuda COPY docker/tensorrt/detector/rootfs/ / COPY --from=trt-deps /usr/local/lib/libyolo_layer.so /usr/local/lib/libyolo_layer.so RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \ - pip3 install -U /deps/trt-wheels/*.whl + uv pip install --system -U /deps/trt-wheels/*.whl diff --git a/docker/tensorrt/Dockerfile.arm64 b/docker/tensorrt/Dockerfile.arm64 index 23a2459ac..0d4edba0e 100644 --- a/docker/tensorrt/Dockerfile.arm64 +++ b/docker/tensorrt/Dockerfile.arm64 @@ -43,9 +43,9 @@ RUN --mount=type=bind,source=docker/tensorrt/detector/build_python_tensorrt.sh,t COPY docker/tensorrt/requirements-arm64.txt /requirements-tensorrt.txt ADD https://nvidia.box.com/shared/static/9aemm4grzbbkfaesg5l7fplgjtmswhj8.whl /tmp/onnxruntime_gpu-1.15.1-cp39-cp39-linux_aarch64.whl -RUN pip3 uninstall -y onnxruntime-openvino \ +RUN uv pip uninstall --system -y onnxruntime-openvino \ && pip3 wheel --wheel-dir=/trt-wheels -r /requirements-tensorrt.txt \ - && pip3 install --no-deps /tmp/onnxruntime_gpu-1.15.1-cp39-cp39-linux_aarch64.whl + && uv pip install --system --no-deps /tmp/onnxruntime_gpu-1.15.1-cp39-cp39-linux_aarch64.whl FROM build-wheels AS trt-model-wheels ARG DEBIAN_FRONTEND @@ -76,7 +76,7 @@ COPY --from=jetson-ffmpeg /rootfs / 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 \ + uv pip install --system -U /deps/trt-wheels/*.whl /deps/trt-model-wheels/*.whl \ && ldconfig WORKDIR /opt/frigate/ diff --git a/docker/tensorrt/detector/build_python_tensorrt.sh b/docker/tensorrt/detector/build_python_tensorrt.sh index 21b6ae268..e7c66c08d 100755 --- a/docker/tensorrt/detector/build_python_tensorrt.sh +++ b/docker/tensorrt/detector/build_python_tensorrt.sh @@ -16,7 +16,7 @@ if [[ "${TARGETARCH}" == "arm64" ]]; then # Collect dependencies EXT_PATH=/workspace/external && mkdir -p $EXT_PATH - pip3 install pybind11 && ln -s /usr/local/lib/python3.9/dist-packages/pybind11 $EXT_PATH/pybind11 + uv pip install --system pybind11 && ln -s /usr/local/lib/python3.9/dist-packages/pybind11 $EXT_PATH/pybind11 ln -s /usr/include/python3.9 $EXT_PATH/python3.9 ln -s /usr/include/aarch64-linux-gnu/NvOnnxParser.h /workspace/TensorRT/parsers/onnx/