From 5b4c57fd7a0eaa90c18795bb9f1218319ff83bc7 Mon Sep 17 00:00:00 2001 From: Leandro Nunes Date: Fri, 2 Sep 2022 15:47:09 +0100 Subject: [PATCH] [TFLite][CI] Update TensorFlow dependency to 2.9.1 This updates the TF version to be used in TVM CI to 2.9.1, which brings improvements so that more platforms are supported by official packages. When building TFLite, an update to CMake was also required, which is updated now to 3.18.4. ethos-u-vela dependency is also updated, from version 3.2.0 to 3.4.0 so that it is closer to the TensorFlow version being proposed here. This PR updates the Docker images scripting to install TF and TFLite. Change-Id: I290085f0c018ad57606f1295494c19ff6e1af2dd --- cmake/modules/contrib/TFLite.cmake | 2 ++ docker/Dockerfile.ci_cortexm | 3 +++ docker/Dockerfile.ci_cpu | 3 +++ docker/Dockerfile.ci_gpu | 3 +++ docker/Dockerfile.ci_riscv | 3 +++ docker/install/ubuntu_install_cmake_source.sh | 4 ++-- .../install/ubuntu_install_python_package.sh | 2 +- docker/install/ubuntu_install_tensorflow.sh | 5 ++-- .../ubuntu_install_tensorflow_aarch64.sh | 23 ++----------------- docker/install/ubuntu_install_tflite.sh | 13 +++++++++-- docker/install/ubuntu_install_vela.sh | 2 +- docker/install/ubuntu_install_zephyr.sh | 2 +- 12 files changed, 34 insertions(+), 31 deletions(-) diff --git a/cmake/modules/contrib/TFLite.cmake b/cmake/modules/contrib/TFLite.cmake index 31597109095a1..b8d6a0daff195 100644 --- a/cmake/modules/contrib/TFLite.cmake +++ b/cmake/modules/contrib/TFLite.cmake @@ -38,8 +38,10 @@ if(NOT USE_TFLITE STREQUAL "OFF") set(USE_TFLITE ${USE_TENSORFLOW_PATH}/tensorflow/lite/tools/make/gen/*/lib) endif() find_library(TFLITE_CONTRIB_LIB libtensorflow-lite.a ${USE_TFLITE}) + file(GLOB_RECURSE TFLITE_DEPS "${USE_TFLITE}/*.a") list(APPEND TVM_RUNTIME_LINKER_LIBS ${TFLITE_CONTRIB_LIB}) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${TFLITE_DEPS}) if (NOT USE_FLATBUFFERS_PATH STREQUAL "none") include_directories(${USE_FLATBUFFERS_PATH}/include) diff --git a/docker/Dockerfile.ci_cortexm b/docker/Dockerfile.ci_cortexm index 63089f3d65f25..fb3c10d393f08 100644 --- a/docker/Dockerfile.ci_cortexm +++ b/docker/Dockerfile.ci_cortexm @@ -32,6 +32,9 @@ RUN bash /install/ubuntu_install_googletest.sh COPY install/ubuntu1804_install_python.sh /install/ubuntu1804_install_python.sh RUN bash /install/ubuntu1804_install_python.sh +COPY install/ubuntu_install_cmake_source.sh /install/ubuntu_install_cmake_source.sh +RUN bash /install/ubuntu_install_cmake_source.sh + COPY install/ubuntu1804_install_python_venv.sh /install/ubuntu1804_install_python_venv.sh RUN bash /install/ubuntu1804_install_python_venv.sh ENV PATH=/opt/tvm-venv/bin:/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin:$PATH diff --git a/docker/Dockerfile.ci_cpu b/docker/Dockerfile.ci_cpu index 3812bfbd197ee..d9f353d41be1f 100644 --- a/docker/Dockerfile.ci_cpu +++ b/docker/Dockerfile.ci_cpu @@ -40,6 +40,9 @@ RUN bash /install/ubuntu_install_python_package.sh COPY install/ubuntu1804_install_llvm.sh /install/ubuntu1804_install_llvm.sh RUN bash /install/ubuntu1804_install_llvm.sh +COPY install/ubuntu_install_cmake_source.sh /install/ubuntu_install_cmake_source.sh +RUN bash /install/ubuntu_install_cmake_source.sh + COPY install/ubuntu_install_dnnl.sh /install/ubuntu_install_dnnl.sh RUN bash /install/ubuntu_install_dnnl.sh diff --git a/docker/Dockerfile.ci_gpu b/docker/Dockerfile.ci_gpu index f04d8515b8dc2..6f02ab97c09eb 100644 --- a/docker/Dockerfile.ci_gpu +++ b/docker/Dockerfile.ci_gpu @@ -32,6 +32,9 @@ RUN apt-get update --fix-missing COPY install/ubuntu_install_core.sh /install/ubuntu_install_core.sh RUN bash /install/ubuntu_install_core.sh +COPY install/ubuntu_install_cmake_source.sh /install/ubuntu_install_cmake_source.sh +RUN bash /install/ubuntu_install_cmake_source.sh + COPY install/ubuntu_install_googletest.sh /install/ubuntu_install_googletest.sh RUN bash /install/ubuntu_install_googletest.sh diff --git a/docker/Dockerfile.ci_riscv b/docker/Dockerfile.ci_riscv index b65b87a863868..1ca792e20c981 100644 --- a/docker/Dockerfile.ci_riscv +++ b/docker/Dockerfile.ci_riscv @@ -32,6 +32,9 @@ RUN bash /install/ubuntu_install_googletest.sh COPY install/ubuntu1804_install_python.sh /install/ubuntu1804_install_python.sh RUN bash /install/ubuntu1804_install_python.sh +COPY install/ubuntu_install_cmake_source.sh /install/ubuntu_install_cmake_source.sh +RUN bash /install/ubuntu_install_cmake_source.sh + COPY install/ubuntu1804_install_python_venv.sh /install/ubuntu1804_install_python_venv.sh RUN bash /install/ubuntu1804_install_python_venv.sh ENV PATH=/opt/tvm-venv/bin:/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin:$PATH diff --git a/docker/install/ubuntu_install_cmake_source.sh b/docker/install/ubuntu_install_cmake_source.sh index 18335c98c4035..d603f71dcf924 100755 --- a/docker/install/ubuntu_install_cmake_source.sh +++ b/docker/install/ubuntu_install_cmake_source.sh @@ -20,8 +20,8 @@ set -e set -u set -o pipefail -v=3.14 -version=3.14.7 +v=3.22 +version=3.18.4 wget https://cmake.org/files/v${v}/cmake-${version}.tar.gz tar xvf cmake-${version}.tar.gz cd cmake-${version} diff --git a/docker/install/ubuntu_install_python_package.sh b/docker/install/ubuntu_install_python_package.sh index 3fc310c47e34b..9fee9d01425ce 100755 --- a/docker/install/ubuntu_install_python_package.sh +++ b/docker/install/ubuntu_install_python_package.sh @@ -28,7 +28,7 @@ pip3 install --upgrade \ cython \ decorator \ mypy \ - numpy~=1.19.5 \ + numpy==1.21.* \ orderedset \ packaging \ Pillow==9.1.0 \ diff --git a/docker/install/ubuntu_install_tensorflow.sh b/docker/install/ubuntu_install_tensorflow.sh index 17d2b31d9bc24..2225b7aef3b86 100755 --- a/docker/install/ubuntu_install_tensorflow.sh +++ b/docker/install/ubuntu_install_tensorflow.sh @@ -21,6 +21,5 @@ set -u set -o pipefail pip3 install \ - "h5py==3.1.0" \ - keras==2.6 \ - tensorflow==2.6.5 + keras==2.9 \ + tensorflow==2.9.1 diff --git a/docker/install/ubuntu_install_tensorflow_aarch64.sh b/docker/install/ubuntu_install_tensorflow_aarch64.sh index 59cc5b4814b32..09efe5db57070 100755 --- a/docker/install/ubuntu_install_tensorflow_aarch64.sh +++ b/docker/install/ubuntu_install_tensorflow_aarch64.sh @@ -21,27 +21,8 @@ set -euxo pipefail # Build dependencies apt-install-and-clear -y --no-install-recommends libhdf5-dev -# Downloading Tensorflow and installing it manually is needed -# just as a temporary workaround while we move to a newer -# version (>2.7) that is hosted in the official PyPI repository. -linaro_repo="https://snapshots.linaro.org/ldcg/python/tensorflow-manylinux/43/tensorflow-aarch64" -tensorflow_package="tensorflow_aarch64-2.6.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl" -tmpdir=$(mktemp -d) - -cleanup() -{ - rm -rf "$tmpdir" -} - -trap cleanup 0 - -cd "${tmpdir}" -wget -q "${linaro_repo}/${tensorflow_package}" - # We're only using the TensorFlow wheel snapshot here as the # h5py wheel tries to use the wrong .so file pip3 install \ - ${tensorflow_package} \ - "h5py==3.1.0" \ - keras==2.6 \ - "protobuf<4" + keras==2.9 \ + tensorflow-aarch64==2.9.1 diff --git a/docker/install/ubuntu_install_tflite.sh b/docker/install/ubuntu_install_tflite.sh index 8a394302fdd33..4b73c202bc7f7 100755 --- a/docker/install/ubuntu_install_tflite.sh +++ b/docker/install/ubuntu_install_tflite.sh @@ -18,6 +18,7 @@ set -e set -u +set -x set -o pipefail # The tflite version should have matched versions to the tensorflow @@ -38,8 +39,16 @@ pip3 install flatbuffers # The library is built at: # tensorflow/tensorflow/lite/tools/make/gen/*/lib/libtensorflow-lite.a. git clone https://github.com/tensorflow/tensorflow --branch=v${TENSORFLOW_VERSION} --depth 1 -./tensorflow/tensorflow/lite/tools/make/download_dependencies.sh -./tensorflow/tensorflow/lite/tools/make/build_lib.sh + +mkdir -p /opt/tflite +cd /opt/tflite +cmake \ + -DTFLITE_ENABLE_XNNPACK=OFF \ + /tensorflow/tensorflow/lite + +cmake --build . +cd - + # Setup tflite from schema mkdir tflite diff --git a/docker/install/ubuntu_install_vela.sh b/docker/install/ubuntu_install_vela.sh index c72d118233454..9e32889cd4eb1 100755 --- a/docker/install/ubuntu_install_vela.sh +++ b/docker/install/ubuntu_install_vela.sh @@ -20,4 +20,4 @@ set -e set -u set -o pipefail -pip3 install ethos-u-vela==3.2.0 +pip3 install ethos-u-vela==3.4.0 diff --git a/docker/install/ubuntu_install_zephyr.sh b/docker/install/ubuntu_install_zephyr.sh index d25027f007094..7fa30e223cd2e 100755 --- a/docker/install/ubuntu_install_zephyr.sh +++ b/docker/install/ubuntu_install_zephyr.sh @@ -31,7 +31,7 @@ sudo apt-install-and-clear -y --no-install-recommends \ git cmake ninja-build gperf \ ccache dfu-util device-tree-compiler wget \ python3-dev python3-pip python3-setuptools python3-tk python3-wheel python3-venv \ - xz-utils file make gcc gcc-multilib g++-multilib apt-transport-https + xz-utils file make gcc gcc-multilib g++-multilib apt-transport-https libudev-dev wget --no-verbose https://apt.kitware.com/keys/kitware-archive-latest.asc sudo apt-key add kitware-archive-latest.asc