Fix running on CPU again

This commit is contained in:
doctorpangloss 2024-08-05 17:20:28 -07:00
parent b00964ace4
commit 8ab6b4b697

View File

@ -1034,9 +1034,16 @@ def should_use_bf16(device=None, model_params=0, prioritize_performance=True, ma
if is_intel_xpu():
return True
props = torch.cuda.get_device_properties("cuda")
if props.major >= 8:
return True
if device is None:
device = torch.device("cuda")
try:
props = torch.cuda.get_device_properties(device)
if props.major >= 8:
return True
except AssertionError:
logging.warning("Torch was not compiled with CUDA support")
return False
bf16_works = torch.cuda.is_bf16_supported()