torch device cpu code example Example: torch device device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')