Check for torch.xpu.is_available()

This commit is contained in:
oobabooga 2023-10-16 12:53:40 -07:00
parent 188d20e9e5
commit 8ea554bc19

View file

@ -151,8 +151,15 @@ def huggingface_loader(model_name):
# Load with quantization and/or offloading # Load with quantization and/or offloading
else: else:
if not any((shared.args.cpu, torch.cuda.is_available(), torch.backends.mps.is_available())): conditions = [
logger.warning('torch.cuda.is_available() returned False. This means that no GPU has been detected. Falling back to CPU mode.') shared.args.cpu,
torch.cuda.is_available(),
torch.backends.mps.is_available(),
hasattr(torch, 'xpu') and torch.xpu.is_available(),
]
if not any(conditions):
logger.warning('No GPU has been detected by Pytorch. Falling back to CPU mode.')
shared.args.cpu = True shared.args.cpu = True
if shared.args.cpu: if shared.args.cpu: