From 1d59f29407a928bd53def5623eb938435a520f2d Mon Sep 17 00:00:00 2001 From: Egor Tyuvaev Date: Thu, 14 Nov 2024 11:51:38 +0100 Subject: [PATCH] Fix Ubuntu 20 Image build (#315) * fix ubuntu20 for python39 * Add venv to ubuntu20 to mitigate python version mixup --- templates/ubuntu20/common/base.dockerfile.j2 | 12 ++++++++---- templates/ubuntu20/dist/dev.dockerfile.j2 | 18 +++++++++--------- .../ubuntu20/dist/dev_no_samples.dockerfile.j2 | 10 +++++----- templates/ubuntu20/dist/runtime.dockerfile.j2 | 2 +- .../ubuntu20/python/python38.dockerfile.j2 | 4 ---- .../ubuntu20/python/python39.dockerfile.j2 | 5 +++++ 6 files changed, 28 insertions(+), 23 deletions(-) delete mode 100644 templates/ubuntu20/python/python38.dockerfile.j2 create mode 100644 templates/ubuntu20/python/python39.dockerfile.j2 diff --git a/templates/ubuntu20/common/base.dockerfile.j2 b/templates/ubuntu20/common/base.dockerfile.j2 index d6308672..79d5ebb9 100644 --- a/templates/ubuntu20/common/base.dockerfile.j2 +++ b/templates/ubuntu20/common/base.dockerfile.j2 @@ -35,7 +35,7 @@ SHELL ["/bin/bash", "-xo", "pipefail", "-c"] RUN apt-get update; \ apt-get install -y --no-install-recommends \ git \ - python3-dev \ + python3.9-dev \ python3-pip \ build-essential \ cmake \ @@ -187,17 +187,21 @@ ARG INSTALL_SOURCES="no" ARG DEPS="tzdata \ curl" {% if 'runtime' == distribution %} -ARG LGPL_DEPS="" +ARG LGPL_DEPS="python3.9-venv python3-pip" ARG INSTALL_PACKAGES="-c=python -c=core" {% elif 'dev' == distribution or 'dev_no_samples' == distribution %} ARG LGPL_DEPS="g++ \ gcc \ - libc6-dev" + libc6-dev \ + python3.9-venv \ + python3-pip" ARG INSTALL_PACKAGES="-c=python -c=core -c=dev" {% else %} ARG LGPL_DEPS="g++ \ gcc \ - libc6-dev" + libc6-dev \ + python3.9-venv \ + python3-pip" ARG INSTALL_PACKAGES="-c=python" {% endif %} diff --git a/templates/ubuntu20/dist/dev.dockerfile.j2 b/templates/ubuntu20/dist/dev.dockerfile.j2 index 5a5e5d72..fa8c9834 100644 --- a/templates/ubuntu20/dist/dev.dockerfile.j2 +++ b/templates/ubuntu20/dist/dev.dockerfile.j2 @@ -5,15 +5,15 @@ ARG OPENVINO_WHEELS_URL # hadolint ignore=SC2102 RUN apt-get update && apt-get install -y --no-install-recommends cmake make git && rm -rf /var/lib/apt/lists/* && \ if [ -z "$OPENVINO_WHEELS_URL" ]; then \ - ${PYTHON_VER} -m pip install --no-cache-dir openvino=="${OPENVINO_WHEELS_VERSION}" && \ - ${PYTHON_VER} -m pip install --no-cache-dir openvino-tokenizers=="${OPENVINO_WHEELS_VERSION}" && \ - ${PYTHON_VER} -m pip install --no-cache-dir openvino-genai=="${OPENVINO_WHEELS_VERSION}" && \ - ${PYTHON_VER} -m pip install --no-cache-dir openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="${OPENVINO_WHEELS_VERSION}" --extra-index-url https://download.pytorch.org/whl/cpu; \ + python3 -m pip install --no-cache-dir openvino=="${OPENVINO_WHEELS_VERSION}" && \ + python3 -m pip install --no-cache-dir openvino-tokenizers=="${OPENVINO_WHEELS_VERSION}" && \ + python3 -m pip install --no-cache-dir openvino-genai=="${OPENVINO_WHEELS_VERSION}" && \ + python3 -m pip install --no-cache-dir openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="${OPENVINO_WHEELS_VERSION}" --extra-index-url https://download.pytorch.org/whl/cpu; \ else \ - ${PYTHON_VER} -m pip install --no-cache-dir --pre openvino=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ - ${PYTHON_VER} -m pip install --no-cache-dir --pre openvino-tokenizers=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ - ${PYTHON_VER} -m pip install --no-cache-dir --pre openvino-genai=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ - ${PYTHON_VER} -m pip install --no-cache-dir --pre openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" --extra-index-url https://download.pytorch.org/whl/cpu; \ + python3 -m pip install --no-cache-dir --pre openvino=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ + python3 -m pip install --no-cache-dir --pre openvino-tokenizers=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ + python3 -m pip install --no-cache-dir --pre openvino-genai=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ + python3 -m pip install --no-cache-dir --pre openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="${OPENVINO_WHEELS_VERSION}" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" --extra-index-url https://download.pytorch.org/whl/cpu; \ fi WORKDIR ${INTEL_OPENVINO_DIR}/licensing @@ -37,6 +37,6 @@ RUN ./build_samples.sh -b /tmp/build -i ${INTEL_OPENVINO_DIR}/samples/cpp/sample # hadolint ignore=DL3013 RUN git clone https://github.com/openvinotoolkit/open_model_zoo && \ sed -i '/opencv-python/d' open_model_zoo/demos/common/python/requirements.txt && \ - pip3 --no-cache-dir install open_model_zoo/demos/common/python/ && \ + python3 -m pip --no-cache-dir install open_model_zoo/demos/common/python/ && \ rm -Rf open_model_zoo && \ python3 -c "from model_zoo import model_api" diff --git a/templates/ubuntu20/dist/dev_no_samples.dockerfile.j2 b/templates/ubuntu20/dist/dev_no_samples.dockerfile.j2 index 2dcd3f4b..37cdb8bb 100644 --- a/templates/ubuntu20/dist/dev_no_samples.dockerfile.j2 +++ b/templates/ubuntu20/dist/dev_no_samples.dockerfile.j2 @@ -3,13 +3,13 @@ WORKDIR ${INTEL_OPENVINO_DIR} ARG OPENVINO_WHEELS_VERSION={{ product_version }} ARG OPENVINO_WHEELS_URL # hadolint ignore=SC2102 -RUN ${PYTHON_VER} -m pip install --no-cache-dir cmake && \ +RUN python3 -m pip install --no-cache-dir cmake && \ if [ -z "$OPENVINO_WHEELS_URL" ]; then \ - ${PYTHON_VER} -m pip install --no-cache-dir openvino=="$OPENVINO_WHEELS_VERSION" && \ - ${PYTHON_VER} -m pip install --no-cache-dir openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="$OPENVINO_WHEELS_VERSION" ; \ + python3 -m pip install --no-cache-dir openvino=="$OPENVINO_WHEELS_VERSION" && \ + python3 -m pip install --no-cache-dir openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="$OPENVINO_WHEELS_VERSION" ; \ else \ - ${PYTHON_VER} -m pip install --no-cache-dir --pre openvino=="$OPENVINO_WHEELS_VERSION" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ - ${PYTHON_VER} -m pip install --no-cache-dir --pre openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="$OPENVINO_WHEELS_VERSION" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" ; \ + python3 -m pip install --no-cache-dir --pre openvino=="$OPENVINO_WHEELS_VERSION" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" && \ + python3 -m pip install --no-cache-dir --pre openvino_dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=="$OPENVINO_WHEELS_VERSION" --trusted-host=* --find-links "$OPENVINO_WHEELS_URL" ; \ fi WORKDIR ${INTEL_OPENVINO_DIR}/licensing diff --git a/templates/ubuntu20/dist/runtime.dockerfile.j2 b/templates/ubuntu20/dist/runtime.dockerfile.j2 index d7e9780e..81e04cd9 100644 --- a/templates/ubuntu20/dist/runtime.dockerfile.j2 +++ b/templates/ubuntu20/dist/runtime.dockerfile.j2 @@ -1,5 +1,5 @@ # Install OpenVINO python API dependency -RUN ${PYTHON_VER} -m pip install --no-cache-dir numpy==1.24.4 +RUN python3 -m pip install --no-cache-dir numpy==1.24.4 WORKDIR ${INTEL_OPENVINO_DIR}/licensing # Please use `third-party-programs-docker-runtime.txt` short path to 3d party file if you use the Dockerfile directly from docker_ci/dockerfiles repo folder diff --git a/templates/ubuntu20/python/python38.dockerfile.j2 b/templates/ubuntu20/python/python38.dockerfile.j2 deleted file mode 100644 index 74c59635..00000000 --- a/templates/ubuntu20/python/python38.dockerfile.j2 +++ /dev/null @@ -1,4 +0,0 @@ -# setup Python -ENV PYTHON_VER python3.8 - -RUN ${PYTHON_VER} -m pip install --upgrade pip \ No newline at end of file diff --git a/templates/ubuntu20/python/python39.dockerfile.j2 b/templates/ubuntu20/python/python39.dockerfile.j2 new file mode 100644 index 00000000..0e5e68a8 --- /dev/null +++ b/templates/ubuntu20/python/python39.dockerfile.j2 @@ -0,0 +1,5 @@ +# setup Python +ENV VIRTUAL_ENV=/opt/venv +RUN python3.9 -m venv $VIRTUAL_ENV +ENV PATH=$VIRTUAL_ENV/bin:$PATH +RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools \ No newline at end of file