mirror of
https://github.com/openai/whisper.git
synced 2025-11-27 07:48:45 +00:00
MPS (Mac acceleration) by default if available
This commit is contained in:
parent
9f70a352f9
commit
bdd0d79b8e
@ -88,7 +88,12 @@ def load_model(name: str, device: Optional[Union[str, torch.device]] = None, dow
|
||||
"""
|
||||
|
||||
if device is None:
|
||||
device = "cuda" if torch.cuda.is_available() else "cpu"
|
||||
if torch.cuda.is_available():
|
||||
device = "cuda"
|
||||
elif torch.backends.mps.is_available():
|
||||
device = "mps"
|
||||
else:
|
||||
device = "cpu"
|
||||
if download_root is None:
|
||||
download_root = os.getenv(
|
||||
"XDG_CACHE_HOME",
|
||||
|
||||
@ -74,6 +74,8 @@ def transcribe(
|
||||
if model.device == torch.device("cpu"):
|
||||
if torch.cuda.is_available():
|
||||
warnings.warn("Performing inference on CPU when CUDA is available")
|
||||
if torch.backends.mps.is_available():
|
||||
warnings.warn("Performing inference on CPU when MPS is available")
|
||||
if dtype == torch.float16:
|
||||
warnings.warn("FP16 is not supported on CPU; using FP32 instead")
|
||||
dtype = torch.float32
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user