From 5ec441733dc91370985164c24a94d0a7e90d3aab Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Thu, 23 Jan 2020 14:39:50 +0100 Subject: [PATCH 01/15] compile test program with same compiler as will be used to compile sklearn + support icc linux openmp flag --- azure-pipelines.yml | 1 + build_tools/azure/install.sh | 22 ++++++++++++++---- build_tools/azure/test_docs.sh | 4 ++++ build_tools/azure/test_script.sh | 4 ++++ sklearn/_build_utils/openmp_helpers.py | 4 +++- sklearn/_build_utils/pre_build_helpers.py | 28 +++++++++++++++++++++-- 6 files changed, 56 insertions(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b029a2fd18574..632b093942d26 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -40,6 +40,7 @@ jobs: PYTEST_VERSION: '*' JOBLIB_VERSION: '*' COVERAGE: 'true' + BUILD_WITH_ICC: 'true' - template: build_tools/azure/posix.yml parameters: diff --git a/build_tools/azure/install.sh b/build_tools/azure/install.sh index 1ef981b5dd6e8..a6f332135f8f8 100755 --- a/build_tools/azure/install.sh +++ b/build_tools/azure/install.sh @@ -120,7 +120,21 @@ except ImportError: " python -m pip list -# Use setup.py instead of `pip install -e .` to be able to pass the -j flag -# to speed-up the building multicore CI machines. -python setup.py build_ext --inplace -j 3 -python setup.py develop +if [[ "$BUILD_WITH_ICC" == "true" ]]; then + wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" + sudo apt-get update + sudo apt-get install intel-oneapi-icc + source /opt/intel/inteloneapi/setvars.sh + + python setup.py build_ext --compiler=intelem -i -j 3 build_clib --compiler=intelem + python setup.py develop +else + # Use setup.py instead of `pip install -e .` to be able to pass the -j flag + # to speed-up the building multicore CI machines. + python setup.py build_ext --inplace -j 3 + python setup.py develop +fi + diff --git a/build_tools/azure/test_docs.sh b/build_tools/azure/test_docs.sh index b3a5ec97c4d6a..fc1bd988cc9b7 100755 --- a/build_tools/azure/test_docs.sh +++ b/build_tools/azure/test_docs.sh @@ -8,4 +8,8 @@ elif [[ "$DISTRIB" == "ubuntu" ]]; then source $VIRTUALENV/bin/activate fi +if [[ "$BUILD_WITH_ICC" == "true" ]]; then + source /opt/intel/inteloneapi/setvars.sh +fi + make test-doc diff --git a/build_tools/azure/test_script.sh b/build_tools/azure/test_script.sh index 77a950d86549c..8caaf2bb3ef0f 100755 --- a/build_tools/azure/test_script.sh +++ b/build_tools/azure/test_script.sh @@ -8,6 +8,10 @@ elif [[ "$DISTRIB" == "ubuntu" ]] || [[ "$DISTRIB" == "ubuntu-32" ]]; then source $VIRTUALENV/bin/activate fi +if [[ "$BUILD_WITH_ICC" == "true" ]]; then + source /opt/intel/inteloneapi/setvars.sh +fi + python --version python -c "import numpy; print('numpy %s' % numpy.__version__)" python -c "import scipy; print('scipy %s' % scipy.__version__)" diff --git a/sklearn/_build_utils/openmp_helpers.py b/sklearn/_build_utils/openmp_helpers.py index d4c377c67e05f..63e185debb00e 100644 --- a/sklearn/_build_utils/openmp_helpers.py +++ b/sklearn/_build_utils/openmp_helpers.py @@ -1,7 +1,7 @@ """Helpers for OpenMP support during the build.""" # This code is adapted for a large part from the astropy openmp helpers, which -# can be found at: https://github.com/astropy/astropy-helpers/blob/master/astropy_helpers/openmp_helpers.py # noqa +# can be found at: https://github.com/astropy/extension-helpers/blob/master/extension_helpers/_openmp_helpers.py # noqa import os @@ -40,6 +40,8 @@ def get_openmp_flag(compiler): # export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/local/opt/libomp/lib # -L/usr/local/opt/libomp/lib -lomp" return [] + elif sys.platform == "linux" and "icc" in compiler: + return ['-qopenmp'] # Default flag for GCC and clang: return ['-fopenmp'] diff --git a/sklearn/_build_utils/pre_build_helpers.py b/sklearn/_build_utils/pre_build_helpers.py index bc3d83257dd7e..6b495af0faff3 100644 --- a/sklearn/_build_utils/pre_build_helpers.py +++ b/sklearn/_build_utils/pre_build_helpers.py @@ -7,14 +7,38 @@ import textwrap import subprocess +from distutils.dist import Distribution from distutils.sysconfig import customize_compiler from numpy.distutils.ccompiler import new_compiler +def _get_compiler(): + """Get a compiler equivalent to the one that will be used to build sklearn + + Handles compiler specified as follows: + - python setup.py build_ext --compiler= + - CC= python setup.py build_ext + """ + dist = Distribution({'script_name': os.path.basename(sys.argv[0]), + 'script_args': sys.argv[1:]}) + dist.parse_config_files() + dist.parse_command_line() + + cmd_opts = dist.command_options.get('build_ext') + if cmd_opts is not None and 'compiler' in cmd_opts: + compiler = cmd_opts['compiler'][1] + else: + compiler = None + + ccompiler = new_compiler(compiler=compiler) + customize_compiler(ccompiler) + + return ccompiler + + def compile_test_program(code, extra_preargs=[], extra_postargs=[]): """Check that some C code can be compiled and run""" - ccompiler = new_compiler() - customize_compiler(ccompiler) + ccompiler = _get_compiler() # extra_(pre/post)args can be a callable to make it possible to get its # value from the compiler From c57451c8caa9b2dfb998955e422596b0017127f8 Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Fri, 24 Jan 2020 13:59:25 +0100 Subject: [PATCH 02/15] trigger ci From 256be7f0f5a41e9c3db0c3be7664a3e8cfbf90c7 Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Fri, 24 Jan 2020 14:27:33 +0100 Subject: [PATCH 03/15] trigger ci From 7d0d40eb2bdb98d906898d7719d0d3fb5f267447 Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Mon, 27 Jan 2020 11:15:03 +0100 Subject: [PATCH 04/15] openmp flag for icc on linux and macos --- sklearn/_build_utils/openmp_helpers.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sklearn/_build_utils/openmp_helpers.py b/sklearn/_build_utils/openmp_helpers.py index 63e185debb00e..2d1b92c4e7298 100644 --- a/sklearn/_build_utils/openmp_helpers.py +++ b/sklearn/_build_utils/openmp_helpers.py @@ -25,8 +25,8 @@ def get_openmp_flag(compiler): return ['/Qopenmp'] elif sys.platform == "win32": return ['/openmp'] - elif sys.platform == "darwin" and ('icc' in compiler or 'icl' in compiler): - return ['-openmp'] + elif sys.platform in ("darwin", "linux") and "icc" in compiler: + return ['-qopenmp'] elif sys.platform == "darwin" and 'openmp' in os.getenv('CPPFLAGS', ''): # -fopenmp can't be passed as compile flag when using Apple-clang. # OpenMP support has to be enabled during preprocessing. @@ -40,8 +40,6 @@ def get_openmp_flag(compiler): # export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/local/opt/libomp/lib # -L/usr/local/opt/libomp/lib -lomp" return [] - elif sys.platform == "linux" and "icc" in compiler: - return ['-qopenmp'] # Default flag for GCC and clang: return ['-fopenmp'] From 3068d0009e8c40074ece1a911c733e580820657e Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Mon, 27 Jan 2020 15:19:32 +0100 Subject: [PATCH 05/15] icc on cron job --- .travis.yml | 10 ++++++++-- build_tools/azure/install.sh | 22 ++++------------------ build_tools/azure/test_docs.sh | 4 ---- build_tools/azure/test_script.sh | 4 ---- build_tools/travis/install.sh | 18 ++++++++++++++++++ build_tools/travis/test_docs.sh | 6 ++++++ build_tools/travis/test_script.sh | 6 ++++++ 7 files changed, 42 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9fda90f71a7c0..758a53f18b04b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,8 +22,14 @@ matrix: # installed from their CI wheels in a virtualenv with the Python # interpreter provided by travis. - python: 3.7 - env: CHECK_WARNINGS="true" - if: type = cron OR commit_message =~ /\[scipy-dev\]/ + env: CHECK_WARNINGS="true" + if: type = cron OR commit_message =~ /\[scipy-dev\]/ + + - python: 3.7 + env: + - CHECK_WARNING="true" + - BUILD_WITH_ICC="true" + if: type = cron OR commit_message =~ /\[scipy-dev\]/ install: source build_tools/travis/install.sh script: diff --git a/build_tools/azure/install.sh b/build_tools/azure/install.sh index a6f332135f8f8..1ef981b5dd6e8 100755 --- a/build_tools/azure/install.sh +++ b/build_tools/azure/install.sh @@ -120,21 +120,7 @@ except ImportError: " python -m pip list -if [[ "$BUILD_WITH_ICC" == "true" ]]; then - wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB - sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB - rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB - sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" - sudo apt-get update - sudo apt-get install intel-oneapi-icc - source /opt/intel/inteloneapi/setvars.sh - - python setup.py build_ext --compiler=intelem -i -j 3 build_clib --compiler=intelem - python setup.py develop -else - # Use setup.py instead of `pip install -e .` to be able to pass the -j flag - # to speed-up the building multicore CI machines. - python setup.py build_ext --inplace -j 3 - python setup.py develop -fi - +# Use setup.py instead of `pip install -e .` to be able to pass the -j flag +# to speed-up the building multicore CI machines. +python setup.py build_ext --inplace -j 3 +python setup.py develop diff --git a/build_tools/azure/test_docs.sh b/build_tools/azure/test_docs.sh index fc1bd988cc9b7..b3a5ec97c4d6a 100755 --- a/build_tools/azure/test_docs.sh +++ b/build_tools/azure/test_docs.sh @@ -8,8 +8,4 @@ elif [[ "$DISTRIB" == "ubuntu" ]]; then source $VIRTUALENV/bin/activate fi -if [[ "$BUILD_WITH_ICC" == "true" ]]; then - source /opt/intel/inteloneapi/setvars.sh -fi - make test-doc diff --git a/build_tools/azure/test_script.sh b/build_tools/azure/test_script.sh index 8caaf2bb3ef0f..77a950d86549c 100755 --- a/build_tools/azure/test_script.sh +++ b/build_tools/azure/test_script.sh @@ -8,10 +8,6 @@ elif [[ "$DISTRIB" == "ubuntu" ]] || [[ "$DISTRIB" == "ubuntu-32" ]]; then source $VIRTUALENV/bin/activate fi -if [[ "$BUILD_WITH_ICC" == "true" ]]; then - source /opt/intel/inteloneapi/setvars.sh -fi - python --version python -c "import numpy; print('numpy %s' % numpy.__version__)" python -c "import scipy; print('scipy %s' % scipy.__version__)" diff --git a/build_tools/travis/install.sh b/build_tools/travis/install.sh index 6bb15b3f539e1..f20bed2a9b2e0 100755 --- a/build_tools/travis/install.sh +++ b/build_tools/travis/install.sh @@ -60,6 +60,24 @@ python --version python -c "import numpy; print('numpy %s' % numpy.__version__)" python -c "import scipy; print('scipy %s' % scipy.__version__)" +if [[ "$BUILD_WITH_ICC" == "true" ]]; then + wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" + sudo apt-get update + sudo apt-get install intel-oneapi-icc + source /opt/intel/inteloneapi/setvars.sh + + # The build_clib command is implicitly used to build libsvm-skl. To compile + # with a different compiler we also need to specify the compiler for this + # command. + python setup.py build_ext --compiler=intelem -i -j 3 build_clib --compiler=intelem +else + # Use setup.py instead of `pip install -e .` to be able to pass the -j flag + # to speed-up the building multicore CI machines. + python setup.py build_ext --inplace -j 3 + python setup.py develop ccache --show-stats diff --git a/build_tools/travis/test_docs.sh b/build_tools/travis/test_docs.sh index d43b480fa79f9..d70aca3249321 100755 --- a/build_tools/travis/test_docs.sh +++ b/build_tools/travis/test_docs.sh @@ -3,4 +3,10 @@ set -e set -x +if [[ "$BUILD_WITH_ICC" == "true" ]]; then + # the tools in the oneAPI toolkits are configured via environment variables + # which are also required at runtime. + source /opt/intel/inteloneapi/setvars.sh +fi + make test-doc diff --git a/build_tools/travis/test_script.sh b/build_tools/travis/test_script.sh index f13e0f1bbb2fa..ed111d80a5c12 100755 --- a/build_tools/travis/test_script.sh +++ b/build_tools/travis/test_script.sh @@ -20,6 +20,12 @@ except ImportError: " python -c "import multiprocessing as mp; print('%d CPUs' % mp.cpu_count())" +if [[ "$BUILD_WITH_ICC" == "true" ]]; then + # the tools in the oneAPI toolkits are configured via environment variables + # which are also required at runtime. + source /opt/intel/inteloneapi/setvars.sh +fi + run_tests() { TEST_CMD="pytest --showlocals --durations=20 --pyargs" From a8d4df91b3544dea8c4838bdbca331d88ffd7b2e Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Mon, 27 Jan 2020 15:20:08 +0100 Subject: [PATCH 06/15] tst [scipy-dev] From 23eb9f2d6073175ffec6927908cd1e5d6d97fcfd Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Mon, 27 Jan 2020 15:26:40 +0100 Subject: [PATCH 07/15] [scipy-dev] tst From 51805427289f5fb9b06a0f23ceeaefc11915f117 Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Mon, 27 Jan 2020 15:29:01 +0100 Subject: [PATCH 08/15] [scipy-dev] cln --- azure-pipelines.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 632b093942d26..b029a2fd18574 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -40,7 +40,6 @@ jobs: PYTEST_VERSION: '*' JOBLIB_VERSION: '*' COVERAGE: 'true' - BUILD_WITH_ICC: 'true' - template: build_tools/azure/posix.yml parameters: From fa29257dd2eca9a6ae9fd1097fa8aae285e04454 Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Mon, 27 Jan 2020 15:39:29 +0100 Subject: [PATCH 09/15] [scipy-dev] fix yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 758a53f18b04b..cdcde79927bed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,14 +21,14 @@ matrix: # Linux environment to test scikit-learn against numpy and scipy master # installed from their CI wheels in a virtualenv with the Python # interpreter provided by travis. - - python: 3.7 + - python: 3.7 env: CHECK_WARNINGS="true" if: type = cron OR commit_message =~ /\[scipy-dev\]/ - python: 3.7 env: - - CHECK_WARNING="true" - - BUILD_WITH_ICC="true" + - CHECK_WARNING="true" + - BUILD_WITH_ICC="true" if: type = cron OR commit_message =~ /\[scipy-dev\]/ install: source build_tools/travis/install.sh From b3b3a71e0591f2b97ed8d2e151134afb5ab57f99 Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Mon, 27 Jan 2020 15:42:41 +0100 Subject: [PATCH 10/15] [scipy-dev] tst --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cdcde79927bed..d9acb27863572 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,8 @@ matrix: if: type = cron OR commit_message =~ /\[scipy-dev\]/ - python: 3.7 - env: - - CHECK_WARNING="true" - - BUILD_WITH_ICC="true" + env: CHECK_WARNING="true" + # - BUILD_WITH_ICC="true" if: type = cron OR commit_message =~ /\[scipy-dev\]/ install: source build_tools/travis/install.sh From 386de12d8cd1babaa696e99935e780e714845c32 Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Mon, 27 Jan 2020 15:44:17 +0100 Subject: [PATCH 11/15] tst [scipy-dev] --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d9acb27863572..436abab44607b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,10 +25,10 @@ matrix: env: CHECK_WARNINGS="true" if: type = cron OR commit_message =~ /\[scipy-dev\]/ - - python: 3.7 - env: CHECK_WARNING="true" - # - BUILD_WITH_ICC="true" - if: type = cron OR commit_message =~ /\[scipy-dev\]/ + # - python: 3.7 + # env: CHECK_WARNING="true" + # # - BUILD_WITH_ICC="true" + # if: type = cron OR commit_message =~ /\[scipy-dev\]/ install: source build_tools/travis/install.sh script: From 40b3415b298fe1104f18e7fc57e09f223fbbd27c Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Mon, 27 Jan 2020 15:45:41 +0100 Subject: [PATCH 12/15] [scipy-dev] tst --- .travis.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 436abab44607b..ff8c6b7d2f947 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,13 +22,14 @@ matrix: # installed from their CI wheels in a virtualenv with the Python # interpreter provided by travis. - python: 3.7 - env: CHECK_WARNINGS="true" - if: type = cron OR commit_message =~ /\[scipy-dev\]/ + env: CHECK_WARNINGS="true" + if: type = cron OR commit_message =~ /\[scipy-dev\]/ - # - python: 3.7 - # env: CHECK_WARNING="true" - # # - BUILD_WITH_ICC="true" - # if: type = cron OR commit_message =~ /\[scipy-dev\]/ + - python: 3.7 + env: + - CHECK_WARNING="true" + - BUILD_WITH_ICC="true" + if: type = cron OR commit_message =~ /\[scipy-dev\]/ install: source build_tools/travis/install.sh script: From 874ed98fea5d1ef752140be534502033acbc7014 Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Mon, 27 Jan 2020 15:49:48 +0100 Subject: [PATCH 13/15] [scipy-dev] fix install script --- build_tools/travis/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build_tools/travis/install.sh b/build_tools/travis/install.sh index f20bed2a9b2e0..c6a34af23d549 100755 --- a/build_tools/travis/install.sh +++ b/build_tools/travis/install.sh @@ -77,6 +77,7 @@ else # Use setup.py instead of `pip install -e .` to be able to pass the -j flag # to speed-up the building multicore CI machines. python setup.py build_ext --inplace -j 3 +fi python setup.py develop From 11a2b55bc4c26c097eab395a5e27712bde859f15 Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Tue, 4 Feb 2020 10:43:45 +0100 Subject: [PATCH 14/15] support config_cc --- sklearn/_build_utils/pre_build_helpers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sklearn/_build_utils/pre_build_helpers.py b/sklearn/_build_utils/pre_build_helpers.py index 6b495af0faff3..322a442ddee39 100644 --- a/sklearn/_build_utils/pre_build_helpers.py +++ b/sklearn/_build_utils/pre_build_helpers.py @@ -10,6 +10,7 @@ from distutils.dist import Distribution from distutils.sysconfig import customize_compiler from numpy.distutils.ccompiler import new_compiler +from numpy.distutils.command.config_compiler import config_cc def _get_compiler(): @@ -20,7 +21,8 @@ def _get_compiler(): - CC= python setup.py build_ext """ dist = Distribution({'script_name': os.path.basename(sys.argv[0]), - 'script_args': sys.argv[1:]}) + 'script_args': sys.argv[1:], + 'cmdclass': {'config_cc': config_cc}}) dist.parse_config_files() dist.parse_command_line() From 661fa48b0b7e9c55e660e633959ecf8efc31b8fe Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Thu, 6 Feb 2020 14:51:11 +0100 Subject: [PATCH 15/15] instructions to build with ICC using oneAPI on Linux --- .travis.yml | 3 +- doc/developers/advanced_installation.rst | 50 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ff8c6b7d2f947..85c017961afaa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,11 +25,12 @@ matrix: env: CHECK_WARNINGS="true" if: type = cron OR commit_message =~ /\[scipy-dev\]/ + # As above but build scikit-learn with Intel C compiler (ICC). - python: 3.7 env: - CHECK_WARNING="true" - BUILD_WITH_ICC="true" - if: type = cron OR commit_message =~ /\[scipy-dev\]/ + if: type = cron OR commit_message =~ /\[icc-build\]/ install: source build_tools/travis/install.sh script: diff --git a/doc/developers/advanced_installation.rst b/doc/developers/advanced_installation.rst index 8fd0f9ecf0273..1ddc26bf0434c 100644 --- a/doc/developers/advanced_installation.rst +++ b/doc/developers/advanced_installation.rst @@ -382,3 +382,53 @@ the base system and these steps will not be necessary. .. _Homebrew: https://brew.sh .. _virtualenv: https://docs.python.org/3/tutorial/venv.html .. _conda environment: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html + +Alternative compilers +===================== + +The command:: + + pip install --verbose --editable . + +will build scikit-learn using your default C/C++ compiler. If you want to build +scikit-learn with another compiler handled by ``distutils`` or by +``numpy.distutils``, use the following command:: + + python setup.py build_ext --compiler= -i build_clib --compiler= + +To see the list of available compilers run:: + + python setup.py build_ext --help-compiler + +If your compiler is not listed here, you can specify it via the ``CC`` and +``LDSHARED`` environment variables (does not work on windows):: + + CC= LDSHARED=" -shared" python setup.py build_ext -i + +Building with Intel C Compiler (ICC) using oneAPI on Linux +---------------------------------------------------------- + +Intel provides access to all of its oneAPI toolkits and packages through a +public APT repository. First you need to get and install the public key of this +repository:: + + wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + +Then, add the oneAPI repository to your APT repositories:: + + sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" + sudo apt-get update + +Install ICC, packaged under the name ``intel-oneapi-icc``:: + + sudo apt-get install intel-oneapi-icc + +Before using ICC, you need to set up environment variables:: + + source /opt/intel/inteloneapi/setvars.sh + +Finally, you can build scikit-learn. For example on Linux x86_64:: + + python setup.py build_ext --compiler=intelem -i build_clib --compiler=intelem