GPU support#

Added in version 1.7.

GPU processing is supported thanks to the numpy dispatch mechanism of array functions - read NEP-18 and NEP-35 for more information. It means that most HyperSpy functions will work on a GPU if the data is a cupy.ndarray and the required functions are implemented in cupy.

Note

GPU processing with hyperspy requires numpy>=1.20 and dask>=2021.3.0, to be able to use NEP-18 and NEP-35.

>>> import cupy as cp 
>>> # Create a cupy array (on GPU device)
>>> data = cp.random.random(size=(20, 20, 100, 100)) 
>>> s = hs.signals.Signal2D(data) 
>>> type(s.data) 
... cupy._core.core.ndarray

Two convenience methods are available to transfer data between the host and the (GPU) device memory:

For lazy processing, see the corresponding section.