Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
daf41a27
Commit
daf41a27
authored
Jul 06, 2023
by
Hao-Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix warning of 'has_mps' is deprecated from PyTorch
parent
fab73f2e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
modules/mac_specific.py
modules/mac_specific.py
+14
-9
No files found.
modules/mac_specific.py
View file @
daf41a27
...
...
@@ -4,16 +4,21 @@ from modules.sd_hijack_utils import CondFunc
from
packaging
import
version
# has_mps is only available in nightly pytorch (for now) and macOS 12.3+.
# check `getattr` and try it for compatibility
# before torch version 1.13, has_mps is only available in nightly pytorch and macOS 12.3+,
# use check `getattr` and try it for compatibility.
# in torch version 1.13, backends.mps.is_available() and backends.mps.is_built() are introduced in to check mps availabilty,
# since torch 2.0.1+ nightly build, getattr(torch, 'has_mps', False) was deprecated, see https://github.com/pytorch/pytorch/pull/103279
def
check_for_mps
()
->
bool
:
if
not
getattr
(
torch
,
'has_mps'
,
False
):
return
False
try
:
torch
.
zeros
(
1
)
.
to
(
torch
.
device
(
"mps"
))
return
True
except
Exception
:
return
False
if
version
.
parse
(
torch
.
__version__
)
<=
version
.
parse
(
"2.0.1"
):
if
not
getattr
(
torch
,
'has_mps'
,
False
):
return
False
try
:
torch
.
zeros
(
1
)
.
to
(
torch
.
device
(
"mps"
))
return
True
except
Exception
:
return
False
else
:
return
torch
.
backends
.
mps
.
is_available
()
and
torch
.
backends
.
mps
.
is_built
()
has_mps
=
check_for_mps
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment