Update model_management.py

fallback to cpu if nvidia is not available
This commit is contained in:
Jon Vojtush 2026-04-17 05:19:38 +00:00 committed by GitHub
parent c033bbf516
commit cbd3ba3dec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -203,8 +203,10 @@ def get_torch_device():
return torch.device("npu", torch.npu.current_device()) return torch.device("npu", torch.npu.current_device())
elif is_mlu(): elif is_mlu():
return torch.device("mlu", torch.mlu.current_device()) return torch.device("mlu", torch.mlu.current_device())
else: elif torch.cuda.is_available():
return torch.device(torch.cuda.current_device()) return torch.device(torch.cuda.current_device())
else:
return torch.device("cpu")
def get_total_memory(dev=None, torch_total_too=False): def get_total_memory(dev=None, torch_total_too=False):
global directml_enabled global directml_enabled