Check for GPU access with PyTorch

We can use torch.cuda.is_available to check whether we access for GPU or not with PyTorch.

import torch;
 
torch.cuda.is_available()

Output will be either true if the access is there; false otherwise.