# MacOS 12.3+print(torch.backends.mps.is_available())# PyTorch installation built with MPSprint(torch.backends.mps.is_built())device = torch.device("mps")
CUDA
Check whether GPU accelaration with CUDA available
Simply move inputs, labels, and model to GPU add parallelization and speed, ez
if torch.cuda.is_available(): a = torch.LongTensor(10).fill_(3).cuda()
Usage
device = torch.device("cuda:0"if torch.cuda.is_available() else"cpu")cuda = torch.device('cuda')# Default CUDA device