test cuda pytorch
import torch torch.cuda.is_available() >>> True torch.cuda.current_device() >>> 0 torch.cuda.device(0) >>> <torch.cuda.device at 0x7efce0b03be0> torch.cuda.device_count() >>> 1 torch.cuda.get_device_name(0) >>> 'GeForce GTX 950M'
Source: stackoverflow.com
torch cuda is available
torch.cuda.is_available() torch.cuda.current_device() torch.cuda.device(0) torch.cuda.device_count() torch.cuda.get_device_name(0)
Source: stackoverflow.com
check cuda version pytorch
torch.version.cuda
Source: discuss.pytorch.org
pytorch check if cuda is available
import torch device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
check if model is on cuda pytorch
next(network.parameters()).device