Skip to content

Commit

Permalink
Run all backends compatible with CPU in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharras committed Sep 14, 2023
1 parent 2fabb18 commit 5d9c3a0
Showing 1 changed file with 90 additions and 12 deletions.
102 changes: 90 additions & 12 deletions .github/workflows/test_kmeans_cpu_benchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ env:
_SCIKIT_LEARN_COMMIT: 2ccfc8c4bdf66db005d7681757b4145842944fb9
_BENCHOPT_COMMIT: fc4d7fe6492dacca3d6cb5d512a3a9b3d5f84df5
_SKLEARN_NUMBA_DPEX_COMMIT: e6e901757fced52abee8e1750a5f0004d35b0f3e
_SKLEARN_PYTORCH_ENGINE_COMMIT: e962dea262ba4d6e9873fced395e815a02a17fd0
_KMEANS_DPCPP_COMMIT: dceaa6418463c7921ba56dfcc80e3aeda0bcd5c3

_ONEAPI_INSTALLER_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/992857b9-624c-45de-9701-f6445d845359
_ONEAPI_INSTALL_BINARY_NAME: l_BaseKit_p_2023.2.0.49397.sh
_ONEAPI_COMPONENTS: "intel.oneapi.lin.dpcpp-cpp-compiler:intel.oneapi.lin.mkl.devel"


# TODO: setup runners with compatible gpus and also test gpu benchmarks
Expand All @@ -19,39 +25,102 @@ jobs:
container: jjerphan/numba_dpex_dev:latest

steps:
- name: Install build pre-requisites
- name: Cache scikit-learn and benchopt wheels
id: wheels-cache
uses: actions/cache@v3
with:
path: |
scikit-learn/dist/
benchopt/dist/
key: sklearn-benchopt-${{ env._SCIKIT_LEARN_COMMIT}}

- if: ${{ steps.wheels-cache.outputs.cache-hit != 'true' }}
name: Install build pre-requisites
run: |
apt-get update --quiet
apt-get install -y build-essential python3-dev
pip install cython numpy scipy joblib threadpoolctl build wheel
- name: Build scikit-learn`
- if: ${{ steps.wheels-cache.outputs.cache-hit != 'true' }}
name: Build scikit-learn
run: |
git clone https://github.com/fcharras/scikit-learn -b "feature/engine-api"
git clone https://github.com/fcharras/scikit-learn.git -b "feature/engine-api"
cd scikit-learn
git checkout $_SCIKIT_LEARN_COMMIT
python setup.py bdist_wheel
# NB: building benchopt from source will not be needed after next benchopt release
- name: Build benchopt
- if: ${{ steps.wheels-cache.outputs.cache-hit != 'true' }}
name: Build benchopt
run: |
git clone https://github.com/benchopt/benchopt -b main
git clone https://github.com/benchopt/benchopt.git -b main
cd benchopt
git checkout $_BENCHOPT_COMMIT
python -m build --wheel --outdir dist/
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
name: binaries
path: |
benchopt/dist/
scikit-learn/dist/
retention-days: 14

run_sklearn_numba_dpex_benchmarks:
name: Run sklearn_numba_dpex benchmarks on CPU
needs: build_scikit_learn_and_benchopt
build_kmeans_dpcpp:
name: Build kmeans_dpcpp
runs-on: ubuntu-latest
container: jjerphan/numba_dpex_dev:latest

steps:
- name: Cache kmeans_dpcpp build
id: kmeans-dpcpp-cache
uses: actions/cache@v3
with:
path: kmeans_dpcpp/
key: kmeans-dpcpp-${{ env._KMEANS_DPCPP_COMMIT}}

- if: ${{ steps.kmeans-dpcpp-cache.outputs.cache-hit != 'true' }}
name: Install build pre-requisites
run: |
apt-get update --quiet
apt-get install -y --no-install-recommends gawk
pip install cmake ninja packaging setuptools distro scikit-build numpy
- if: ${{ steps.kmeans-dpcpp-cache.outputs.cache-hit != 'true' }}
name: Install necessary oneapi basekit components
run: |
mkdir -p ./opt/intel/oneapi $RUNNER_TEMP/intel/cache $RUNNER_TEMP/intel/download $RUNNER_TEMP/intel/log
wget -P $RUNNER_TEMP/intel/download $_ONEAPI_INSTALLER_URL/$_ONEAPI_INSTALL_BINARY_NAME
chmod +x $RUNNER_TEMP/intel/download/$_ONEAPI_INSTALL_BINARY_NAME
$RUNNER_TEMP/intel/download/$_ONEAPI_INSTALL_BINARY_NAME -a -s --eula accept \
--action install --components $_ONEAPI_COMPONENTS \
--install-dir ./opt/intel/oneapi --log-dir $RUNNER_TEMP/intel/log \
--download-cache $RUNNER_TEMP/intel/cache \
# HACK: `kmeans_dpcpp` packaging is broken, just run `develop` to build the
# C++ extensions, then later on add it explicitly to PYTHONPATH
- if: ${{ steps.kmeans-dpcpp-cache.outputs.cache-hit != 'true' }}
name: build kmeans_dpcpp
shell: bash
run: |
source ./opt/intel/oneapi/setvars.sh
git clone https://github.com/oleksandr-pavlyk/kmeans_dpcpp.git -b main
cd kmeans_dpcpp
git checkout $_KMEANS_DPCPP_COMMIT
python setup.py develop -- -DCMAKE_CXX_COMPILER:PATH=$(which icpx) -DDPCTL_MODULE_PATH=$(python -m dpctl --cmakedir)
- name: Upload kmeans_dpcpp build files
uses: actions/upload-artifact@v3
with:
name: binaries
path: kmeans_dpcpp*/
retention-days: 14


run_benchmarks_on_cpu:
name: Run benchmarks on cpu
needs: [build_scikit_learn_and_benchopt, build_kmeans_dpcpp]
runs-on: ubuntu-latest
container: jjerphan/numba_dpex_dev:latest

Expand All @@ -62,21 +131,30 @@ jobs:
- name: download scikit-learn and benchopt wheels
uses: actions/download-artifact@v3
with:
name: wheels
name: binaries

# TODO: instead of installing all dependencies of all solvers in the same
# environment, might be more cautious to have one solver per environment ?
- name: install all dependencies
run: |
git clone https://github.com/soda-inria/sklearn-numba-dpex -b main
git clone https://github.com/soda-inria/sklearn-numba-dpex.git -b main
cd sklearn-numba-dpex
git checkout $_SKLEARN_NUMBA_DPEX_COMMIT
cd ../
git clone https://github.com/soda-inria/sklearn-pytorch-engine.git -b main
cd sklearn-pytorch-engine
git checkout $_SKLEARN_PYTORCH_ENGINE_COMMIT
cd ../
# TODO: it seems that non-editable install of sklearn-numba-dpex doesn't work ?
# Fix and update the install command here to avoid having to git clone manually
pip install ../scikit-learn/dist/*.whl ../benchopt/dist/*.whl -e .
pip install ./scikit-learn/dist/*.whl ./benchopt/dist/*.whl scikit-learn-intelex -e ./sklearn-numba-dpex/ -e ./sklearn-pytorch-engine
pip install torch --index-url https://download.pytorch.org/whl/cpu
- name: Check oneapi default device
run: python -c "import dpctl; dpctl.select_default_device().print_device_info()"

- name: Run k-means benchmarks
run: |
export PYTHONPATH=$PYTHONPATH:$(realpath ./kmeans_dpcpp/)
cd benchmarks/kmeans
benchopt run --no-plot -l -d simulated[n_samples=1000,n_features=14]

0 comments on commit 5d9c3a0

Please sign in to comment.