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
b911eefc
Commit
b911eefc
authored
Nov 28, 2023
by
comfyanonymous
Browse files
Limit gc.collect() to once every 10 seconds.
parent
57d7f446
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
main.py
main.py
+9
-3
No files found.
main.py
View file @
b911eefc
...
@@ -88,6 +88,7 @@ def cuda_malloc_warning():
...
@@ -88,6 +88,7 @@ def cuda_malloc_warning():
def
prompt_worker
(
q
,
server
):
def
prompt_worker
(
q
,
server
):
e
=
execution
.
PromptExecutor
(
server
)
e
=
execution
.
PromptExecutor
(
server
)
last_gc_collect
=
0
while
True
:
while
True
:
item
,
item_id
=
q
.
get
()
item
,
item_id
=
q
.
get
()
execution_start_time
=
time
.
perf_counter
()
execution_start_time
=
time
.
perf_counter
()
...
@@ -97,9 +98,14 @@ def prompt_worker(q, server):
...
@@ -97,9 +98,14 @@ def prompt_worker(q, server):
if
server
.
client_id
is
not
None
:
if
server
.
client_id
is
not
None
:
server
.
send_sync
(
"executing"
,
{
"node"
:
None
,
"prompt_id"
:
prompt_id
},
server
.
client_id
)
server
.
send_sync
(
"executing"
,
{
"node"
:
None
,
"prompt_id"
:
prompt_id
},
server
.
client_id
)
print
(
"Prompt executed in {:.2f} seconds"
.
format
(
time
.
perf_counter
()
-
execution_start_time
))
current_time
=
time
.
perf_counter
()
gc
.
collect
()
execution_time
=
current_time
-
execution_start_time
comfy
.
model_management
.
soft_empty_cache
()
print
(
"Prompt executed in {:.2f} seconds"
.
format
(
execution_time
))
if
(
current_time
-
last_gc_collect
)
>
10.0
:
gc
.
collect
()
comfy
.
model_management
.
soft_empty_cache
()
last_gc_collect
=
current_time
print
(
"gc collect"
)
async
def
run
(
server
,
address
=
''
,
port
=
8188
,
verbose
=
True
,
call_on_start
=
None
):
async
def
run
(
server
,
address
=
''
,
port
=
8188
,
verbose
=
True
,
call_on_start
=
None
):
await
asyncio
.
gather
(
server
.
start
(
address
,
port
,
verbose
,
call_on_start
),
server
.
publish_loop
())
await
asyncio
.
gather
(
server
.
start
(
address
,
port
,
verbose
,
call_on_start
),
server
.
publish_loop
())
...
...
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