File size: 225 Bytes
fc33673
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
import torch

def get_device():
    if torch.cuda.is_available():
        return torch.device("cuda")
    elif torch.backends.mps.is_available():
        return torch.device("mps")
    else:
        return torch.device("cpu")