Search code examples
pythonpython-3.xscikit-learnpip

Unable to install scikit-learn-intelex in Colab


I failed to install scikit-learn-intelex (ver. 2021.2.2) in Colab. Here was what I did in Colab:

! python -m pip install --upgrade pip
! python -m pip install scikit-learn-intelex

As a result, I got the following output, which looks normal to me.

Collecting pip
  Downloading https://files.pythonhosted.org/packages/ac/cf/0cc542fc93de2f3b9b53cb979c7d1118cffb93204afb46299a9f858e113f/pip-21.1-py3-none-any.whl (1.5MB)
     |████████████████████████████████| 1.6MB 11.3MB/s 
Installing collected packages: pip
  Found existing installation: pip 19.3.1
    Uninstalling pip-19.3.1:
      Successfully uninstalled pip-19.3.1
Successfully installed pip-21.1

and

Collecting scikit-learn-intelex
  Downloading scikit_learn_intelex-2021.2.2-py37-none-manylinux1_x86_64.whl (24 kB)
Collecting daal4py==2021.2.2
  Downloading daal4py-2021.2.2-py37-none-manylinux1_x86_64.whl (13.6 MB)
     |████████████████████████████████| 13.6 MB 108 kB/s 
Collecting dpcpp-cpp-rt==2021.*
  Downloading dpcpp_cpp_rt-2021.2.0-py2.py3-none-manylinux1_x86_64.whl (171.6 MB)
     |████████████████████████████████| 171.6 MB 80 kB/s 
Requirement already satisfied: numpy>=1.15 in /usr/local/lib/python3.7/dist-packages (from daal4py==2021.2.2->scikit-learn-intelex) (1.19.5)
Collecting daal==2021.2.2
  Downloading daal-2021.2.2-py2.py3-none-manylinux1_x86_64.whl (295.7 MB)
     |████████████████████████████████| 295.7 MB 13 kB/s 
Collecting tbb==2021.*
  Downloading tbb-2021.2.0-py2.py3-none-manylinux1_x86_64.whl (3.9 MB)
     |████████████████████████████████| 3.9 MB 64.4 MB/s 
Collecting opencl-rt==2021.*
  Downloading opencl_rt-2021.2.0-py2.py3-none-manylinux1_x86_64.whl (169.0 MB)
     |████████████████████████████████| 169.0 MB 34 kB/s 
Requirement already satisfied: intel-openmp==2021.* in /usr/local/lib/python3.7/dist-packages (from dpcpp-cpp-rt==2021.*->daal4py==2021.2.2->scikit-learn-intelex) (2021.2.0)
Collecting common-cmplr-lib-rt==2021.*
  Downloading common_cmplr_lib_rt-2021.2.0-py2.py3-none-manylinux1_x86_64.whl (31.6 MB)
     |████████████████████████████████| 31.6 MB 162 kB/s 
Collecting common-cmplr-lic-rt==2021.*
  Downloading common_cmplr_lic_rt-2021.2.0-py2.py3-none-manylinux1_x86_64.whl (24 kB)
Installing collected packages: tbb, common-cmplr-lic-rt, opencl-rt, common-cmplr-lib-rt, dpcpp-cpp-rt, daal, daal4py, scikit-learn-intelex

Then I restarted the kernel by clicking on Restart runtime in Runtime of the Colab window banner before running the following code:

from sklearnex import patch_sklearn

An error message was raised after running the code. It said:

---------------------------------------------------------------------------

ModuleNotFoundError                       Traceback (most recent call last)

<ipython-input-1-45b0f2aba6d7> in <module>()
----> 1 from sklearnex import patch_sklearn

ModuleNotFoundError: No module named 'sklearnex'


---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

Can anyone tell me how to install the package in Colab?


Solution

  • Here is a workaround answered by the developer of the package on GitHub:

    Google colab is currently running on Debian system. One of the changes you may encounter on a Debian system is dist-packages instead of site-packages. Third party Python software installed from Debian packages goes into dist-packages, not site-packages. We are working on support for Debian systems and it should be fixed in the next release. For now, I can suggest the following workaround:

          import sys
          import os
          import site
          sys.path.append(os.path.join(os.path.dirname(site.getsitepackages()[0]), "site-packages"))