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
deb2b93e
Commit
deb2b93e
authored
Apr 15, 2023
by
comfyanonymous
Browse files
Move code to empty gpu cache to model_management.py
parent
f4c689ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
comfy/model_management.py
comfy/model_management.py
+9
-0
execution.py
execution.py
+2
-7
No files found.
comfy/model_management.py
View file @
deb2b93e
...
@@ -307,6 +307,15 @@ def should_use_fp16():
...
@@ -307,6 +307,15 @@ def should_use_fp16():
return
True
return
True
def
soft_empty_cache
():
global
xpu_available
if
xpu_available
:
torch
.
xpu
.
empty_cache
()
elif
torch
.
cuda
.
is_available
():
if
torch
.
version
.
cuda
:
#This seems to make things worse on ROCm so I only do it for cuda
torch
.
cuda
.
empty_cache
()
torch
.
cuda
.
ipc_collect
()
#TODO: might be cleaner to put this somewhere else
#TODO: might be cleaner to put this somewhere else
import
threading
import
threading
...
...
execution.py
View file @
deb2b93e
...
@@ -10,7 +10,7 @@ import gc
...
@@ -10,7 +10,7 @@ import gc
import
torch
import
torch
import
nodes
import
nodes
from
model_management
import
xpu_available
import
comfy.
model_management
def
get_input_data
(
inputs
,
class_def
,
unique_id
,
outputs
=
{},
prompt
=
{},
extra_data
=
{}):
def
get_input_data
(
inputs
,
class_def
,
unique_id
,
outputs
=
{},
prompt
=
{},
extra_data
=
{}):
valid_inputs
=
class_def
.
INPUT_TYPES
()
valid_inputs
=
class_def
.
INPUT_TYPES
()
...
@@ -204,12 +204,7 @@ class PromptExecutor:
...
@@ -204,12 +204,7 @@ class PromptExecutor:
self
.
server
.
send_sync
(
"executing"
,
{
"node"
:
None
},
self
.
server
.
client_id
)
self
.
server
.
send_sync
(
"executing"
,
{
"node"
:
None
},
self
.
server
.
client_id
)
gc
.
collect
()
gc
.
collect
()
if
torch
.
cuda
.
is_available
():
comfy
.
model_management
.
soft_empty_cache
()
if
torch
.
version
.
cuda
:
#This seems to make things worse on ROCm so I only do it for cuda
torch
.
cuda
.
empty_cache
()
torch
.
cuda
.
ipc_collect
()
elif
xpu_available
:
torch
.
xpu
.
empty_cache
()
def
validate_inputs
(
prompt
,
item
):
def
validate_inputs
(
prompt
,
item
):
...
...
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