Package: pylops-gpu
:vertical_traffic_light: :vertical_traffic_light: This library is under early development.
Expect things to constantly change until version v1.0.0. :vertical_traffic_light: :vertical_traffic_light:ObjectiveThis library is an extension ofPyLopsto run operators on GPUs.As much asnumpyandscipylie
at the core of the parent project PyLops, PyLops-GPU heavily builds on top ofPyTorchand takes advantage of the same optimized
tensor computations used in PyTorch for deep learning using GPUs and CPUs.Doing so, linear operators can be computed on GPUs.Here is a simple example showing how a diagonal operator can be created,
applied and inverted using PyLops:importnumpyasnpfrompylopsimportDiagonaln=int(1e6)x=np.ones(n)d=np.arange(n)+1.Dop=Diagonal(d)# y = Dxy=Dop*xand similarly using PyLops-gpu:importnumpyasnpimporttorchfrompylops_gpu.utils.backendimportdevicefrompylops_gpuimportDiagonaldev=device()n=int(1e6)x=torch.ones(n,dtype=torch.float64).to(dev)d=(torch.arange(0,n,dtype=torch.float64)+1.).to(dev)Dop=Diagonal(d,device=dev)# y = Dxy=Dop*xRunning these two snippets of code in Google Colab with GPU enabled gives a 50+
speed up for the forward pass.As a by-product of implementing PyLops linear operators in PyTorch, we can easily
chain our operators with any nonlinear mathematical operation (e.g., log, sin, tan, pow, ...)
as well as with operators from thetorch.nnsubmodule and obtainAutomatic
Differentiation(AD) for the entire chain. Since the gradient of a linear
operator is simply itsadjoint, we have implemented a single class,pylops_gpu.TorchOperator, which can wrap any linear operator
from PyLops and PyLops-gpu libraries and return atorch.autograd.Functionobject.Project structureThis repository is organized as follows:pylops_gpu: python library containing various GPU-powered linear operators and auxiliary routinespytests:    set of pyteststestdata:   sample datasets used in pytests and documentationdocs:       sphinx documentationexamples:   set of python script examples for each linear operator to be embedded in documentation using sphinx-gallerytutorials:  set of python script tutorials to be embedded in documentation using sphinx-galleryGetting startedYou needPython 3.5 or greater.From PyPiIf you want to use PyLops-gpu within your codes,
install it in your Python-gpu environment by typing the following command in your terminal:pip install pylops-gpuOpen a python terminal and type:import pylops_gpuIf you do not see any error, you should be good to go, enjoy!From GithubYou can also directly install from the master nodepip install git+https://git@github.com/PyLops/pylops-gpu.git@masterContributingFeel like contributing to the project? Adding new operators or tutorial?Follow the instructions fromPyLops official documentation.DocumentationThe official documentation of PyLops-gpu is availablehere.Visit this page to get started learning about different operators and their applications as well as how to
create new operators yourself and make it to theContributorslist.Moreover, if you have installed PyLops using thedeveloper environmentyou can also build the documentation locally by
typing the following command:make docOnce the documentation is created, you can make any change to the source code and rebuild the documentation by
simply typingmake docupdateNote that if a new example or tutorial is created (and if any change is made to a previously available example or tutorial)
you are required to rebuild the entire documentation before your changes will be visible.HistoryPyLops-GPU was initially written and it is currently maintained byEquinor.
It is an extension ofPyLopsfor large-scale optimization withGPU-drivenlinear operators on that can be tailored to our needs, and as contribution to the free software community.ContributorsMatteo Ravasi, mrava87Francesco Picetti, fpicetti