Skip to main content

PyLops-gpu

PyPI version Build Status AzureDevOps Status Documentation Status OS-support Slack Status

: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:

Objective

This library is an extension of PyLops to run operators on GPUs.

As much as numpy and scipy lie at the core of the parent project PyLops, PyLops-GPU heavily builds on top of PyTorch and 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:

import numpy as np
from pylops import Diagonal

n = int(1e6)
x = np.ones(n)
d = np.arange(n) + 1.

Dop = Diagonal(d)

# y = Dx
y = Dop*x

and similarly using PyLops-gpu:

import numpy as np
import torch
from pylops_gpu.utils.backend import device
from pylops_gpu import Diagonal

dev = 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 = Dx
y = Dop*x

Running 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 the torch.nn submodule and obtain Automatic Differentiation (AD) for the entire chain. Since the gradient of a linear operator is simply its adjoint, we have implemented a single class, pylops_gpu.TorchOperator, which can wrap any linear operator from PyLops and PyLops-gpu libraries and return a torch.autograd.Function object.

Project structure

This repository is organized as follows:

  • pylops_gpu: python library containing various GPU-powered linear operators and auxiliary routines
  • pytests: set of pytests
  • testdata: sample datasets used in pytests and documentation
  • docs: sphinx documentation
  • examples: set of python script examples for each linear operator to be embedded in documentation using sphinx-gallery
  • tutorials: set of python script tutorials to be embedded in documentation using sphinx-gallery

Getting started

You need Python 3.5 or greater.

From PyPi

If 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-gpu

Open a python terminal and type:

import pylops_gpu

If you do not see any error, you should be good to go, enjoy!

From Github

You can also directly install from the master node

pip install git+https://git@github.com/PyLops/pylops-gpu.git@master

Contributing

Feel like contributing to the project? Adding new operators or tutorial?

Follow the instructions from PyLops official documentation.

Documentation

The official documentation of PyLops-gpu is available here.

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 the Contributors list.

Moreover, if you have installed PyLops using the developer environment you can also build the documentation locally by typing the following command:

make doc

Once the documentation is created, you can make any change to the source code and rebuild the documentation by simply typing

make docupdate

Note 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.

History

PyLops-GPU was initially written and it is currently maintained by Equinor. It is an extension of PyLops for large-scale optimization with GPU-driven linear operators on that can be tailored to our needs, and as contribution to the free software community.

Contributors

  • Matteo Ravasi, mrava87
  • Francesco Picetti, fpicetti

Metadata

Release files for pylops-gpu 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pylops-gpu 0.0.1
File Size Uploaded
pylops_gpu-0.0.1.tar.gz 30.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pylops-gpu 0.0.1
File Interpreter ABI Platform
pylops_gpu-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 71.5 kB

Release files / pylops_gpu-0.0.1.tar.gz

Download URL pylops_gpu-0.0.1.tar.gz
Size 30.8 kB
Tags Source
SHA-256 checksum
How to use checksums
aaac89ee21877c9254d510c3bb39daec9e5ce236128c2cea891389f029c5bd6f
BLAKE2b-256 checksum
How to use checksums
51feec835fdf83b75646c16f49a9607031a54738e55653f29a7470c0e8f2f057
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

Release files / pylops_gpu-0.0.1-py3-none-any.whl

Download URL pylops_gpu-0.0.1-py3-none-any.whl
Size 40.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c25f2d151e6f725b506068d34f16780b8ad1b436598a5f8414ebeecce2b7867a
BLAKE2b-256 checksum
How to use checksums
6598006e67a590e7c7bae298f44524abf312bc801af59b6ee416d85a74c5bb00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.9

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page