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
13fdee6a
Commit
13fdee6a
authored
Nov 27, 2023
by
comfyanonymous
Browse files
Try to free memory for both cond+uncond before inference.
parent
be71bb5e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
comfy/model_base.py
comfy/model_base.py
+2
-2
comfy/sample.py
comfy/sample.py
+1
-1
No files found.
comfy/model_base.py
View file @
13fdee6a
...
...
@@ -166,8 +166,8 @@ class BaseModel(torch.nn.Module):
def
memory_required
(
self
,
input_shape
):
if
comfy
.
model_management
.
xformers_enabled
()
or
comfy
.
model_management
.
pytorch_attention_flash_attention
():
#TODO: this needs to be tweaked
area
=
max
(
input_shape
[
0
]
,
3
)
*
input_shape
[
2
]
*
input_shape
[
3
]
return
(
area
*
comfy
.
model_management
.
dtype_size
(
self
.
get_dtype
())
/
6
0
)
*
(
1024
*
1024
)
area
=
input_shape
[
0
]
*
input_shape
[
2
]
*
input_shape
[
3
]
return
(
area
*
comfy
.
model_management
.
dtype_size
(
self
.
get_dtype
())
/
5
0
)
*
(
1024
*
1024
)
else
:
#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
]
...
...
comfy/sample.py
View file @
13fdee6a
...
...
@@ -83,7 +83,7 @@ def prepare_sampling(model, noise_shape, positive, negative, noise_mask):
real_model
=
None
models
,
inference_memory
=
get_additional_models
(
positive
,
negative
,
model
.
model_dtype
())
comfy
.
model_management
.
load_models_gpu
([
model
]
+
models
,
model
.
memory_required
(
noise_shape
)
+
inference_memory
)
comfy
.
model_management
.
load_models_gpu
([
model
]
+
models
,
model
.
memory_required
(
[
noise_shape
[
0
]
*
2
]
+
list
(
noise_shape
[
1
:])
)
+
inference_memory
)
real_model
=
model
.
model
return
real_model
,
positive
,
negative
,
noise_mask
,
models
...
...
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