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 (vianvidia-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, thenNone
is returned.- Parameters:
- Return torch.device device:
selected cuda device
Warning
GPU indices in
nvidia-smi
may not match those in PyTorch if in your environmentCUDA_DEVICE_ORDER
is not set toPCI_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 withhide_warnings=True
) but will not change the device.
Examples using get_freer_gpu
:#

Imaging inverse problems with adversarial networks

Reconstructing an image using the deep image prior.

Solving blind inverse problems / estimating physics parameters

Random phase retrieval and reconstruction methods.

Pattern Ordering in a Compressive Single Pixel Camera

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

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

Regularization by Denoising (RED) for Super-Resolution.

Self-supervised MRI reconstruction with Artifact2Artifact

Self-supervised learning with Equivariant Imaging for MRI.

Self-supervised learning from incomplete measurements of multiple operators.

Self-supervised denoising with the Neighbor2Neighbor loss.

Self-supervised denoising with the Generalized R2R loss.

Self-supervised learning with measurement splitting

Deep Equilibrium (DEQ) algorithms for image deblurring

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

Unfolded Chambolle-Pock for constrained image inpainting