v1.12.0, PyLops supports computations on GPUs powered by
cupy-cudaXX>=8.1.0) and cuSignal (
They must be installed before PyLops is installed.
Set environment variables
CUSIGNAL_PYLOPS=0 to force PyLops to ignore
This can be also used if a previous version of
cusignal is installed in your system, otherwise you will get an error when importing PyLops.
Apart from a few exceptions, all operators and solvers in PyLops can
seamlessly work with
numpy arrays on CPU as well as with
on GPU. Users do simply need to consistently create operators and
provide data vectors to the solvers, e.g., when using
pylops.MatrixMult the input matrix must be a
cupy array if the data provided to a solver is also
pylops.LinearOperator methods are currently on GPU:
Some operators are currently not available on GPU:
Some solvers are currently not available on GPU:
Finally, let’s briefly look at an example. First we write a code snippet using
numpy arrays which PyLops will run on your CPU:
ny, nx = 400, 400 G = np.random.normal(0, 1, (ny, nx)).astype(np.float32) x = np.ones(nx, dtype=np.float32) Gop = MatrixMult(G, dtype='float32') y = Gop * x xest = Gop / y
Now we write a code snippet using
cupy arrays which PyLops will run on
ny, nx = 400, 400 G = cp.random.normal(0, 1, (ny, nx)).astype(np.float32) x = cp.ones(nx, dtype=np.float32) Gop = MatrixMult(G, dtype='float32') y = Gop * x xest = Gop / y
The code is almost unchanged apart from the fact that we now use
PyLops will figure this out!
The CuPy backend is in active development, with many examples not yet in the docs. You can find many other examples from the PyLops Notebooks repository.