File size: 228 Bytes
e348bce
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
import torch

if torch.cuda.is_available():
    device = torch.device("cuda")
    print(f"GPU {torch.cuda.get_device_name(0)} is available")
else:
    device = torch.device("cpu")
    print("No GPU available, using CPU instead")