Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
S
Stable Diffusion Webui
管理
动态
成员
代码
仓库
分支
提交
标签
仓库图
比较修订版本
部署
模型注册表
分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
Hunter0726
Stable Diffusion Webui
提交
799760ab
“4fa1a76c92d871df87693eebf526703d9b4877ab”上不存在“README.md”
未验证
提交
799760ab
编辑于
1 year ago
作者:
AUTOMATIC1111
提交者:
GitHub
1 year ago
浏览文件
操作
下载
差异文件
Merge pull request #11722 from akx/mps-gc-fix
Fix MPS cache cleanup
上级
7b833291
b85fc718
No related branches found
No related tags found
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
modules/devices.py
+3
-2
3 个添加, 2 个删除
modules/devices.py
modules/mac_specific.py
+14
-0
14 个添加, 0 个删除
modules/mac_specific.py
有
17 个添加
和
2 个删除
modules/devices.py
+
3
−
2
浏览文件 @
799760ab
...
...
@@ -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
+
14
−
0
浏览文件 @
799760ab
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
'
:
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录