From c0d2eb4f91dd949e75389b84a9df35239ff771a1 Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Sat, 3 Jul 2021 23:44:30 +0200 Subject: [PATCH 1/9] Add circleci CI for arm64. --- .circleci/config.yml | 32 +++++++++++++- build_tools/circle/build_test_arm.sh | 66 ++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) create mode 100755 build_tools/circle/build_test_arm.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index f4ee4e4cf1dfb..286d5e9b45de2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,4 @@ -version: 2 +version: 2.1 jobs: doc-min-dependencies: @@ -128,6 +128,33 @@ jobs: - ~/.ccache - ~/.cache/pip + arm64: + machine: + image: ubuntu-2004:202101-01 + resource_class: arm.medium + environment: + - CYTHON_VERSION: 'latest' + - JOBLIB_VERSION: 'latest' + - THREADPOOLCTL_VERSION: 'latest' + - PYTEST_VERSION: 'latest' + - PYTEST_XDIST_VERSION: 'latest' + - TEST_DOCSTRINGS: 'true' + steps: + - checkout + - run: ./build_tools/circle/checkout_merge_commit.sh + - restore_cache: + key: v1-datasets-{{ .Branch }} + - run: ./build_tools/circle/build_test_arm.sh + - save_cache: + key: doc-ccache-{{ .Branch }}-{{ .BuildNum }} + paths: + - ~/.ccache + - ~/.cache/pip + - save_cache: + key: v1-datasets-{{ .Branch }} + paths: + - ~/scikit_learn_data + deploy: docker: - image: circleci/python:3.7 @@ -174,3 +201,6 @@ workflows: - main jobs: - pypy3 + arm64: + jobs: + - arm64 diff --git a/build_tools/circle/build_test_arm.sh b/build_tools/circle/build_test_arm.sh new file mode 100755 index 0000000000000..a1d714adc813f --- /dev/null +++ b/build_tools/circle/build_test_arm.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +set -e +set -x + +UNAMESTR=`uname` + +setup_ccache() { + echo "Setting up ccache" + mkdir /tmp/ccache/ + which ccache + for name in gcc g++ cc c++ x86_64-linux-gnu-gcc x86_64-linux-gnu-c++; do + ln -s $(which ccache) "/tmp/ccache/${name}" + done + export PATH="/tmp/ccache/:${PATH}" + ccache -M 256M +} + +# imports get_dep +source build_tools/shared.sh + +sudo add-apt-repository --remove ppa:ubuntu-toolchain-r/test +sudo apt-get update +sudo apt-get install python3-scipy python3-matplotlib libatlas3-base libatlas-base-dev python3-virtualenv ccache +python3 -m virtualenv --system-site-packages --python=python3 testenv +source testenv/bin/activate +setup_ccache +python -m pip install $(get_dep cython $CYTHON_VERSION) \ + $(get_dep joblib $JOBLIB_VERSION) +python -m pip install $(get_dep threadpoolctl $THREADPOOLCTL_VERSION) \ + $(get_dep pytest $PYTEST_VERSION) \ + $(get_dep pytest-xdist $PYTEST_XDIST_VERSION) + +if [[ "$COVERAGE" == "true" ]]; then + python -m pip install codecov pytest-cov +fi + +if [[ "$PYTEST_XDIST_VERSION" != "none" ]]; then + python -m pip install pytest-xdist +fi + +if [[ "$TEST_DOCSTRINGS" == "true" ]]; then + # numpydoc requires sphinx + python -m pip install sphinx + python -m pip install numpydoc +fi + +python --version + +# Set parallelism to 3 to overlap IO bound tasks with CPU bound tasks on CI +# workers with 2 cores when building the compiled extensions of scikit-learn. +export SKLEARN_BUILD_PARALLEL=3 + +python -m pip list +pip install --verbose --editable . +ccache -s +python -c "import numpy; print('numpy %s' % numpy.__version__)" +python -c "import scipy; print('scipy %s' % scipy.__version__)" +python -c "\ +try: + import pandas + print('pandas %s' % pandas.__version__) +except ImportError: + print('pandas not installed') +" +python -m pytest sklearn From 5471a80455345a653cd75db64aa7a40a3df781c4 Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Mon, 5 Jul 2021 19:18:17 +0200 Subject: [PATCH 2/9] Update documentation and arm64 trigger. Build against openblas. --- .circleci/config.yml | 2 ++ .travis.yml | 9 --------- build_tools/circle/build_test_arm.sh | 3 ++- doc/developers/contributing.rst | 1 - 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 286d5e9b45de2..1fce0f1383485 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -133,6 +133,8 @@ jobs: image: ubuntu-2004:202101-01 resource_class: arm.medium environment: + - OMP_NUM_THREADS: 2 + - OPENBLAS_NUM_THREADS: 2 - CYTHON_VERSION: 'latest' - JOBLIB_VERSION: 'latest' - THREADPOOLCTL_VERSION: 'latest' diff --git a/.travis.yml b/.travis.yml index 09f05b57eecfa..328940a165fee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,15 +30,6 @@ env: jobs: include: - # Manual trigger of linux/arm64 tests in PR without triggering the full - # wheel building process for all the Python versions. - - python: 3.9 - os: linux - arch: arm64 - if: commit_message =~ /\[arm64\]/ - env: - - CPU_COUNT=4 - # Linux environments to build the scikit-learn wheels for the ARM64 # architecture and Python 3.7 and newer. This is used both at release time # with the manual trigger in the commit message in the release branch and as diff --git a/build_tools/circle/build_test_arm.sh b/build_tools/circle/build_test_arm.sh index a1d714adc813f..0336e8a373cb8 100755 --- a/build_tools/circle/build_test_arm.sh +++ b/build_tools/circle/build_test_arm.sh @@ -21,7 +21,8 @@ source build_tools/shared.sh sudo add-apt-repository --remove ppa:ubuntu-toolchain-r/test sudo apt-get update -sudo apt-get install python3-scipy python3-matplotlib libatlas3-base libatlas-base-dev python3-virtualenv ccache +sudo apt-get install python3-scipy python3-matplotlib libopenblas-base \ + python3-virtualenv ccache python3 -m virtualenv --system-site-packages --python=python3 testenv source testenv/bin/activate setup_ccache diff --git a/doc/developers/contributing.rst b/doc/developers/contributing.rst index bfa3b98f889f1..96a89f31375e1 100644 --- a/doc/developers/contributing.rst +++ b/doc/developers/contributing.rst @@ -560,7 +560,6 @@ message, the following actions are taken. [lint skip] Azure pipeline skips linting [scipy-dev] Add a Travis build with our dependencies (numpy, scipy, etc ...) development builds [icc-build] Add a Travis build with the Intel C compiler (ICC) - [arm64] Add a Travis build for the ARM64 / aarch64 little endian architecture [doc skip] Docs are not built [doc quick] Docs built, but excludes example gallery plots [doc build] Docs built including example gallery plots (very long) From 8d400ad90d65ce6d863d40a3803ce3320478c17a Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Mon, 5 Jul 2021 19:30:27 +0200 Subject: [PATCH 3/9] Update documentation. --- doc/developers/contributing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/developers/contributing.rst b/doc/developers/contributing.rst index 96a89f31375e1..0e993e22f3d48 100644 --- a/doc/developers/contributing.rst +++ b/doc/developers/contributing.rst @@ -547,7 +547,7 @@ Continuous Integration (CI) * Azure pipelines are used for testing scikit-learn on Linux, Mac and Windows, with different dependencies and settings. * CircleCI is used to build the docs for viewing, for linting with flake8, and - for testing with PyPy on Linux + for testing with PyPy and ARM64 / aarch64 on Linux Please note that if one of the following markers appear in the latest commit message, the following actions are taken. From 6156e9f32c46cd41023aa64b74f0ca507215b64b Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Wed, 21 Jul 2021 15:05:09 +0200 Subject: [PATCH 4/9] Test: change the random seed in failing test. --- sklearn/manifold/tests/test_locally_linear.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/manifold/tests/test_locally_linear.py b/sklearn/manifold/tests/test_locally_linear.py index 0853382224170..02f3a4a8b16c5 100644 --- a/sklearn/manifold/tests/test_locally_linear.py +++ b/sklearn/manifold/tests/test_locally_linear.py @@ -36,7 +36,7 @@ def test_barycenter_kneighbors_graph(): def test_lle_simple_grid(): # note: ARPACK is numerically unstable, so this test will fail for # some random seeds. We choose 2 because the tests pass. - rng = np.random.RandomState(2) + rng = np.random.RandomState(42) # grid of equidistant points in 2D, n_components = n_dim X = np.array(list(product(range(5), repeat=2))) From a6cb5270bad854caa50415df4e09d27fa860de5b Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Wed, 21 Jul 2021 18:21:17 +0200 Subject: [PATCH 5/9] Update comment about random seed. --- sklearn/manifold/tests/test_locally_linear.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sklearn/manifold/tests/test_locally_linear.py b/sklearn/manifold/tests/test_locally_linear.py index 02f3a4a8b16c5..73bc9b9885f89 100644 --- a/sklearn/manifold/tests/test_locally_linear.py +++ b/sklearn/manifold/tests/test_locally_linear.py @@ -35,7 +35,8 @@ def test_barycenter_kneighbors_graph(): def test_lle_simple_grid(): # note: ARPACK is numerically unstable, so this test will fail for - # some random seeds. We choose 2 because the tests pass. + # some random seeds. We choose 42 because the tests pass. + # for arm64 platforms 2 makes the test fail. rng = np.random.RandomState(42) # grid of equidistant points in 2D, n_components = n_dim From a3e78a365524e1c13ca9d7f1ca7f0538910ea869 Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Fri, 30 Jul 2021 18:04:38 +0200 Subject: [PATCH 6/9] Address comments. --- .circleci/config.yml | 2 +- build_tools/circle/build_test_arm.sh | 15 ++++----------- sklearn/manifold/tests/test_locally_linear.py | 2 ++ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b14f08ab6cd91..d29f285d264e1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -130,7 +130,7 @@ jobs: - ~/.ccache - ~/.cache/pip - arm64: + linux-arm64: machine: image: ubuntu-2004:202101-01 resource_class: arm.medium diff --git a/build_tools/circle/build_test_arm.sh b/build_tools/circle/build_test_arm.sh index 0336e8a373cb8..3d555f66227c4 100755 --- a/build_tools/circle/build_test_arm.sh +++ b/build_tools/circle/build_test_arm.sh @@ -21,10 +21,10 @@ source build_tools/shared.sh sudo add-apt-repository --remove ppa:ubuntu-toolchain-r/test sudo apt-get update -sudo apt-get install python3-scipy python3-matplotlib libopenblas-base \ - python3-virtualenv ccache +sudo apt-get install python3-virtualenv ccache python3 -m virtualenv --system-site-packages --python=python3 testenv source testenv/bin/activate +pip install --upgrade pip setup_ccache python -m pip install $(get_dep cython $CYTHON_VERSION) \ $(get_dep joblib $JOBLIB_VERSION) @@ -55,13 +55,6 @@ export SKLEARN_BUILD_PARALLEL=3 python -m pip list pip install --verbose --editable . ccache -s -python -c "import numpy; print('numpy %s' % numpy.__version__)" -python -c "import scipy; print('scipy %s' % scipy.__version__)" -python -c "\ -try: - import pandas - print('pandas %s' % pandas.__version__) -except ImportError: - print('pandas not installed') -" +python -c "import sklearn; sklearn.show_versions()" +python -m threadpoolctl --import sklearn python -m pytest sklearn diff --git a/sklearn/manifold/tests/test_locally_linear.py b/sklearn/manifold/tests/test_locally_linear.py index 73bc9b9885f89..520ba00df2e09 100644 --- a/sklearn/manifold/tests/test_locally_linear.py +++ b/sklearn/manifold/tests/test_locally_linear.py @@ -37,6 +37,8 @@ def test_lle_simple_grid(): # note: ARPACK is numerically unstable, so this test will fail for # some random seeds. We choose 42 because the tests pass. # for arm64 platforms 2 makes the test fail. + # TODO: rewrite this test to make less sensitive to the random seed, + # irrespective of the platform. rng = np.random.RandomState(42) # grid of equidistant points in 2D, n_components = n_dim From a268f8df3ab8db78902b43f2a00ef33a6c2a1bfe Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Sun, 1 Aug 2021 14:28:15 +0200 Subject: [PATCH 7/9] Update .circleci/config.yml Co-authored-by: Olivier Grisel --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d29f285d264e1..b730ae0ff595a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -205,6 +205,6 @@ workflows: - main jobs: - pypy3 - arm64: + linux-arm64: jobs: - - arm64 + - linux-arm64 From 0587ac384cbf2d6909862d7c6f94c1e751aaa6aa Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Wed, 4 Aug 2021 14:19:38 +0200 Subject: [PATCH 8/9] Apply suggestions from code review --- build_tools/circle/build_test_arm.sh | 1 + sklearn/manifold/tests/test_locally_linear.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/build_tools/circle/build_test_arm.sh b/build_tools/circle/build_test_arm.sh index 3d555f66227c4..f38f5dcd273d5 100755 --- a/build_tools/circle/build_test_arm.sh +++ b/build_tools/circle/build_test_arm.sh @@ -57,4 +57,5 @@ pip install --verbose --editable . ccache -s python -c "import sklearn; sklearn.show_versions()" python -m threadpoolctl --import sklearn +python -m threadpoolctl --import sklearn python -m pytest sklearn diff --git a/sklearn/manifold/tests/test_locally_linear.py b/sklearn/manifold/tests/test_locally_linear.py index 520ba00df2e09..2a019b7054f0a 100644 --- a/sklearn/manifold/tests/test_locally_linear.py +++ b/sklearn/manifold/tests/test_locally_linear.py @@ -39,6 +39,8 @@ def test_lle_simple_grid(): # for arm64 platforms 2 makes the test fail. # TODO: rewrite this test to make less sensitive to the random seed, # irrespective of the platform. + # TODO: rewrite this test to make less sensitive to the random seed, + # irrespective of the platform. rng = np.random.RandomState(42) # grid of equidistant points in 2D, n_components = n_dim From 1b6257937d6c48a72d111b0f9068c9413cc36108 Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Wed, 4 Aug 2021 14:24:22 +0200 Subject: [PATCH 9/9] Clean-up duplicated lines and trigger [arm64] --- build_tools/circle/build_test_arm.sh | 1 - sklearn/manifold/tests/test_locally_linear.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/build_tools/circle/build_test_arm.sh b/build_tools/circle/build_test_arm.sh index f38f5dcd273d5..3d555f66227c4 100755 --- a/build_tools/circle/build_test_arm.sh +++ b/build_tools/circle/build_test_arm.sh @@ -57,5 +57,4 @@ pip install --verbose --editable . ccache -s python -c "import sklearn; sklearn.show_versions()" python -m threadpoolctl --import sklearn -python -m threadpoolctl --import sklearn python -m pytest sklearn diff --git a/sklearn/manifold/tests/test_locally_linear.py b/sklearn/manifold/tests/test_locally_linear.py index 2a019b7054f0a..520ba00df2e09 100644 --- a/sklearn/manifold/tests/test_locally_linear.py +++ b/sklearn/manifold/tests/test_locally_linear.py @@ -39,8 +39,6 @@ def test_lle_simple_grid(): # for arm64 platforms 2 makes the test fail. # TODO: rewrite this test to make less sensitive to the random seed, # irrespective of the platform. - # TODO: rewrite this test to make less sensitive to the random seed, - # irrespective of the platform. rng = np.random.RandomState(42) # grid of equidistant points in 2D, n_components = n_dim