Skip to content

Commit 9eafec4

Browse files
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.
1 parent 09b03d4 commit 9eafec4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Dockerfile.redhat

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,16 @@ ARG ov_tokenizers_branch=master
227227
RUN git clone https://github.com/openvinotoolkit/openvino_tokenizers.git /openvino_tokenizers && cd /openvino_tokenizers && git checkout $ov_tokenizers_branch && git submodule update --init --recursive
228228
WORKDIR /openvino_tokenizers/build
229229
RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE="${VERBOSE_LOGS}" -DCMAKE_CXX_FLAGS=" ${LTO_CXX_FLAGS} " -DCMAKE_SHARED_LINKER_FLAGS="${LTO_LD_FLAGS}" && cmake --build . --parallel $JOBS ; cp /openvino_tokenizers/build/src/lib*.so /opt/intel/openvino/runtime/lib/intel64/
230+
WORKDIR /openvino_tokenizers/
231+
# Install the openvino_tokenizers python bindings and use a symlink to point
232+
# to the shared object in it's final location.
233+
RUN if ! [[ $debug_bazel_flags == *"_py_off"* ]]; then \
234+
mkdir -p /opt/intel/openvino/python/openvino_tokenizers/lib ; \
235+
cp -r python/* /opt/intel/openvino/python/ ; \
236+
cp build/python/* /opt/intel/openvino/python/openvino_tokenizers/ ; \
237+
mkdir -p /opt/intel/openvino/python/openvino_tokenizers-2025.1.dist-info ; \
238+
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 ; \
239+
ln -s /ovms/lib/libopenvino_tokenizers.so /opt/intel/openvino/python/openvino_tokenizers/lib/libopenvino_tokenizers.so ; fi
230240

231241
# Build OpenVINO Model Server
232242
WORKDIR /ovms
@@ -346,7 +356,9 @@ ARG FUZZER_BUILD=0
346356
ARG debug_bazel_flags="--strip=always --config=mp_on_py_on --//:distro=redhat"
347357
COPY --from=capi-build /ovms_release/lib/libovms_shared.so /ovms_release/lib/
348358
COPY create_package.sh /
349-
RUN ./create_package.sh
359+
RUN ./create_package.sh ; if ! [[ $debug_bazel_flags == *"_py_off"* ]]; then \
360+
echo $'#!/bin/bash\npython3 -m openvino_tokenizers.cli "$@"' > /ovms_release/bin/convert_tokenizer ; \
361+
chmod +x /ovms_release/bin/convert_tokenizer ; fi
350362

351363
# hadolint ignore=DL3059
352364
RUN chown -R ovms:ovms /ovms_release
@@ -395,6 +407,7 @@ RUN if [ -f /usr/bin/dnf ] ; then export DNF_TOOL=dnf ; echo -e "max_parallel_do
395407
useradd --home-dir /home/ovms --create-home --uid 5000 --gid 5000 --groups 39,44 --shell /bin/bash --skel /dev/null ovms
396408

397409
ENV LD_LIBRARY_PATH=/ovms/lib
410+
ENV PATH="$PATH:/ovms/bin"
398411

399412
COPY --from=pkg /ovms_release /ovms
400413
COPY --from=pkg /usr/local/lib/python3.*/site-packages/jinja2 /ovms/python_deps/jinja2

0 commit comments

Comments
 (0)