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

ModuleNotFoundError: No module named 'daal4py._oneapi' for example

Open xwu99 opened this issue 2 years ago • 1 comments

Describe the bug I run the simplest example of daal4py. It outputs ModuleNotFoundError: No module named 'daal4py._oneapi'

To Reproduce Steps to reproduce the behavior: reproducer

from sklearnex import patch_sklearn, config_context
patch_sklearn()

from sklearn.cluster import DBSCAN

import numpy as np

X = np.array([[1., 2.], [2., 2.], [2., 3.],
            [8., 7.], [8., 8.], [25., 80.]], dtype=np.float32)
with config_context(target_offload="gpu:0"):
   clustering = DBSCAN(eps=3, min_samples=2).fit(X)

Expected behavior run correctly

Output/Screenshots

$ python daal4py-gpu.py 
Intel(R) Extension for Scikit-learn* enabled (https://github.com/intel/scikit-learn-intelex)
WARNING:root:Device support is limited. Please install dpctl for full experience
Traceback (most recent call last):
  File "/home/xiaochang/Works/dpcpp/daal4py-gpu.py", line 11, in <module>
    clustering = DBSCAN(eps=3, min_samples=2).fit(X)
  File "/home/xiaochang/miniconda3/envs/dpcpp/lib/python3.10/site-packages/daal4py/sklearn/_device_offload.py", line 88, in wrapper_with_self
    return wrapper_impl(self, *args, **kwargs)
  File "/home/xiaochang/miniconda3/envs/dpcpp/lib/python3.10/site-packages/daal4py/sklearn/_device_offload.py", line 74, in wrapper_impl
    result = _run_on_device(func, q, obj, *hostargs, **hostkwargs)
  File "/home/xiaochang/miniconda3/envs/dpcpp/lib/python3.10/site-packages/daal4py/sklearn/_device_offload.py", line 57, in _run_on_device
    from daal4py.oneapi import sycl_context, _get_in_sycl_ctxt
  File "/home/xiaochang/miniconda3/envs/dpcpp/lib/python3.10/site-packages/daal4py/oneapi/__init__.py", line 37, in <module>
    from daal4py._oneapi import *
ModuleNotFoundError: No module named 'daal4py._oneapi'

Environment:

# packages in environment at /home/xiaochang/miniconda3/envs/dpcpp:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
ca-certificates           2021.10.8            ha878542_0    conda-forge
daal4py                   2021.5.0                 pypi_0    pypi
dal                       2021.5.1           ha770c72_803    conda-forge
dpcpp-cpp-rt              2022.0.1             intel_3633    intel
dpcpp_cpp_rt              2022.0.1             intel_3633    intel
icc_rt                    2022.0.1             intel_3633    intel
intel-cmplr-lib-rt        2022.0.1             intel_3633    intel
intel-cmplr-lic-rt        2022.0.1             intel_3633    intel
intel-opencl-rt           2022.0.1             intel_3633    intel
intel-openmp              2022.0.1             intel_3633    intel
joblib                    1.1.0              pyhd8ed1ab_0    conda-forge
ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
libblas                   3.9.0           13_linux64_openblas    conda-forge
libcblas                  3.9.0           13_linux64_openblas    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 11.2.0              h1d223b6_14    conda-forge
libgfortran-ng            11.2.0              h69a702a_14    conda-forge
libgfortran5              11.2.0              h5c6108e_14    conda-forge
libgomp                   11.2.0              h1d223b6_14    conda-forge
liblapack                 3.9.0           13_linux64_openblas    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libopenblas               0.3.18          pthreads_h8fe5266_0    conda-forge
libstdcxx-ng              11.2.0              he4da1e4_14    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libzlib                   1.2.11            h36c2ea0_1013    conda-forge
mpi                       1.0                       mpich    conda-forge
mpich                     4.0.1              h846660c_100    conda-forge
ncurses                   6.3                  h9c3ff4c_0    conda-forge
numpy                     1.22.3                   pypi_0    pypi
openssl                   3.0.0                h7f98852_2    conda-forge
pip                       22.0.4             pyhd8ed1ab_0    conda-forge
python                    3.10.2          hc74c709_4_cpython    conda-forge
python_abi                3.10                    2_cp310    conda-forge
readline                  8.1                  h46c0cb4_0    conda-forge
scikit-learn              1.0.2                    pypi_0    pypi
scikit-learn-intelex      2021.20220207.123531          pypi_0    pypi
scipy                     1.8.0                    pypi_0    pypi
setuptools                60.10.0                  pypi_0    pypi
sqlite                    3.37.1               h4ff8645_0    conda-forge
tbb                       2021.5.0              intel_707    intel
threadpoolctl             3.1.0              pyh8a188c0_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
tzdata                    2022a                h191b570_0    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
zlib                      1.2.11            h36c2ea0_1013    conda-forge

xwu99 avatar Mar 18 '22 09:03 xwu99

Issue is similar to https://github.com/intel/scikit-learn-intelex/issues/968: py310 daal4py wheel is not available for current release, wheel for py39 is downloaded by error in setup config, both sklearnex and daal4py should be built from source for py310.

Alexsandruss avatar Mar 23 '22 14:03 Alexsandruss

Latest PyPI packages for 3.10 python version are correct now

Alexsandruss avatar Aug 23 '22 18:08 Alexsandruss

I see this issue in python 3.10.8 env setup in miniconda.


(skl) dg2@dg2-demo:~/skl$ python test2.py
Traceback (most recent call last):
  File "/home/dg2/skl/test2.py", line 3, in <module>
    from daal4py.oneapi import sycl_context
  File "/home/dg2/miniconda3/envs/skl/lib/python3.10/site-packages/daal4py/oneapi/__init__.py", line 44, in <module>
    from daal4py._oneapi import *
ModuleNotFoundError: No module named 'daal4py._oneapi'
(skl) dg2@dg2-demo:~/skl$

(skl) dg2@dg2-demo:~/skl$ pip list | grep -e da -e intel
daal4py              2023.1.1
python-dateutil      2.8.2
scikit-learn-intelex 20230426.134828
stack-data           0.6.2
(skl) dg2@dg2-demo:~/skl$

(skl) dg2@dg2-demo:~/skl$ cat test2.py
import numpy as np
from sklearnex import patch_sklearn
from daal4py.oneapi import sycl_context
patch_sklearn()

from sklearn.cluster import DBSCAN

X = np.array([[1., 2.], [2., 2.], [2., 3.],
              [8., 7.], [8., 8.], [25., 80.]], dtype=np.float32)
with sycl_context("gpu"):
    clustering = DBSCAN(eps=3, min_samples=2).fit(X)
(skl) dg2@dg2-demo:~/skl$

js333031 avatar May 26 '23 18:05 js333031

@js333031, daal4py/sklearnex 2023.1.1 release from intel conda/pypi channels with dpcpp runtimes runs without import error. You can check consistency of your environment to fix it.

Alexsandruss avatar Jun 01 '23 11:06 Alexsandruss