I'm trying to use sklearnex/scikit-learn-intelex for GPU accelaration. This is my code, learnt from 'Patching several algorithms:':
try:
from sklearnex import patch_sklearn
patch_sklearn()
except:
pass
patch_sklearn(['PCA','LinearRegression'])
Apparently the package suppports linear regression. However, it returns the following error on my machine:
> Intel(R) Extension for Scikit-learn* enabled (https://github.com/intel/scikit-learn-intelex)
> Traceback (most recent call last):
> File "/home/path/tmp_test.py", line 16, in <module>
> patch_sklearn(['PCA','LinearRegression'])
> File "/usr/local/lib/python3.9/site-packages/sklearnex/dispatcher.py", line 177, in patch_sklearn
> patch_sklearn_orig(algorithm, verbose=False, deprecation=False,
> File "/usr/local/lib/python3.9/site-packages/daal4py/sklearn/monkeypatch/dispatcher.py", line 127, in enable
> do_patch(name, get_map)
> File "/usr/local/lib/python3.9/site-packages/daal4py/sklearn/monkeypatch/dispatcher.py", line 111, in do_patch
> raise ValueError("Has no patch for: " + name)
> ValueError: Has no patch for: LinearRegression
What's wrong with my code? The package supports linear regression and I did exactly the way in the example
When I patch PCA
only, the algo works normaly. I'm using the latest version of this package.. The original sklearn works fine if I don't import sklearnex.
Fix for code itself - this would work, but this is not clear naming that would be fixed - https://github.com/intel/scikit-learn-intelex/pull/1343
patch_sklearn(['PCA','Linear'])
patch_sklearn() would affect only your CPU code - i.e. regular scikit code.
In case of GPU there is no notion of GPU support in scikit-learn itself.
To run on GPU (note: only Intel GPUs support ) you ether have to use explicit definition with config_context or pass GPU data(dpctl tensor) to algorithm https://intel.github.io/scikit-learn-intelex/oneapi-gpu.html