zetavg
extract and fix get_device
570c043
raw
history blame
250 Bytes
import torch
def get_device():
device ="cpu"
if torch.cuda.is_available():
device = "cuda"
try:
if torch.backends.mps.is_available():
device = "mps"
except: # noqa: E722
pass
return device