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
8508df25
Commit
8508df25
authored
May 21, 2024
by
comfyanonymous
Browse files
Work around black image bug on Mac 14.5 by forcing attention upcasting.
parent
83d969e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
comfy/ldm/modules/attention.py
comfy/ldm/modules/attention.py
+3
-2
comfy/model_management.py
comfy/model_management.py
+13
-0
No files found.
comfy/ldm/modules/attention.py
View file @
8508df25
...
...
@@ -19,12 +19,13 @@ from comfy.cli_args import args
import
comfy.ops
ops
=
comfy
.
ops
.
disable_weight_init
FORCE_UPCAST_ATTENTION_DTYPE
=
model_management
.
force_upcast_attention_dtype
()
def
get_attn_precision
(
attn_precision
):
if
args
.
dont_upcast_attention
:
return
None
if
attn_precision
is
None
and
args
.
force_upcast_attenti
on
:
return
torch
.
float32
if
FORCE_UPCAST_ATTENTION_DTYPE
is
not
N
on
e
:
return
FORCE_UPCAST_ATTENTION_DTYPE
return
attn_precision
def
exists
(
val
):
...
...
comfy/model_management.py
View file @
8508df25
...
...
@@ -5,6 +5,7 @@ from comfy.cli_args import args
import
comfy.utils
import
torch
import
sys
import
platform
class
VRAMState
(
Enum
):
DISABLED
=
0
#No vram present: no need to move models to vram
...
...
@@ -685,6 +686,18 @@ def pytorch_attention_flash_attention():
return
True
return
False
def
force_upcast_attention_dtype
():
upcast
=
args
.
force_upcast_attention
try
:
if
platform
.
mac_ver
()[
0
]
in
[
'14.5'
]:
#black image bug on OSX Sonoma 14.5
upcast
=
True
except
:
pass
if
upcast
:
return
torch
.
float32
else
:
return
None
def
get_free_memory
(
dev
=
None
,
torch_free_too
=
False
):
global
directml_enabled
if
dev
is
None
:
...
...
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