Skip to content

Commit

Permalink
Initial GPU docs (#437)
Browse files Browse the repository at this point in the history
* Initial GPU docs

* Apply suggestions from code review

Co-authored-by: Ekaterina Mekhnetsova <outoftardis@users.noreply.github.com>

* fixing comments

* Update doc/index.rst

Co-authored-by: Ekaterina Mekhnetsova <outoftardis@users.noreply.github.com>

* Update doc/index.rst

Co-authored-by: Ekaterina Mekhnetsova <outoftardis@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Ekaterina Mekhnetsova <outoftardis@users.noreply.github.com>

Co-authored-by: Ekaterina Mekhnetsova <outoftardis@users.noreply.github.com>
  • Loading branch information
napetrov and outoftardis authored Dec 25, 2020
1 parent 3b8cd7a commit ff0e104
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 15 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ Core functioanlity of daal4py is in place Scikit-learn patching - Same Code, Sam
Intel CPU optimizations patching
```py
from daal4py.sklearn import patch_sklearn
from daal4py.oneapi import sycl_context
patch_sklearn()

from sklearn.svm import SVC
from sklearn.datasets import load_digits
digits = load_digits()
X, y = digits.data, digits.target
clf = SVC().fit(X, y)
res = clf.predict(X)
from sklearn.cluster import DBSCAN

X = np.array([[1., 2.], [2., 2.], [2., 3.],
[8., 7.], [8., 8.], [25., 80.]], dtype=np.float32)
clustering = DBSCAN(eps=3, min_samples=2).fit(X)
```

Intel CPU/GPU optimizations patching
Expand All @@ -60,14 +60,14 @@ from daal4py.sklearn import patch_sklearn
from daal4py.oneapi import sycl_context
patch_sklearn()

from sklearn.svm import SVC
from sklearn.datasets import load_digits
digits = load_digits()
X, y = digits.data, digits.target
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"):
clf = SVC().fit(X, y)
res = clf.predict(X)
clustering = DBSCAN(eps=3, min_samples=2).fit(X)
```

daal4py API, allows you to use wider set of Intel(R) oneAPI Data Analytics Library algorithms in just one line:
```py
import daal4py as d4p
Expand Down
42 changes: 39 additions & 3 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ the linear regression workflow is showcased below::
In the example above, it can be seen that model is divided into training and
prediction. This gives flexibility when writing custom grid searches and custom
functions that modify model behavior or use it as a parameter. Daal4py also
allows for direct usage of NumPy arrays and Pandas DataFrames instead of DAAL's
NumericTables, which allow for better integration with the Pandas/NumPy/SciPy stack.

allows for direct usage of NumPy arrays and pandas DataFrames instead of oneDAL
NumericTables, which allow for better integration with the pandas/NumPy/SciPy stack.

Daal4py machine learning algorithms are constructed with a rich set of
parameters. Assuming we want to find the initial set of centroids for kmeans,
Expand Down Expand Up @@ -82,6 +81,43 @@ Last but not least, daal4py allows :ref:`getting input data from streams <stream
algo.compute(input)
result = algo.finalize()

oneAPI and GPU support in daal4py
---------------------------------
daal4py provides support of oneAPI concepts such as context and queues, which means that
algorithms can be executed on different devices, GPUs in particular. This is implemented via 'with sycl_context("xpu")'
blocks that redirect execution to a device of the selected type: GPU, CPU, or host.
Same approach is implemented for scikit-learn patching, so scikit-learn programs can be
executed on GPU devices as well.

To patch your code with Intel CPU/GPU optimizations:

.. code-block:: python
from daal4py.sklearn 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)
For execution on GPU, DPC++ compiler runtime and driver are required. Refer to `DPC++ system
requirements <https://software.intel.com/content/www/us/en/develop/articles/intel-oneapi-dpcpp-system-requirements.html>`_ for details.

DPC++ compiler runtime can be installed either from PyPI or Anaconda:

- Install from PyPI::
pip install dpcpp-cpp-rt

- Install from Anaconda::
conda install dpcpp_cpp_rt -c intel


Daal4py's Design
----------------
The design of daal4py utilizes several different technologies to deliver Intel(R) oneAPI Data
Expand Down

0 comments on commit ff0e104

Please sign in to comment.