scikit-learn-intelex icon indicating copy to clipboard operation
scikit-learn-intelex copied to clipboard

Library crashes on sklearn >= 1.1.0

Open gabrielication opened this issue 2 years ago • 11 comments

Describe the bug Version 2021.5.3 of scikit-learn-intelex seems incompatible with latest 1.1.1 version of scikit-learn. Latest scikit-learn which works is 1.0.2, so I had to downgrade it.

Moreover, I know that scikit-learn-intelex 2021.6.0 is suggested in my upgrades but pip gives an error every time it tries to download it ( #1003), so I am referring 2021.5.3 as the latest version.

To Reproduce

  1. Install latest scikit-learn-intelex (2021.5.3) and scikit-learn (1.1.1)
  2. Import it to an existing sklearn python project file
from sklearnex import patch_sklearn
patch_sklearn()
  1. Run it and obtain this error:
from sklearn.utils.fixes import sparse_lsqr
ImportError: cannot import name 'sparse_lsqr' from 'sklearn.utils.fixes'

Expected behavior Run it without any importing error.

Output/Screenshots None.

Environment:

  • OS: Linux Mint 20.3
  • Compiler: Python 3.8.10
  • Version: 2021.5.3

gabrielication avatar May 20 '22 10:05 gabrielication

Hi @gabrielication Thanks a lot for pointing this out. This definitely not expected behavior. I will try to find fix ASAP

PivovarA avatar May 23 '22 09:05 PivovarA

Hi @gabrielication Everything seems to work fine for python version=3.10. Could you try running the intel extension for scikit-learn with this version of python?

PivovarA avatar May 30 '22 09:05 PivovarA

Hi, I was able to reproduce this issue compiling from source with python 3.8 and python 3.9, but it seems that when using python 3.10 it works. @PivovarA Could you indicate why this doesn't happen with 3.10 ? Is python 3.10 a requirement ?

rafariossaa avatar May 31 '22 10:05 rafariossaa

Hi @gabrielication Everything seems to work fine for python version=3.10. Could you try running the intel extension for scikit-learn with this version of python?

I will try it in the next days, thank you for your work.

gabrielication avatar Jun 01 '22 10:06 gabrielication

Hi @gabrielication and @rafariossaa Finally we have updated the metadata for scikit-learn-intelex, now sklearnex can be installed for python>=3.7.

PivovarA avatar Jun 20 '22 14:06 PivovarA

Hi @gabrielication and @rafariossaa Finally we have updated the metadata for scikit-learn-intelex, now sklearnex can be installed for python>=3.7.

Hi, I confirm that it completely works now. Thank you!

gabrielication avatar Jun 20 '22 16:06 gabrielication

Does this fix require compiling from source?

I just ran into this bug as well trying to do a fresh installation of scikit-learn-intelex today. I installed with the command: conda create -n scikit-learn-intelex-basic -c conda-forge python=3.9 scikit-learn-intelex, as suggested here. This installed scikit-learn-1.1.1 and scikit-learn-intelex-2021.5.0. When I call from sklearnex import patch_sklearn, I also get the error

from sklearn.utils.fixes import sparse_lsqr
ImportError: cannot import name 'sparse_lsqr' from 'sklearn.utils.fixes' (/opt/anaconda3/envs/scikit-learn-intelex-basic/lib/python3.9/site-packages/sklearn/utils/fixes.py)

OS: MacOS Monterey 12.4 Python 3.9.13

BethanyL avatar Jun 27 '22 19:06 BethanyL

Does this fix require compiling from source?

I just ran into this bug as well trying to do a fresh installation of scikit-learn-intelex today. I installed with the command: conda create -n scikit-learn-intelex-basic -c conda-forge python=3.9 scikit-learn-intelex, as suggested here. This installed scikit-learn-1.1.1 and scikit-learn-intelex-2021.5.0. When I call from sklearnex import patch_sklearn, I also get the error

from sklearn.utils.fixes import sparse_lsqr
ImportError: cannot import name 'sparse_lsqr' from 'sklearn.utils.fixes' (/opt/anaconda3/envs/scikit-learn-intelex-basic/lib/python3.9/site-packages/sklearn/utils/fixes.py)

OS: MacOS Monterey 12.4 Python 3.9.13

Hi,@BethanyL, I had the same problem yesterday, with scikit-learn-intelex-2021.5.0. and python 3.9. And finally I reinstall scikit-learn==1.0.2 fix the problem(scikit-learn-intelex-2021.5.0. + scikit-learn==1.0.2 will work well with python-3.9 also with 3.10).

luke396 avatar Jul 06 '22 06:07 luke396

I'm also running into this. Does this require a new release?

Zethson avatar Jul 18 '22 09:07 Zethson

I'm also running into this. Does this require a new release?

Maybe it just because sklearn's version is not math with sklearn-inelex's, downgrade sklearn to 1.0.x, and it may work well.

luke396 avatar Jul 18 '22 09:07 luke396

Fixed in https://github.com/intel/scikit-learn-intelex/pull/980, sklearnex built from source works with sklearn 1.1.1

Alexsandruss avatar Aug 09 '22 13:08 Alexsandruss

2021.6.3. with fix is available in PyPI, but not in conda yet.

Alexsandruss avatar Aug 24 '22 12:08 Alexsandruss