diff --git a/optimum/gptq/quantizer.py b/optimum/gptq/quantizer.py index db77ac0341..844da3e315 100644 --- a/optimum/gptq/quantizer.py +++ b/optimum/gptq/quantizer.py @@ -702,7 +702,7 @@ def tmp(_, input, output): model = self.post_init_model(model) torch.cuda.empty_cache() - if hasattr(torch, "xpu"): + if hasattr(torch, "xpu") and torch.xpu.is_available(): torch.xpu.empty_cache() return model