From 2e4beb18a1a7ca066b4acd9d131f04dec9c24c9f Mon Sep 17 00:00:00 2001 From: Jun Yamog Date: Fri, 15 Dec 2023 16:23:31 +1300 Subject: [PATCH] fixes fastai/fastai#3981 to stop deprecated warning messages, use the current torch.backends.mps.is_built attribute --- fastai/torch_core.py | 2 +- nbs/00_torch_core.ipynb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fastai/torch_core.py b/fastai/torch_core.py index c35ec92b2f..2815ecd05e 100644 --- a/fastai/torch_core.py +++ b/fastai/torch_core.py @@ -260,7 +260,7 @@ def to_float(b): # %% ../nbs/00_torch_core.ipynb 71 def _has_mps(): if nested_attr(torch, 'backends.mps.is_available', noop)(): return True - return getattr(torch, 'has_mps', False) + return nested_attr(torch, 'backends.mps.is_built', False)() def default_device(use=-1): "Return or set default device; `use_cuda`: -1 - CUDA/mps if available; True - error if not available; False - CPU" diff --git a/nbs/00_torch_core.ipynb b/nbs/00_torch_core.ipynb index 90b837656d..e3b5945bb0 100644 --- a/nbs/00_torch_core.ipynb +++ b/nbs/00_torch_core.ipynb @@ -960,7 +960,7 @@ "#|export\n", "def _has_mps():\n", " if nested_attr(torch, 'backends.mps.is_available', noop)(): return True\n", - " return getattr(torch, 'has_mps', False)\n", + " return nested_attr(torch, 'backends.mps.is_built', False)()\n", "\n", "def default_device(use=-1):\n", " \"Return or set default device; `use_cuda`: -1 - CUDA/mps if available; True - error if not available; False - CPU\"\n",