1
0
mirror of https://github.com/immich-app/immich.git synced 2025-01-02 12:48:35 +02:00

chore(deps): update onnxruntime-openvino (#7854)

This commit is contained in:
Mert 2024-03-16 00:04:45 -04:00 committed by GitHub
parent a9438a9c2d
commit 3a045b33ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 43 additions and 63 deletions

View File

@ -2,7 +2,7 @@ ARG DEVICE=cpu
FROM python:3.11-bookworm@sha256:991e20a11120277e977cadbc104e7a9b196a68a346597879821b19034285a403 as builder-cpu FROM python:3.11-bookworm@sha256:991e20a11120277e977cadbc104e7a9b196a68a346597879821b19034285a403 as builder-cpu
FROM openvino/ubuntu22_runtime:2023.1.0@sha256:002842a9005ba01543b7169ff6f14ecbec82287f09c4d1dd37717f0a8e8754a7 as builder-openvino FROM openvino/ubuntu22_runtime:2023.3.0@sha256:176646df619032ea6c10faf842867119c393e7497b7f88b5e307e932a0fd5aa8 as builder-openvino
USER root USER root
RUN apt-get update && apt-get install -y --no-install-recommends python3-dev RUN apt-get update && apt-get install -y --no-install-recommends python3-dev
@ -21,10 +21,12 @@ FROM builder-${DEVICE} as builder
ARG DEVICE ARG DEVICE
ENV PYTHONDONTWRITEBYTECODE=1 \ ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \ PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=true \ PIP_NO_CACHE_DIR=true \
VIRTUAL_ENV="/opt/venv" \ VIRTUAL_ENV="/opt/venv" \
PATH="/opt/venv/bin:${PATH}" PATH="/opt/venv/bin:${PATH}"
RUN apt-get update && apt-get install -y --no-install-recommends g++
RUN pip install --upgrade pip && pip install poetry RUN pip install --upgrade pip && pip install poetry
RUN poetry config installer.max-workers 10 && \ RUN poetry config installer.max-workers 10 && \
@ -36,7 +38,7 @@ RUN poetry install --sync --no-interaction --no-ansi --no-root --with ${DEVICE}
FROM python:3.11-slim-bookworm@sha256:a2eb07f336e4f194358382611b4fea136c632b40baa6314cb27a366deeaf0144 as prod-cpu FROM python:3.11-slim-bookworm@sha256:a2eb07f336e4f194358382611b4fea136c632b40baa6314cb27a366deeaf0144 as prod-cpu
FROM openvino/ubuntu22_runtime:2023.1.0@sha256:002842a9005ba01543b7169ff6f14ecbec82287f09c4d1dd37717f0a8e8754a7 as prod-openvino FROM openvino/ubuntu22_runtime:2023.3.0@sha256:176646df619032ea6c10faf842867119c393e7497b7f88b5e307e932a0fd5aa8 as prod-openvino
USER root USER root
FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04@sha256:2d913b09e6be8387e1a10976933642c73c840c0b735f0bf3c28d97fc9bc422e0 as prod-cuda FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04@sha256:2d913b09e6be8387e1a10976933642c73c840c0b735f0bf3c28d97fc9bc422e0 as prod-cuda
@ -56,14 +58,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends ocl-icd-libopen
mkdir /opt/armnn mkdir /opt/armnn
COPY --from=builder-armnn \ COPY --from=builder-armnn \
/opt/armnn/libarmnn.so.?? \ /opt/armnn/libarmnn.so.?? \
/opt/armnn/libarmnnOnnxParser.so.?? \ /opt/armnn/libarmnnOnnxParser.so.?? \
/opt/armnn/libarmnnDeserializer.so.?? \ /opt/armnn/libarmnnDeserializer.so.?? \
/opt/armnn/libarmnnTfLiteParser.so.?? \ /opt/armnn/libarmnnTfLiteParser.so.?? \
/opt/armnn/libprotobuf.so.?.??.?.? \ /opt/armnn/libprotobuf.so.?.??.?.? \
/opt/ann/libann.s[o] \ /opt/ann/libann.s[o] \
/opt/ann/build.sh \ /opt/ann/build.sh \
/opt/armnn/ /opt/armnn/
FROM prod-${DEVICE} as prod FROM prod-${DEVICE} as prod
@ -73,11 +75,12 @@ RUN apt-get update && \
WORKDIR /usr/src/app WORKDIR /usr/src/app
ENV NODE_ENV=production \ ENV NODE_ENV=production \
TRANSFORMERS_CACHE=/cache \ TRANSFORMERS_CACHE=/cache \
PYTHONDONTWRITEBYTECODE=1 \ PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \ PYTHONUNBUFFERED=1 \
PATH="/opt/venv/bin:$PATH" \ PATH="/opt/venv/bin:$PATH" \
PYTHONPATH=/usr/src PYTHONPATH=/usr/src \
DEVICE=${DEVICE}
# prevent core dumps # prevent core dumps
RUN echo "hard core 0" >> /etc/security/limits.conf && \ RUN echo "hard core 0" >> /etc/security/limits.conf && \

View File

@ -1,6 +1,5 @@
from __future__ import annotations from __future__ import annotations
import os
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from pathlib import Path from pathlib import Path
from shutil import rmtree from shutil import rmtree
@ -115,17 +114,12 @@ class InferenceModel(ABC):
case ".armnn": case ".armnn":
session = AnnSession(model_path) session = AnnSession(model_path)
case ".onnx": case ".onnx":
cwd = os.getcwd() session = ort.InferenceSession(
try: model_path.as_posix(),
os.chdir(model_path.parent) sess_options=self.sess_options,
session = ort.InferenceSession( providers=self.providers,
model_path.as_posix(), provider_options=self.provider_options,
sess_options=self.sess_options, )
providers=self.providers,
provider_options=self.provider_options,
)
finally:
os.chdir(cwd)
case _: case _:
raise ValueError(f"Unsupported model file type: {model_path.suffix}") raise ValueError(f"Unsupported model file type: {model_path.suffix}")
return session return session

View File

@ -262,7 +262,6 @@ class TestBase:
mock_ann = mocker.patch("app.models.base.AnnSession") mock_ann = mocker.patch("app.models.base.AnnSession")
mock_ort = mocker.patch("app.models.base.ort.InferenceSession") mock_ort = mocker.patch("app.models.base.ort.InferenceSession")
mocker.patch("app.models.base.os.chdir")
encoder = OpenCLIPEncoder("ViT-B-32__openai") encoder = OpenCLIPEncoder("ViT-B-32__openai")
encoder._make_session(mock_armnn_path) encoder._make_session(mock_armnn_path)
@ -285,26 +284,6 @@ class TestBase:
mock_ann.assert_not_called() mock_ann.assert_not_called()
mock_ort.assert_not_called() mock_ort.assert_not_called()
def test_make_session_changes_cwd(self, mocker: MockerFixture) -> None:
mock_model_path = mocker.Mock()
mock_model_path.is_file.return_value = True
mock_model_path.suffix = ".onnx"
mock_model_path.parent = "model_parent"
mock_model_path.with_suffix.return_value = mock_model_path
mock_ort = mocker.patch("app.models.base.ort.InferenceSession")
mock_chdir = mocker.patch("app.models.base.os.chdir")
encoder = OpenCLIPEncoder("ViT-B-32__openai")
encoder._make_session(mock_model_path)
mock_chdir.assert_has_calls(
[
mock.call(mock_model_path.parent),
mock.call(os.getcwd()),
]
)
mock_ort.assert_called_once()
def test_download(self, mocker: MockerFixture) -> None: def test_download(self, mocker: MockerFixture) -> None:
mock_snapshot_download = mocker.patch("app.models.base.snapshot_download") mock_snapshot_download = mocker.patch("app.models.base.snapshot_download")

View File

@ -1,4 +1,4 @@
# This file is automatically @generated by Poetry 1.8.1 and should not be changed by hand. # This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.
[[package]] [[package]]
name = "aiocache" name = "aiocache"
@ -2064,21 +2064,22 @@ reference = "cuda12"
[[package]] [[package]]
name = "onnxruntime-openvino" name = "onnxruntime-openvino"
version = "1.15.0" version = "1.17.1"
description = "ONNX Runtime is a runtime accelerator for Machine Learning models" description = "ONNX Runtime is a runtime accelerator for Machine Learning models"
optional = false optional = false
python-versions = "*" python-versions = "*"
files = [ files = [
{file = "onnxruntime_openvino-1.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ac9bfe245312e897f219dfef619c0d98f4797ffb008ad55aa41aedb32b522f72"}, {file = "onnxruntime_openvino-1.17.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6ed693011b472f9a617b2d5c4785d5fa1e1b77f7cb2b02e47b899534ec6c6396"},
{file = "onnxruntime_openvino-1.15.0-cp310-cp310-win_amd64.whl", hash = "sha256:a31cd9c9848dc196803d74ea46152fe0f3dd876bc5769eff7e3776fef4c654de"}, {file = "onnxruntime_openvino-1.17.1-cp310-cp310-win_amd64.whl", hash = "sha256:5152b5e56e83e022ced2986700d68dd8ba7b1466761725ce774f679c5710ab87"},
{file = "onnxruntime_openvino-1.15.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0c9bc1614f9d267d62023287035d204d9840ac0057d1c7a770a27acdd1642662"}, {file = "onnxruntime_openvino-1.17.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2ce3b1aa06d6b8b732d314d217028ec4735de5806215c44d3bdbcad03b9260d5"},
{file = "onnxruntime_openvino-1.15.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d0c5808b7b876e5f6a083228bd43fc1028096cb9b485f466bf980d8f72d8424d"}, {file = "onnxruntime_openvino-1.17.1-cp311-cp311-win_amd64.whl", hash = "sha256:21133a701bb07ea19e01f48b8c23beee575f2e879f49173843f275d7c91a625a"},
{file = "onnxruntime_openvino-1.17.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:76824dac3c392ad4b812f29c18be2055ab3bba2e3c111e44baae847b33d5b081"},
] ]
[package.dependencies] [package.dependencies]
coloredlogs = "*" coloredlogs = "*"
flatbuffers = "*" flatbuffers = "*"
numpy = ">=1.21.6" numpy = ">=1.25.2"
packaging = "*" packaging = "*"
protobuf = "*" protobuf = "*"
sympy = "*" sympy = "*"
@ -3626,4 +3627,4 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"]
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = ">=3.10,<3.12" python-versions = ">=3.10,<3.12"
content-hash = "c947090d326e81179054b7ce4dded311df8b7ca5a56680d5e9459cf8ca18df1a" content-hash = "1b014276ec94f9389459a70d31f0d96d1dd5a138bcc988900865e5f07a72bc62"

View File

@ -51,7 +51,7 @@ onnxruntime-gpu = {version = "^1.17.0", source = "cuda12"}
optional = true optional = true
[tool.poetry.group.openvino.dependencies] [tool.poetry.group.openvino.dependencies]
onnxruntime-openvino = ">=1.15.0,<1.16.0" onnxruntime-openvino = "^1.17.1"
[tool.poetry.group.armnn] [tool.poetry.group.armnn]
optional = true optional = true

View File

@ -1,8 +1,11 @@
#!/usr/bin/env sh #!/usr/bin/env sh
lib_path="/usr/lib/$(arch)-linux-gnu/libmimalloc.so.2" lib_path="/usr/lib/$(arch)-linux-gnu/libmimalloc.so.2"
export LD_PRELOAD="$lib_path" # mimalloc seems to increase memory usage dramatically with openvino, need to investigate
export LD_BIND_NOW=1 if ! [ "$DEVICE" = "openvino" ]; then
export LD_PRELOAD="$lib_path"
export LD_BIND_NOW=1
fi
: "${MACHINE_LEARNING_HOST:=[::]}" : "${MACHINE_LEARNING_HOST:=[::]}"
: "${MACHINE_LEARNING_PORT:=3003}" : "${MACHINE_LEARNING_PORT:=3003}"