Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enh] Conda recipe update and CI OS version pinning #1992

Merged
merged 16 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/pipeline/build-and-test-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ steps:
- script: |
call activate CB
cd ..
call s\conda-recipe\run_test.bat s
call s\conda-recipe\run_test.bat s\
Alexsandruss marked this conversation as resolved.
Show resolved Hide resolved
displayName: 'Sklearnex testing'
- script: |
call activate CB
Expand Down
51 changes: 50 additions & 1 deletion .ci/pipeline/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,55 @@ jobs:
pip install isort black[jupyter]==24.1.1
isort --profile black --check . && black --check .
displayName: 'Linting'
- job: LinuxCondaRecipe
dependsOn: Lint
timeoutInMinutes: 120
strategy:
matrix:
Python3.12:
PYTHON_VERSION: '3.12'
NUMPY_VERSION: '2.1'
pool:
vmImage: 'ubuntu-22.04'
steps:
- script: |
conda config --add channels conda-forge
conda config --set channel_priority strict
conda update -y -q --all
displayName: "Conda update"
- script: |
conda create -y -q -n build-env conda-build conda-verify
displayName: "Conda create"
- script: |
. /usr/share/miniconda/etc/profile.d/conda.sh
conda activate build-env
conda build . --python $(PYTHON_VERSION) --numpy $(NUMPY_VERSION)
displayName: "Conda build and test"
- job: WindowsCondaRecipe
Alexsandruss marked this conversation as resolved.
Show resolved Hide resolved
dependsOn: Lint
timeoutInMinutes: 120
strategy:
matrix:
Python3.12:
PYTHON_VERSION: '3.12'
NUMPY_VERSION: '2.1'
pool:
vmImage: 'windows-2022'
steps:
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
displayName: Add conda to PATH
- script: |
conda config --add channels conda-forge
conda config --set channel_priority strict
conda update -y -q --all
displayName: "Conda update"
- script: |
conda create -y -q -n build-env conda-build conda-verify
displayName: "Conda create"
- script: |
call activate build-env
conda build . --python $(PYTHON_VERSION) --numpy $(NUMPY_VERSION)
displayName: "Conda build and test"
- job: LinuxCondaEnv
dependsOn: Lint
timeoutInMinutes: 120
Expand Down Expand Up @@ -108,6 +157,6 @@ jobs:
PYTHON_VERSION: '3.12'
SKLEARN_VERSION: '1.5'
pool:
vmImage: 'windows-latest'
vmImage: 'windows-2022'
steps:
- template: build-and-test-win.yml
6 changes: 3 additions & 3 deletions .ci/pipeline/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ variables:
jobs:
- job: Coverity
pool:
vmImage: 'ubuntu-latest'
vmImage: 'ubuntu-22.04'
Alexsandruss marked this conversation as resolved.
Show resolved Hide resolved
steps:
- script: |
cd $(Agent.BuildDirectory)
Expand All @@ -58,7 +58,7 @@ jobs:
- job: Jupyter
timeoutInMinutes: 0
pool:
vmImage: 'ubuntu-latest'
vmImage: 'ubuntu-22.04'
steps:
- script: |
conda config --append channels conda-forge
Expand Down Expand Up @@ -110,6 +110,6 @@ jobs:
PYTHON_VERSION: '3.11'
SKLEARN_VERSION: 'main'
pool:
vmImage: 'windows-latest'
vmImage: 'windows-2022'
steps:
- template: build-and-test-win.yml
4 changes: 3 additions & 1 deletion .ci/scripts/gen_release_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

CHANNELS = args.channels
PYTHON_VERSIONS = ["3.9", "3.10", "3.11"]
SYSTEMS = ["ubuntu-latest", "windows-latest"]
# image versions are pinned to exact number instead of "latest"
# to avoid unexpected failures when images are updated
SYSTEMS = ["ubuntu-22.04", "windows-2022"]
Alexsandruss marked this conversation as resolved.
Show resolved Hide resolved
ACTIVATE = {
"ubuntu-latest": "conda activate",
"windows-latest": "call activate",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ jobs:
call .\.github\scripts\activate_components.bat ${{ env.DPCPP_VERSION }} ${{ env.TBB_VERSION }} ${{ steps.set-env.outputs.DPCFLAG }}
set PYTHON=python
cd ..
call scikit-learn-intelex\conda-recipe\run_test.bat scikit-learn-intelex
call scikit-learn-intelex\conda-recipe\run_test.bat scikit-learn-intelex\
- name: Sklearn testing
shell: cmd
run: |
Expand Down
27 changes: 27 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ To install Intel(R) Extension for Scikit-learn*, use one of the following scenar
- [Prerequisites](#prerequisites)
- [Configure the Build with Environment Variables](#configure-the-build-with-environment-variables)
- [Build Intel(R) Extension for Scikit-learn](#build-intelr-extension-for-scikit-learn)
- [Build from Sources with `conda-build`](#build-from-sources-with-conda-build)
- [Prerequisites for `conda-build`](#prerequisites-for-conda-build)
- [Build Intel(R) Extension for Scikit-learn with `conda-build`](#build-intelr-extension-for-scikit-learn-with-conda-build)
- [Next Steps](#next-steps)

> **_NOTE:_** Intel(R) Extension for Scikit-learn* is also available as a part of [Intel® AI Tools](https://www.intel.com/content/www/us/en/developer/tools/oneapi/ai-analytics-toolkit.html). If you already have it installed, you do not need to separately install the extension.
Expand Down Expand Up @@ -212,6 +215,30 @@ back to the project source-code directory. That way, you can edit the source cod
without reinstalling the package after a small change.
* `--single-version-externally-managed` is an option for Python packages instructing the setup tools module to create a package the host's package manager can easily manage.

## Build from Sources with `conda-build`

Intel(R) Extension for Scikit-learn* is easily built from the sources using only one command and `conda-build` utility.

### Prerequisites for `conda-build`

* any `conda` distribution (`miniforge` is recommended)
* `conda-build` and `conda-verify` installed in a conda environment
* (Windows only) Microsoft Visual Studio*
* (optional) Intel(R) oneAPI DPC++/C++ Compiler

`conda-build` config requires **2022** version of Microsoft Visual Studio* by default, you can specify another version in `conda-recipe/conda_build_config.yaml` if needed.

In order to enable DPC++ interfaces support on Windows, you need to set `DPCPPROOT` environment variable pointing to DPC++/C++ Compiler distribution.
Conda-forge distribution of DPC++ compiler is used by default on Linux, but you still can set your own distribution via `DPCPPROOT` variable.

### Build Intel(R) Extension for Scikit-learn with `conda-build`

Create and verify `scikit-learn-intelex` conda package with next command executed from root of sklearnex repo:

```bash
conda build .
```

## Next Steps

- [Learn what patching is and how to patch scikit-learn](https://intel.github.io/scikit-learn-intelex/latest/what-is-patching.html)
Expand Down
16 changes: 7 additions & 9 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ rem See the License for the specific language governing permissions and
rem limitations under the License.
rem ============================================================================

IF DEFINED PKG_VERSION (set DAAL4PY_VERSION=%PKG_VERSION%)

set MPIROOT=%PREFIX%\Library

IF NOT DEFINED PYTHON (set "PYTHON=python")
IF DEFINED PKG_VERSION (set SKLEARNEX_VERSION=%PKG_VERSION%)
IF NOT DEFINED DALROOT (set DALROOT=%PREFIX%)
IF NOT DEFINED MPIROOT IF "%NO_DIST%"=="" (set MPIROOT=%PREFIX%\Library)

set "BUILD_ARGS="
rem reset preferred compilers to avoid usage of icx/icpx by default in all cases
set CC=cl.exe
set CXX=cl.exe

rem source compiler if DPCPPROOT is set outside of conda-build
IF DEFINED DPCPPROOT (
echo "Sourcing DPCPPROOT"
call "%DPCPPROOT%\env\vars.bat"
)

set PATH=%PATH%;%PREFIX%\Library\bin\libfabric

%PYTHON% setup.py build %BUILD_ARGS%
IF %ERRORLEVEL% neq 0 EXIT /b %ERRORLEVEL%
%PYTHON% setup.py install --single-version-externally-managed --record record.txt
31 changes: 16 additions & 15 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,29 @@
# limitations under the License.
#===============================================================================

if [ "$PY3K" == "1" ]; then
ARGS=" --single-version-externally-managed --record=record.txt"
else
ARGS="--old-and-unmanageable"
if [ -z "${PYTHON}" ]; then
export PYTHON=python
fi

# if dpc++ vars path is specified
if [ ! -z "${DPCPPROOT}" ]; then
source ${DPCPPROOT}/env/vars.sh
if [ ! -z "${PKG_VERSION}" ]; then
export SKLEARNEX_VERSION=$PKG_VERSION
fi

if [ -z "${DALROOT}" ]; then
export DALROOT=${PREFIX}
fi

if [ "$(uname)" == "Darwin" ]; then
export CC=gcc
export CXX=g++
if [ -z "${MPIROOT}" ] && [ -z "${NO_DIST}" ]; then
export MPIROOT=${PREFIX}
fi

if [ ! -z "${PKG_VERSION}" ]; then
export DAAL4PY_VERSION=$PKG_VERSION
# reset preferred compilers to avoid usage of icx/icpx by default in all cases
if [ ! -z "${CC_FOR_BUILD}" ] && [ ! -z "${CXX_FOR_BUILD}" ]; then
export CC=$CC_FOR_BUILD
export CXX=$CXX_FOR_BUILD
fi
export MPIROOT=${PREFIX}
${PYTHON} setup.py install $ARGS
# source compiler if DPCPPROOT is set outside of conda-build
if [ ! -z "${DPCPPROOT}" ]; then
source ${DPCPPROOT}/env/vars.sh
fi

${PYTHON} setup.py install --single-version-externally-managed --record record.txt
6 changes: 4 additions & 2 deletions conda-recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@
# limitations under the License.
#===============================================================================

numpy:
- 1.19
c_compiler: # [win]
- vs2022 # [win]
Alexsandruss marked this conversation as resolved.
Show resolved Hide resolved
cxx_compiler: # [win]
- vs2022 # [win]
Loading
Loading