From 91e948f4cbbf75a13066b893d2e283a0e4a7aae8 Mon Sep 17 00:00:00 2001 From: Steve Grubb Date: Mon, 5 May 2025 15:32:42 -0400 Subject: [PATCH 1/3] Install openvino-tokenizer python module in image I was working through a demo where it said to run "pip install -U optimum[diffusers,openvino]". When I did that, I noticed that it downloaded: openvino_tokenizers-2025.1.0.0-py3-none-manylinux2014_x86_64.whl. However, the tokenizer is built and installed in the image by the Dockerfile. After more digging, I found that openvino's python module is not installed in the image. This patch installs the openvino-tokenizer python module in the image and uses a symlink to point to the tokenizer shared object to save space. --- Dockerfile.redhat | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Dockerfile.redhat b/Dockerfile.redhat index 8b219d12e0..f0ec3e7f32 100644 --- a/Dockerfile.redhat +++ b/Dockerfile.redhat @@ -220,6 +220,17 @@ RUN git clone https://github.com/openvinotoolkit/openvino_tokenizers.git /openvi WORKDIR /openvino_tokenizers/build RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE="${VERBOSE_LOGS}" && cmake --build . --parallel $JOBS ; cp /openvino_tokenizers/build/src/lib*.so /opt/intel/openvino/runtime/lib/intel64/ +WORKDIR /openvino_tokenizers/ +# Install the openvino_tokenizers python bindings and use a symlink to point +# to the shared object in it's final location. +RUN if ! [[ $debug_bazel_flags == *"_py_off"* ]]; then \ + mkdir -p /opt/intel/openvino/python/openvino_tokenizers/lib ; \ + cp -r python/* /opt/intel/openvino/python/ ; \ + cp build/python/* /opt/intel/openvino/python/openvino_tokenizers/ ; \ + mkdir -p /opt/intel/openvino/python/openvino_tokenizers-2025.1.dist-info ; \ + echo $'Metadata-Version: 1.0\nName: openvino-tokenizers\nVersion: 2025.1\nRequires-Python: >=3.9\nRequires-Dist: openvino~=2025.1.0' > /opt/intel/openvino/python/openvino_tokenizers-2025.1.dist-info/METADATA ; \ + ln -s /ovms/lib/libopenvino_tokenizers.so /opt/intel/openvino/python/openvino_tokenizers/lib/libopenvino_tokenizers.so ; fi + # Build OpenVINO Model Server WORKDIR /ovms COPY .bazelrc .user.bazelr[c] .bazelversion WORKSPACE /ovms/ @@ -338,7 +349,9 @@ ARG FUZZER_BUILD=0 ARG debug_bazel_flags="--strip=always --config=mp_on_py_on --//:distro=redhat" COPY --from=capi-build /ovms_release/lib/libovms_shared.so /ovms_release/lib/ COPY create_package.sh / -RUN ./create_package.sh +RUN ./create_package.sh ; \ + echo $'#!/bin/bash\npython3 -m openvino_tokenizers.cli "$@"' > /ovms_release/bin/convert_tokenizer ; \ + chmod +x /ovms_release/bin/convert_tokenizer # hadolint ignore=DL3059 RUN chown -R ovms:ovms /ovms_release @@ -387,6 +400,7 @@ RUN if [ -f /usr/bin/dnf ] ; then export DNF_TOOL=dnf ; echo -e "max_parallel_do useradd --home-dir /home/ovms --create-home --uid 5000 --gid 5000 --groups 39,44 --shell /bin/bash --skel /dev/null ovms ENV LD_LIBRARY_PATH=/ovms/lib +ENV PATH="$PATH:/ovms/bin" COPY --from=pkg /ovms_release /ovms COPY --from=pkg /usr/local/lib/python3.*/site-packages/jinja2 /ovms/python_deps/jinja2 From 57001f19b1d7fde0d14ec0760ba70731b1133d42 Mon Sep 17 00:00:00 2001 From: Steve Grubb Date: Tue, 6 May 2025 13:56:50 -0400 Subject: [PATCH 2/3] Conditionalize convert_tokenizer creation Only create the convert_tokenizer if python is enbled --- Dockerfile.redhat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.redhat b/Dockerfile.redhat index f0ec3e7f32..e97328b664 100644 --- a/Dockerfile.redhat +++ b/Dockerfile.redhat @@ -349,9 +349,9 @@ ARG FUZZER_BUILD=0 ARG debug_bazel_flags="--strip=always --config=mp_on_py_on --//:distro=redhat" COPY --from=capi-build /ovms_release/lib/libovms_shared.so /ovms_release/lib/ COPY create_package.sh / -RUN ./create_package.sh ; \ +RUN ./create_package.sh ; if ! [[ $debug_bazel_flags == *"_py_off"* ]]; then \ echo $'#!/bin/bash\npython3 -m openvino_tokenizers.cli "$@"' > /ovms_release/bin/convert_tokenizer ; \ - chmod +x /ovms_release/bin/convert_tokenizer + chmod +x /ovms_release/bin/convert_tokenizer ; fi # hadolint ignore=DL3059 RUN chown -R ovms:ovms /ovms_release From adb75155a514b8410e98c49296b35c0bcbc5384a Mon Sep 17 00:00:00 2001 From: Steve Grubb Date: Wed, 21 May 2025 17:31:01 -0400 Subject: [PATCH 3/3] Update branch --- Dockerfile.redhat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.redhat b/Dockerfile.redhat index e97328b664..3e31ad28a9 100644 --- a/Dockerfile.redhat +++ b/Dockerfile.redhat @@ -227,8 +227,8 @@ RUN if ! [[ $debug_bazel_flags == *"_py_off"* ]]; then \ mkdir -p /opt/intel/openvino/python/openvino_tokenizers/lib ; \ cp -r python/* /opt/intel/openvino/python/ ; \ cp build/python/* /opt/intel/openvino/python/openvino_tokenizers/ ; \ - mkdir -p /opt/intel/openvino/python/openvino_tokenizers-2025.1.dist-info ; \ - echo $'Metadata-Version: 1.0\nName: openvino-tokenizers\nVersion: 2025.1\nRequires-Python: >=3.9\nRequires-Dist: openvino~=2025.1.0' > /opt/intel/openvino/python/openvino_tokenizers-2025.1.dist-info/METADATA ; \ + mkdir -p /opt/intel/openvino/python/openvino_tokenizers-2025.2.dist-info ; \ + echo $'Metadata-Version: 1.0\nName: openvino-tokenizers\nVersion: 2025.2\nRequires-Python: >=3.9\nRequires-Dist: openvino~=2025.2.0' > /opt/intel/openvino/python/openvino_tokenizers-2025.2.dist-info/METADATA ; \ ln -s /ovms/lib/libopenvino_tokenizers.so /opt/intel/openvino/python/openvino_tokenizers/lib/libopenvino_tokenizers.so ; fi # Build OpenVINO Model Server