Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
C
ComfyUI
管理
动态
成员
代码
仓库
分支
提交
标签
仓库图
比较修订版本
锁定的文件
部署
模型注册表
分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
hanamizuki
ComfyUI
提交
b5dd15c6
提交
b5dd15c6
编辑于
1 year ago
作者:
space-nuko
浏览文件
操作
下载
补丁
差异文件
System stats endpoint
上级
1bbd3f7f
No related branches found
No related tags found
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
comfy/model_management.py
+27
-0
27 个添加, 0 个删除
comfy/model_management.py
server.py
+24
-0
24 个添加, 0 个删除
server.py
有
51 个添加
和
0 个删除
comfy/model_management.py
+
27
−
0
浏览文件 @
b5dd15c6
...
...
@@ -308,6 +308,33 @@ def pytorch_attention_flash_attention():
return
True
return
False
def
get_total_memory
(
dev
=
None
,
torch_total_too
=
False
):
global
xpu_available
global
directml_enabled
if
dev
is
None
:
dev
=
get_torch_device
()
if
hasattr
(
dev
,
'
type
'
)
and
(
dev
.
type
==
'
cpu
'
or
dev
.
type
==
'
mps
'
):
mem_total
=
psutil
.
virtual_memory
().
total
else
:
if
directml_enabled
:
mem_total
=
1024
*
1024
*
1024
#TODO
mem_total_torch
=
mem_total
elif
xpu_available
:
mem_total
=
torch
.
xpu
.
get_device_properties
(
dev
).
total_memory
mem_total_torch
=
mem_total
else
:
stats
=
torch
.
cuda
.
memory_stats
(
dev
)
mem_reserved
=
stats
[
'
reserved_bytes.all.current
'
]
_
,
mem_total_cuda
=
torch
.
cuda
.
mem_get_info
(
dev
)
mem_total_torch
=
mem_reserved
mem_total
=
mem_total_cuda
+
mem_total_torch
if
torch_total_too
:
return
(
mem_total
,
mem_total_torch
)
else
:
return
mem_total
def
get_free_memory
(
dev
=
None
,
torch_free_too
=
False
):
global
xpu_available
global
directml_enabled
...
...
此差异已折叠。
点击以展开。
server.py
+
24
−
0
浏览文件 @
b5dd15c6
...
...
@@ -7,6 +7,7 @@ import execution
import
uuid
import
json
import
glob
import
torch
from
PIL
import
Image
from
io
import
BytesIO
...
...
@@ -23,6 +24,7 @@ except ImportError:
import
mimetypes
from
comfy.cli_args
import
args
import
comfy.utils
import
comfy.model_management
@web.middleware
async
def
cache_control
(
request
:
web
.
Request
,
handler
):
...
...
@@ -280,6 +282,28 @@ class PromptServer():
return
web
.
Response
(
status
=
404
)
return
web
.
json_response
(
dt
[
"
__metadata__
"
])
@routes.get
(
"
/system_stats
"
)
async
def
get_queue
(
request
):
device_index
=
comfy
.
model_management
.
get_torch_device
()
device
=
torch
.
device
(
device_index
)
device_name
=
comfy
.
model_management
.
get_torch_device_name
(
device_index
)
vram_total
,
torch_vram_total
=
comfy
.
model_management
.
get_total_memory
(
device
,
torch_total_too
=
True
)
vram_free
,
torch_vram_free
=
comfy
.
model_management
.
get_free_memory
(
device
,
torch_free_too
=
True
)
system_stats
=
{
"
devices
"
:
[
{
"
name
"
:
device_name
,
"
type
"
:
device
.
type
,
"
index
"
:
device
.
index
,
"
vram_total
"
:
vram_total
,
"
vram_free
"
:
vram_free
,
"
torch_vram_total
"
:
torch_vram_total
,
"
torch_vram_free
"
:
torch_vram_free
,
}
]
}
return
web
.
json_response
(
system_stats
)
@routes.get
(
"
/prompt
"
)
async
def
get_prompt
(
request
):
return
web
.
json_response
(
self
.
get_queue_info
())
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录