Files

15 lines
288 B
Python
Raw Permalink Normal View History

2026-04-13 18:03:33 -07:00
import torch
import platform
def detect_device():
if torch.cuda.is_available():
return "cuda"
if platform.system() == "Darwin":
try:
if torch.backends.mps.is_available():
return "mps"
except:
pass
return "cpu"