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
b85fc718
Commit
b85fc718
authored
Jul 10, 2023
by
Aarni Koskela
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix MPS cache cleanup
Importing torch does not import torch.mps so the call failed.
parent
7b833291
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
modules/devices.py
modules/devices.py
+3
-2
modules/mac_specific.py
modules/mac_specific.py
+14
-0
No files found.
modules/devices.py
View file @
b85fc718
...
...
@@ -54,8 +54,9 @@ def torch_gc():
with
torch
.
cuda
.
device
(
get_cuda_device_string
()):
torch
.
cuda
.
empty_cache
()
torch
.
cuda
.
ipc_collect
()
elif
has_mps
()
and
hasattr
(
torch
.
mps
,
'empty_cache'
):
torch
.
mps
.
empty_cache
()
if
has_mps
():
mac_specific
.
torch_mps_gc
()
def
enable_tf32
():
...
...
modules/mac_specific.py
View file @
b85fc718
import
logging
import
torch
import
platform
from
modules.sd_hijack_utils
import
CondFunc
from
packaging
import
version
log
=
logging
.
getLogger
()
# 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.
...
...
@@ -19,9 +23,19 @@ def check_for_mps() -> bool:
return
False
else
:
return
torch
.
backends
.
mps
.
is_available
()
and
torch
.
backends
.
mps
.
is_built
()
has_mps
=
check_for_mps
()
def
torch_mps_gc
()
->
None
:
try
:
from
torch.mps
import
empty_cache
empty_cache
()
except
Exception
:
log
.
warning
(
"MPS garbage collection failed"
,
exc_info
=
True
)
# MPS workaround for https://github.com/pytorch/pytorch/issues/89784
def
cumsum_fix
(
input
,
cumsum_func
,
*
args
,
**
kwargs
):
if
input
.
device
.
type
==
'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