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
4adcea72
Commit
4adcea72
authored
Mar 24, 2023
by
comfyanonymous
Browse files
I don't think controlnets were being handled correctly by MPS.
parent
3c6ff882
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
comfy/model_management.py
comfy/model_management.py
+9
-6
No files found.
comfy/model_management.py
View file @
4adcea72
...
...
@@ -62,8 +62,7 @@ if "--novram" in sys.argv:
set_vram_to
=
NO_VRAM
if
"--highvram"
in
sys
.
argv
:
vram_state
=
HIGH_VRAM
if
torch
.
backends
.
mps
.
is_available
():
vram_state
=
MPS
if
set_vram_to
==
LOW_VRAM
or
set_vram_to
==
NO_VRAM
:
try
:
...
...
@@ -78,6 +77,12 @@ if set_vram_to == LOW_VRAM or set_vram_to == NO_VRAM:
total_vram_available_mb
=
(
total_vram
-
1024
)
//
2
total_vram_available_mb
=
int
(
max
(
256
,
total_vram_available_mb
))
try
:
if
torch
.
backends
.
mps
.
is_available
():
vram_state
=
MPS
except
:
pass
if
"--cpu"
in
sys
.
argv
:
vram_state
=
CPU
...
...
@@ -153,9 +158,6 @@ def load_controlnet_gpu(models):
if
vram_state
==
CPU
:
return
if
vram_state
==
MPS
:
return
if
vram_state
==
LOW_VRAM
or
vram_state
==
NO_VRAM
:
#don't load controlnets like this if low vram because they will be loaded right before running and unloaded right after
return
...
...
@@ -164,9 +166,10 @@ def load_controlnet_gpu(models):
if
m
not
in
models
:
m
.
cpu
()
device
=
get_torch_device
()
current_gpu_controlnets
=
[]
for
m
in
models
:
current_gpu_controlnets
.
append
(
m
.
cuda
(
))
current_gpu_controlnets
.
append
(
m
.
to
(
device
))
def
load_if_low_vram
(
model
):
...
...
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