Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
3152023f
Commit
3152023f
authored
Dec 11, 2023
by
comfyanonymous
Browse files
Use inference dtype for unet memory usage estimation.
parent
77755ab8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
comfy/model_base.py
comfy/model_base.py
+4
-1
No files found.
comfy/model_base.py
View file @
3152023f
...
@@ -177,9 +177,12 @@ class BaseModel(torch.nn.Module):
...
@@ -177,9 +177,12 @@ class BaseModel(torch.nn.Module):
def
memory_required
(
self
,
input_shape
):
def
memory_required
(
self
,
input_shape
):
if
comfy
.
model_management
.
xformers_enabled
()
or
comfy
.
model_management
.
pytorch_attention_flash_attention
():
if
comfy
.
model_management
.
xformers_enabled
()
or
comfy
.
model_management
.
pytorch_attention_flash_attention
():
dtype
=
self
.
get_dtype
()
if
self
.
manual_cast_dtype
is
not
None
:
dtype
=
self
.
manual_cast_dtype
#TODO: this needs to be tweaked
#TODO: this needs to be tweaked
area
=
input_shape
[
0
]
*
input_shape
[
2
]
*
input_shape
[
3
]
area
=
input_shape
[
0
]
*
input_shape
[
2
]
*
input_shape
[
3
]
return
(
area
*
comfy
.
model_management
.
dtype_size
(
self
.
get_
dtype
()
)
/
50
)
*
(
1024
*
1024
)
return
(
area
*
comfy
.
model_management
.
dtype_size
(
dtype
)
/
50
)
*
(
1024
*
1024
)
else
:
else
:
#TODO: this formula might be too aggressive since I tweaked the sub-quad and split algorithms to use less memory.
#TODO: this formula might be too aggressive since I tweaked the sub-quad and split algorithms to use less memory.
area
=
input_shape
[
0
]
*
input_shape
[
2
]
*
input_shape
[
3
]
area
=
input_shape
[
0
]
*
input_shape
[
2
]
*
input_shape
[
3
]
...
...
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