Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RVC2 and RVC3 migration to python3.10 #67

Merged
merged 18 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/modelconverter_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ jobs:

- name: Run Tests
run: |
pytest -s --verbose "tests/test_packages/test_${PACKAGE}.py" --tool-version "${VERSION}"
pytest -x "tests/test_packages/test_${PACKAGE}.py" --tool-version "${VERSION}"

75 changes: 52 additions & 23 deletions docker/rvc2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ FROM python:3.8-slim AS base
ARG VERSION=2022.3.0
ENV VERSION=${VERSION}

RUN pip install --upgrade pip

RUN <<EOF

set -e

apt-get update
apt-get install -y \
cmake \
Expand All @@ -23,9 +26,6 @@ EOF

COPY --link docker/extra_packages/openvino-${VERSION}.tar.gz .

COPY --link requirements.txt requirements.txt
COPY --link docker/rvc2/requirements.txt requirements-rvc2.txt

RUN <<EOF

set -e
Expand All @@ -36,10 +36,10 @@ RUN <<EOF
else
STRIP_COMPONENTS=2
fi

tar xvf "openvino-${VERSION}.tar.gz" \
-C /opt/intel --strip-components=${STRIP_COMPONENTS}


if [ "${VERSION}" = "2022.3.0" ]; then
rm -r /opt/intel/tools/*.whl
else
Expand All @@ -48,19 +48,17 @@ RUN <<EOF

EOF

RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip install -r requirements-rvc2.txt

RUN <<EOF

set -e

pip install openvino==${VERSION} openvino-dev==${VERSION} tokenizers==0.20.0
# ONNX Runtime needs to be installed together with
# numpy<1.20 to prevent it from installing higher
# versions of numpy that are incompatible with OpenVINO 2021.4.0
if [ "${VERSION}" = "2021.4.0" ]; then
pip install --no-cache-dir onnxruntime 'numpy<1.20'
pip install onnx onnxruntime 'numpy<1.20'
fi

EOF
Expand All @@ -72,26 +70,39 @@ RUN <<EOF
set -e

# Model Optimizer contains a bug in both versions
# that needs to be patched
# that needs to be manually patched
if [ "${VERSION}" = "2022.3.0" ]; then
patch /usr/local/lib/python3.8/site-packages/openvino/tools/mo/convert_impl.py \
< /patches/mo-2022.3.patch
else
patch /usr/local/lib/python3.8/site-packages/mo/mo/main.py \
< /patches/mo-2021.4.patch

patch /opt/intel/deployment_tools/model_optimizer/mo/main.py \
< /patches/mo-2021.4.patch
fi


if [ "${VERSION}" = "2022.3.0" ]; then
sed -i '1c\#!/usr/local/bin/python3.8' /usr/local/bin/opt_in_out
else
echo '#!/usr/local/bin/python3.8' > /usr/local/bin/opt_in_out
chmod +x /usr/local/bin/opt_in_out
fi

EOF


FROM python:3.8-slim
FROM python:3.10-slim

ARG VERSION

WORKDIR /app

ENV IN_DOCKER=
ENV VERSION=${VERSION}
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/python3.8/site-packages/openvino/libs/

WORKDIR /app

COPY --link --from=base \
/usr/lib/x86_64-linux-gnu/libcurl.so.4 \
Expand All @@ -115,34 +126,52 @@ COPY --link --from=base \
/usr/lib/x86_64-linux-gnu/libXdmcp.so.6 \
/usr/lib/x86_64-linux-gnu/libbsd.so.0 \
/usr/lib/x86_64-linux-gnu/libusb-1.0.so.0 \
/usr/lib/x86_64-linux-gnu/libexpat.so.1 \
/usr/lib/

COPY --link --from=base /opt/intel /opt/intel
COPY --link --from=base /usr/local/bin /usr/local/bin

COPY --link --from=base /usr/local/lib /usr/local/lib

RUN pip install --upgrade pip
COPY --link requirements.txt /app/requirements.txt
COPY --link modelconverter/packages/rvc2/requirements.txt requirements-rvc2.txt

RUN <<EOF

set -e

pip install --upgrade pip --no-cache-dir
pip install -r requirements.txt --no-cache-dir
pip install -r requirements-rvc2.txt --no-cache-dir
pip install openvino==2022.3.0 openvino-dev==2022.3.0 --no-cache-dir

EOF

COPY --link --from=base /usr/local/bin/mo \
/usr/local/bin/opt_in_out \
/usr/local/bin/python3.8 \
/usr/local/bin/


COPY --link docker/rvc2/entrypoint.sh /app/entrypoint.sh
COPY --link modelconverter /app/modelconverter/
COPY --link pyproject.toml /app/pyproject.toml

RUN <<EOF
RUN pip install -e . --no-deps --no-cache-dir

set -e
COPY --link docker/rvc2/entrypoint.sh /app/entrypoint.sh
COPY --link docker/scripts/mo /usr/local/bin/mo
COPY --link docker/scripts/compile_tool /usr/local/bin/compile_tool

COMPILE_TOOL=$(find /opt/intel -name compile_tool -type f)
RUN <<EOF

pip install -e . --no-deps --no-cache-dir
set -e

echo "alias compile_tool=${COMPILE_TOOL}" >> ~/.bashrc
chmod +x /app/entrypoint.sh
chmod +x /usr/local/bin/mo
chmod +x /usr/local/bin/compile_tool

if [ "${VERSION}" = "2022.3.0" ]; then
opt_in_out --opt_out
fi
opt_in_out --opt_out

EOF


ENTRYPOINT ["/app/entrypoint.sh"]
24 changes: 2 additions & 22 deletions docker/rvc2/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
#!/bin/bash

args=("$@")
new_args=""
for arg in "${args[@]}"; do
new_args+="\"$arg\" "
done

set --

if [ ${VERSION} = "2021.4.0" ]; then
source /opt/intel/bin/setupvars.sh
else
source /opt/intel/setupvars.sh
fi

if [[ $PYTHONPATH != *: ]]; then
export PYTHONPATH=$PYTHONPATH:
fi

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python3.8/site-packages/openvino/libs/

if [[ -z $new_args ]]; then
if [[ -z "${@}" ]]; then
exec /bin/bash
fi

eval exec modelconverter $new_args
eval exec modelconverter "${@}"
5 changes: 0 additions & 5 deletions docker/rvc2/requirements.txt

This file was deleted.

67 changes: 47 additions & 20 deletions docker/rvc3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM python:3.8-slim AS base

RUN pip install --upgrade pip

RUN <<EOF

set -e
Expand All @@ -21,44 +23,42 @@ EOF

COPY --link docker/extra_packages/openvino-2022.3.0.tar.gz .

COPY --link requirements.txt requirements.txt
COPY --link docker/rvc3/requirements.txt requirements-rvc3.txt

RUN <<EOF

set -e

mkdir /opt/intel
tar xvf openvino-2022.3.0.tar.gz -C /opt/intel/ --strip-components 1

EOF
pip install openvino==2022.3.0 openvino-dev==2022.3.0 --no-cache-dir
pip install /opt/intel/tools/*.whl

RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip install /opt/intel/tools/*.whl
RUN pip install -r requirements-rvc3.txt
EOF

COPY --link docker/patches /patches

RUN <<EOF

set -e

# Model Optimizer contains a bug that needs to be patched
# Model Optimizer contains a bug that needs to be manually patched
patch /usr/local/lib/python3.8/site-packages/openvino/tools/mo/convert_impl.py \
< /patches/mo-2022.3.patch

rm -r /opt/intel/tools/*.whl

EOF
sed -i '1c\#!/usr/local/bin/python3.8' /usr/local/bin/opt_in_out

EOF

FROM python:3.8-slim

ENV IN_DOCKER=
FROM python:3.10-slim

WORKDIR /app

ENV IN_DOCKER=
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/python3.8/site-packages/openvino/libs/

COPY --link --from=base \
/usr/lib/x86_64-linux-gnu/libcurl.so.4 \
/usr/lib/x86_64-linux-gnu/libnghttp2.so.14 \
Expand All @@ -81,28 +81,55 @@ COPY --link --from=base \
/usr/lib/x86_64-linux-gnu/libXdmcp.so.6 \
/usr/lib/x86_64-linux-gnu/libbsd.so.0 \
/usr/lib/x86_64-linux-gnu/libusb-1.0.so.0 \
/usr/lib/x86_64-linux-gnu/libexpat.so.1 \
/usr/lib/

COPY --link --from=base /opt/intel /opt/intel
COPY --link --from=base /usr/local/bin /usr/local/bin

COPY --link --from=base /usr/local/lib /usr/local/lib

RUN pip install --upgrade pip

COPY --link docker/rvc3/entrypoint.sh /app/entrypoint.sh
COPY --link modelconverter /app/modelconverter/
COPY --link pyproject.toml /app/pyproject.toml
COPY --link requirements.txt requirements.txt
COPY --link modelconverter/packages/rvc3/requirements.txt requirements-rvc3.txt

RUN <<EOF

set -e

COMPILE_TOOL=/opt/intel/tools/compile_tool/compile_tool
pip install --upgrade pip --no-cache-dir
pip install -r requirements.txt --no-cache-dir
pip install -r requirements-rvc3.txt --no-cache-dir
pip install openvino==2022.3.0 openvino-dev==2022.3.0 --no-cache-dir

EOF

COPY --link --from=base /usr/local/bin/mo \
/usr/local/bin/opt_in_out \
/usr/local/bin/pot \
/usr/local/bin/python3.8 \
/usr/local/bin/

COPY --link modelconverter /app/modelconverter/
COPY --link pyproject.toml /app/pyproject.toml

RUN pip install -e . --no-deps

pip install -e . --no-deps --no-cache-dir
# The RVC2 entrypoint is used for RVC3 as well
COPY --link docker/rvc2/entrypoint.sh /app/entrypoint.sh
COPY --link docker/scripts/mo /usr/local/bin/mo
COPY --link docker/scripts/pot /usr/local/bin/pot
COPY --link docker/scripts/compile_tool /usr/local/bin/compile_tool

RUN <<EOF

set -e

echo "alias compile_tool=${COMPILE_TOOL}" >> ~/.bashrc
chmod +x /app/entrypoint.sh
chmod +x /usr/local/bin/mo
chmod +x /usr/local/bin/pot
chmod +x /usr/local/bin/compile_tool

opt_in_out --opt_out

EOF

Expand Down
18 changes: 0 additions & 18 deletions docker/rvc3/entrypoint.sh

This file was deleted.

5 changes: 3 additions & 2 deletions docker/rvc4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RUN <<EOF
EOF

COPY --link requirements.txt requirements.txt
COPY --link docker/rvc4/requirements.txt requirements-rvc4.txt
COPY --link modelconverter/packages/rvc4/requirements.txt requirements-rvc4.txt

RUN pip install --upgrade pip
RUN pip install -r requirements.txt
Expand All @@ -68,6 +68,8 @@ ENV VERSION=${VERSION}

WORKDIR /app

RUN pip install --upgrade pip

COPY --link --from=base /opt/ /opt/
COPY --link --from=base /usr/local/lib /usr/local/lib
COPY --link --from=base \
Expand Down Expand Up @@ -104,7 +106,6 @@ COPY --link --from=base \
/usr/lib/x86_64-linux-gnu/libicudata.so.72 \
/usr/lib/

RUN pip install --upgrade pip

COPY --link docker/rvc4/entrypoint.sh /app/entrypoint.sh
COPY --link modelconverter /app/modelconverter/
Expand Down
11 changes: 11 additions & 0 deletions docker/scripts/compile_tool
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

source $(find /opt/intel -name setupvars.sh) -pyver 3.8 > /dev/null

COMPILE_TOOL=$(find /opt/intel -name compile_tool -type f)

if [[ "${VERSION}" = "2021.4.0" ]]; then
export LD_LIBRARY_PATH="/opt/intel/deployment_tools/inference_engine/:${LD_LIBRARY_PATH}"
fi

exec "${COMPILE_TOOL}" "${@}"
Loading
Loading