Use standard runners for samples.yml and rework Colab testing. (#17146) Changes: * Switched samples/dynamic_shapes to use `iree-compile` installed from pip rather than build the compiler from source * Switched Colab notebook tests to run natively (not under Docker), (this fixes https://github.com/iree-org/iree/issues/16373) * Disabled experimental web tests pending refactoring work to use installed compiler packages Logs: * Tested at https://github.com/iree-org/iree/actions/runs/8820008530 * Compare timing with history at https://github.com/iree-org/iree/actions/workflows/samples.yml. skip-ci: this only runs nightly
diff --git a/.github/workflows/samples.yml b/.github/workflows/samples.yml index 1448188..d5926fa 100644 --- a/.github/workflows/samples.yml +++ b/.github/workflows/samples.yml
@@ -28,52 +28,63 @@ jobs: colab: - runs-on: ubuntu-20.04-64core + runs-on: ubuntu-20.04 steps: - name: "Checking out repository" uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 + - name: "Setting up Python" + uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 + with: + python-version: '3.11' - name: "Testing Colab Notebooks" - run: | - ./build_tools/github_actions/docker_run.sh \ - gcr.io/iree-oss/samples@sha256:0cb4a27f8fce2e6c9a425b93ecd97bf3c5c3a8ec56929ab7ef005f51d4b1e054 \ - ./samples/colab/test_notebooks.py + run: ./samples/colab/test_notebooks.py samples: - runs-on: ubuntu-20.04-64core + runs-on: ubuntu-20.04 steps: - name: "Checking out repository" uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 - - name: "Testing Samples" + - name: "Checking out runtime submodules" + run: ./build_tools/scripts/git/update_runtime_submodules.sh + - name: "Installing build dependencies" run: | - ./build_tools/github_actions/docker_run.sh \ - gcr.io/iree-oss/samples@sha256:0cb4a27f8fce2e6c9a425b93ecd97bf3c5c3a8ec56929ab7ef005f51d4b1e054 \ - ./build_tools/testing/test_samples.sh - - # FIXME: unify this with host build from ci.yml. This is complicated by - # incompatibility between storage options for GitHub-managed and self-hosted - # runners. - web: - runs-on: ubuntu-20.04-64core - # TODO: remove dependence on magic matching build dir names - env: - HOST_BUILD_DIR: build-host-install - steps: - - name: "Checking out repository" - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 + sudo apt update + sudo apt install cmake clang ninja-build + export CC=clang + export CXX=clang++ + - name: "Setting up Python" + uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 with: - submodules: true - - name: "Building host tools" - run: | - ./build_tools/github_actions/docker_run.sh \ - --env "CCACHE_NAMESPACE=gcr.io/iree-oss/base@sha256:dc314b4fe30fc1315742512891357bffed4d1b62ffcb46258b1e0761c737b446" \ - gcr.io/iree-oss/base@sha256:dc314b4fe30fc1315742512891357bffed4d1b62ffcb46258b1e0761c737b446 \ - ./build_tools/cmake/build_host_tools.sh "${HOST_BUILD_DIR}" - - name: "Testing Experimental Web Samples" - env: - IREE_EMPSCRIPTEN_BUILD_DIR: build-emscripten - run: | - ./build_tools/github_actions/docker_run.sh \ - --env "IREE_HOST_BUILD_DIR=${HOST_BUILD_DIR}" \ - --env "IREE_EMPSCRIPTEN_BUILD_DIR=${IREE_EMPSCRIPTEN_BUILD_DIR}" \ - gcr.io/iree-oss/emscripten@sha256:2dd4c52f1bb499ab365aad0111fe5538b685d88af38636b409b0cf6a576ab214 \ - ./experimental/web/build_and_test_samples.sh + python-version: '3.11' + - name: "Testing Samples" + run: ./build_tools/testing/test_samples.sh + + # TODO(scotttodd): Convert web test scripts to use installed compiler packages and local runtime + # builds, rather than local compiler builds. The host tools are too slow to build + # on standard sized runners (and for casual users). + + # web: + # runs-on: ubuntu-20.04 + # # TODO: remove dependence on magic matching build dir names + # env: + # HOST_BUILD_DIR: build-host-install + # steps: + # - name: "Checking out repository" + # uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 + # with: + # submodules: true + # - name: "Building host tools" + # run: | + # ./build_tools/github_actions/docker_run.sh \ + # --env "CCACHE_NAMESPACE=gcr.io/iree-oss/base@sha256:dc314b4fe30fc1315742512891357bffed4d1b62ffcb46258b1e0761c737b446" \ + # gcr.io/iree-oss/base@sha256:dc314b4fe30fc1315742512891357bffed4d1b62ffcb46258b1e0761c737b446 \ + # ./build_tools/cmake/build_host_tools.sh "${HOST_BUILD_DIR}" + # - name: "Testing Experimental Web Samples" + # env: + # IREE_EMPSCRIPTEN_BUILD_DIR: build-emscripten + # run: | + # ./build_tools/github_actions/docker_run.sh \ + # --env "IREE_HOST_BUILD_DIR=${HOST_BUILD_DIR}" \ + # --env "IREE_EMPSCRIPTEN_BUILD_DIR=${IREE_EMPSCRIPTEN_BUILD_DIR}" \ + # gcr.io/iree-oss/emscripten@sha256:2dd4c52f1bb499ab365aad0111fe5538b685d88af38636b409b0cf6a576ab214 \ + # ./experimental/web/build_and_test_samples.sh
diff --git a/build_tools/docker/dockerfiles/samples.Dockerfile b/build_tools/docker/dockerfiles/samples.Dockerfile deleted file mode 100644 index f3a1114..0000000 --- a/build_tools/docker/dockerfiles/samples.Dockerfile +++ /dev/null
@@ -1,29 +0,0 @@ -# Copyright 2021 The IREE Authors -# -# Licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# An image for running IREE's samples. Includes support for: -# * CMake -# * Python (including `venv` and common pip packages needed for Colab) - -FROM gcr.io/iree-oss/base@sha256:dc314b4fe30fc1315742512891357bffed4d1b62ffcb46258b1e0761c737b446 - -# Install additional packages often used in notebooks. -# Installing these at the system level helps with caching, since venvs can -# set --system-site-packages to use the already installed versions. -# -# Note: -# * Packages relating to TensorFlow are pinned to versions close to what -# Colab includes in its hosted runtimes. We don't need to match all of -# Colab's dependencies, but we should at least make an effort for the ones -# our notebooks use. -# * We explicitly do *not* install Jupyter notebook requirements since they -# should be installed within venvs. -RUN python3 -m pip install --ignore-installed \ - numpy \ - matplotlib \ - bottleneck \ - tensorflow==2.14.0 \ - tensorflow_hub==0.15.0
diff --git a/build_tools/docker/prod_digests.txt b/build_tools/docker/prod_digests.txt index a1b0680..9b4fa14 100644 --- a/build_tools/docker/prod_digests.txt +++ b/build_tools/docker/prod_digests.txt
@@ -1,5 +1,4 @@ gcr.io/iree-oss/base@sha256:dc314b4fe30fc1315742512891357bffed4d1b62ffcb46258b1e0761c737b446 -gcr.io/iree-oss/samples@sha256:0cb4a27f8fce2e6c9a425b93ecd97bf3c5c3a8ec56929ab7ef005f51d4b1e054 gcr.io/iree-oss/riscv@sha256:62e87bad3405d691ddba6f9be0ef44eeb60461a467c8d86f0842c81a1f97da79 gcr.io/iree-oss/nvidia@sha256:82fa00b5cdda1b35634796cd0f88cb5d6d22d80328b94bfb51e5f2820598ba23 gcr.io/iree-oss/emscripten@sha256:2dd4c52f1bb499ab365aad0111fe5538b685d88af38636b409b0cf6a576ab214
diff --git a/build_tools/testing/run_python_notebook.sh b/build_tools/testing/run_python_notebook.sh index e5219ed..4078214 100755 --- a/build_tools/testing/run_python_notebook.sh +++ b/build_tools/testing/run_python_notebook.sh
@@ -10,8 +10,9 @@ # # Usage: run_python_notebook.sh /path/to/notebook.ipynb # -# This is intended for use on continuous integration servers within a Docker -# container and as a reference for users, but it can also be run locally. +# This is intended for use on continuous integration servers (possibly within a +# Docker container) and as a reference for users, but it can also be run +# locally. set -e set -x @@ -43,6 +44,8 @@ jupyter_core nbconvert ipykernel # Install common notebook requirements, reusing system versions if possible. +# To match behavior with online Colab notebooks, the versions used here could +# track closely with https://us-docker.pkg.dev/colab-images/public/runtime. python3 -m pip install --quiet \ numpy \ matplotlib \
diff --git a/build_tools/testing/test_samples.sh b/build_tools/testing/test_samples.sh index 1387a6d..ca12127 100755 --- a/build_tools/testing/test_samples.sh +++ b/build_tools/testing/test_samples.sh
@@ -11,8 +11,5 @@ ROOT_DIR=$(git rev-parse --show-toplevel) cd ${ROOT_DIR?} -git submodule sync -git submodule update --init - ./samples/dynamic_shapes/test.sh ./samples/variables_and_state/test.sh
diff --git a/samples/colab/test_notebooks.py b/samples/colab/test_notebooks.py index a31d43f..ab4496c 100755 --- a/samples/colab/test_notebooks.py +++ b/samples/colab/test_notebooks.py
@@ -16,24 +16,15 @@ # FileNotFoundError: [Errno 2] No such file or directory: 'seaborn-whitegrid' # support level for TF-code and samples is also low "tensorflow_mnist_training.ipynb", - # tflite_runtime requires some deps ("version `GLIBC_2.29' not found") that - # samples.Dockerfile does not currently include. - "tflite_text_classification.ipynb", - # PyTorch notebooks using SHARK-Turbine require Python 3.10+ in Docker. - "pytorch_aot_advanced.ipynb", - "pytorch_aot_simple.ipynb", + # This needs 'transformers' (and possibly other packages) preinstalled. + # Add to run_python_notebook.sh, colab/requirements.txt, or samples.yml? "pytorch_huggingface_whisper.ipynb", - "pytorch_jit.ipynb", ] NOTEBOOKS_EXPECTED_TO_FAIL = [ - # Error: - # ``` - # module 'tensorflow.python.pywrap_mlir' has no attribute - # 'experimental_convert_saved_model_v1' - # ``` - # convert_saved_model_v1 may be broken, but convert_saved_model works? - "tensorflow_hub_import.ipynb", + # Bug in iree-turbine==2.3.0rc20240410 + # `assert issubclass(type(mdl), CompiledModule)` (fixed in 2190a8a) + "pytorch_aot_advanced.ipynb", ]
diff --git a/samples/dynamic_shapes/README.md b/samples/dynamic_shapes/README.md index 2cba5e2..82f7686 100644 --- a/samples/dynamic_shapes/README.md +++ b/samples/dynamic_shapes/README.md
@@ -88,13 +88,13 @@ 1. Run either Colab notebook and download the `dynamic_shapes.mlir` file it generates -2. Build the `iree-compile` tool (see - [here](https://iree.dev/building-from-source/getting-started/) - for general instructions on building using CMake) +2. Get `iree-compile` either by + [building from source](https://iree.dev/building-from-source/getting-started/) + or by + [installing from pip](https://iree.dev/reference/bindings/python/#installing-iree-packages). ``` - cmake -B ../iree-build/ -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo . - cmake --build ../iree-build/ --target iree-compile + python -m pip install iree-compiler ``` 3. Compile the `dynamic_shapes.mlir` file using `iree-compile`. The @@ -102,7 +102,7 @@ has the best support for dynamic shapes: ``` - ../iree-build/tools/iree-compile \ + iree-compile \ --iree-hal-target-backends=llvm-cpu \ dynamic_shapes.mlir -o dynamic_shapes_cpu.vmfb ``` @@ -110,6 +110,7 @@ 4. Build the `iree_samples_dynamic_shapes` CMake target ``` + cmake -B ../iree-build/ -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DIREE_BUILD_COMPILER=OFF . cmake --build ../iree-build/ --target iree_samples_dynamic_shapes ```
diff --git a/samples/dynamic_shapes/test.sh b/samples/dynamic_shapes/test.sh index 2336d04..0f05e08 100755 --- a/samples/dynamic_shapes/test.sh +++ b/samples/dynamic_shapes/test.sh
@@ -23,16 +23,25 @@ ${ROOT_DIR}/samples/dynamic_shapes/tensorflow_dynamic_shapes.ipynb test -f ${ARTIFACTS_DIR}/dynamic_shapes.mlir && echo "dynamic_shapes.mlir exists" -# 2. Build the `iree-compile` tool. -cmake -B ${BUILD_DIR} -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo ${ROOT_DIR} -cmake --build ${BUILD_DIR} --target iree-compile -- -k 0 +# Setup Python venv for step 2. +python3 --version +python3 -m venv .venv +source .venv/bin/activate +trap "deactivate 2> /dev/null" EXIT + +# 2. Install the `iree-compile` tool from pip (or build from source). +python -m pip install \ + --find-links https://iree.dev/pip-release-links.html \ + --upgrade \ + iree-compiler # 3. Compile `dynamic_shapes.mlir` using `iree-compile`. -${BUILD_DIR}/tools/iree-compile \ +iree-compile \ --iree-hal-target-backends=llvm-cpu \ ${ARTIFACTS_DIR}/dynamic_shapes.mlir -o ${ARTIFACTS_DIR}/dynamic_shapes_cpu.vmfb # 4. Build the `iree_samples_dynamic_shapes` CMake target. +cmake -B ${BUILD_DIR} -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DIREE_BUILD_COMPILER=OFF . cmake --build ${BUILD_DIR} --target iree_samples_dynamic_shapes -- -k 0 # 5. Run the sample binary.