utils.py
1 import torch 2 3 4 def infer_device(): 5 """ 6 Get current device name based on available devices 7 """ 8 if torch.cuda.is_available(): 9 return "cuda" 10 elif torch.xpu.is_available(): 11 return "xpu" 12 else: 13 return "cpu"
1 import torch 2 3 4 def infer_device(): 5 """ 6 Get current device name based on available devices 7 """ 8 if torch.cuda.is_available(): 9 return "cuda" 10 elif torch.xpu.is_available(): 11 return "xpu" 12 else: 13 return "cpu"