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
d09b5ef4
Commit
d09b5ef4
authored
Apr 22, 2024
by
comfyanonymous
Browse files
Free some memory before loading upscale models.
parent
4ee9aad6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
comfy_extras/nodes_upscale_model.py
comfy_extras/nodes_upscale_model.py
+6
-1
No files found.
comfy_extras/nodes_upscale_model.py
View file @
d09b5ef4
...
...
@@ -37,9 +37,14 @@ class ImageUpscaleWithModel:
def
upscale
(
self
,
upscale_model
,
image
):
device
=
model_management
.
get_torch_device
()
memory_required
=
model_management
.
module_size
(
upscale_model
)
memory_required
+=
(
512
*
512
*
3
)
*
image
.
element_size
()
*
max
(
upscale_model
.
scale
,
1.0
)
*
256.0
#The 256.0 is an estimate of how much some of these models take, TODO: make it more accurate
memory_required
+=
image
.
nelement
()
*
image
.
element_size
()
model_management
.
free_memory
(
memory_required
,
device
)
upscale_model
.
to
(
device
)
in_img
=
image
.
movedim
(
-
1
,
-
3
).
to
(
device
)
free_memory
=
model_management
.
get_free_memory
(
device
)
tile
=
512
overlap
=
32
...
...
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