get_freer_gpu#

deepinv.utils.get_freer_gpu(verbose=True, use_torch_api=True, hide_warnings=False)[source]#

Returns the GPU device with the most free memory.

Use in conjunction with torch.cuda.is_available().

If use_torch_api=True then attempts to select GPU using only torch commands, otherwise uses system driver to detect GPUs (via nvidia-smi command). The first method may be slower but is more reliable as the former depends on environment settings. If system method is chosen and fails, the call falls back to using torch commands and a warning is printed. If no CUDA devices are detected, then None is returned.

Parameters:
  • verbose (bool) – print selected GPU index and memory

  • use_torch_api (bool) – use torch commands if True, or Nvidia driver otherwise

  • hide_warnings (bool) – supress all warnings for all methods

Return torch.device device:

selected cuda device

Warning

GPU indices in nvidia-smi may not match those in PyTorch if in your environment CUDA_DEVICE_ORDER is not set to PCI_BUS_ID: https://discuss.pytorch.org/t/gpu-devices-nvidia-smi-and-cuda-get-device-name-output-appear-inconsistent/13150 If the variable is not set or has different value, the call to will print a warning (if not supressed with hide_warnings=True) but will not change the device.

Examples using get_freer_gpu:#

Imaging inverse problems with adversarial networks

Imaging inverse problems with adversarial networks

Image deblurring with custom deep explicit prior.

Image deblurring with custom deep explicit prior.

Creating your own dataset

Creating your own dataset

Reconstructing an image using the deep image prior.

Reconstructing an image using the deep image prior.

Single photon lidar operator for depth ranging.

Single photon lidar operator for depth ranging.

Saving and loading models

Saving and loading models

3D diffraction PSF

3D diffraction PSF

Solving blind inverse problems / estimating physics parameters

Solving blind inverse problems / estimating physics parameters

Random phase retrieval and reconstruction methods.

Random phase retrieval and reconstruction methods.

A tour of forward sensing operators

A tour of forward sensing operators

Ptychography phase retrieval

Ptychography phase retrieval

Pattern Ordering in a Compressive Single Pixel Camera

Pattern Ordering in a Compressive Single Pixel Camera

Tour of MRI functionality in DeepInverse

Tour of MRI functionality in DeepInverse

Training a reconstruction network.

Training a reconstruction network.

3D wavelet denoising

3D wavelet denoising

Image deblurring with Total-Variation (TV) prior

Image deblurring with Total-Variation (TV) prior

Image inpainting with wavelet prior

Image inpainting with wavelet prior

DPIR method for PnP image deblurring.

DPIR method for PnP image deblurring.

PnP with custom optimization algorithm (Condat-Vu Primal-Dual)

PnP with custom optimization algorithm (Condat-Vu Primal-Dual)

Plug-and-Play algorithm with Mirror Descent for Poisson noise inverse problems.

Plug-and-Play algorithm with Mirror Descent for Poisson noise inverse problems.

Regularization by Denoising (RED) for Super-Resolution.

Regularization by Denoising (RED) for Super-Resolution.

Vanilla PnP for computed tomography (CT).

Vanilla PnP for computed tomography (CT).

Building your custom MCMC sampling algorithm.

Building your custom MCMC sampling algorithm.

Image reconstruction with a diffusion model

Image reconstruction with a diffusion model

Implementing DiffPIR

Implementing DiffPIR

Implementing DPS

Implementing DPS

Uncertainty quantification with PnP-ULA.

Uncertainty quantification with PnP-ULA.

Self-supervised MRI reconstruction with Artifact2Artifact

Self-supervised MRI reconstruction with Artifact2Artifact

Image transformations for Equivariant Imaging

Image transformations for Equivariant Imaging

Self-supervised learning with Equivariant Imaging for MRI.

Self-supervised learning with Equivariant Imaging for MRI.

Self-supervised learning from incomplete measurements of multiple operators.

Self-supervised learning from incomplete measurements of multiple operators.

Self-supervised denoising with the Neighbor2Neighbor loss.

Self-supervised denoising with the Neighbor2Neighbor loss.

Self-supervised denoising with the Generalized R2R loss.

Self-supervised denoising with the Generalized R2R loss.

Self-supervised learning with measurement splitting

Self-supervised learning with measurement splitting

Self-supervised denoising with the SURE loss.

Self-supervised denoising with the SURE loss.

Self-supervised denoising with the UNSURE loss.

Self-supervised denoising with the UNSURE loss.

Deep Equilibrium (DEQ) algorithms for image deblurring

Deep Equilibrium (DEQ) algorithms for image deblurring

Learned Iterative Soft-Thresholding Algorithm (LISTA) for compressed sensing

Learned Iterative Soft-Thresholding Algorithm (LISTA) for compressed sensing

Learned iterative custom prior

Learned iterative custom prior

Learned Primal-Dual algorithm for CT scan.

Learned Primal-Dual algorithm for CT scan.

Unfolded Chambolle-Pock for constrained image inpainting

Unfolded Chambolle-Pock for constrained image inpainting

Vanilla Unfolded algorithm for super-resolution

Vanilla Unfolded algorithm for super-resolution