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
6c23854f
Commit
6c23854f
authored
May 22, 2024
by
comfyanonymous
Browse files
Fix OSX latent2rgb previews.
parent
7718ada4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
4 deletions
+11
-4
comfy/model_management.py
comfy/model_management.py
+8
-2
comfy/ops.py
comfy/ops.py
+1
-1
latent_preview.py
latent_preview.py
+2
-1
No files found.
comfy/model_management.py
View file @
6c23854f
...
...
@@ -630,8 +630,14 @@ def supports_dtype(device, dtype): #TODO
def
device_supports_non_blocking
(
device
):
if
is_device_mps
(
device
):
return
False
#pytorch bug? mps doesn't support non blocking
return
True
def
device_should_use_non_blocking
(
device
):
if
not
device_supports_non_blocking
(
device
):
return
False
return
False
# return True #TODO: figure out why this causes issues
# return True #TODO: figure out why this causes memory issues on Nvidia and possibly others
def
cast_to_device
(
tensor
,
device
,
dtype
,
copy
=
False
):
device_supports_cast
=
False
...
...
@@ -643,7 +649,7 @@ def cast_to_device(tensor, device, dtype, copy=False):
elif
is_intel_xpu
():
device_supports_cast
=
True
non_blocking
=
device_s
upports
_non_blocking
(
device
)
non_blocking
=
device_s
hould_use
_non_blocking
(
device
)
if
device_supports_cast
:
if
copy
:
...
...
comfy/ops.py
View file @
6c23854f
...
...
@@ -21,7 +21,7 @@ import comfy.model_management
def
cast_bias_weight
(
s
,
input
):
bias
=
None
non_blocking
=
comfy
.
model_management
.
device_s
upports
_non_blocking
(
input
.
device
)
non_blocking
=
comfy
.
model_management
.
device_s
hould_use
_non_blocking
(
input
.
device
)
if
s
.
bias
is
not
None
:
bias
=
s
.
bias
.
to
(
device
=
input
.
device
,
dtype
=
input
.
dtype
,
non_blocking
=
non_blocking
)
if
s
.
bias_function
is
not
None
:
...
...
latent_preview.py
View file @
6c23854f
...
...
@@ -4,6 +4,7 @@ import struct
import
numpy
as
np
from
comfy.cli_args
import
args
,
LatentPreviewMethod
from
comfy.taesd.taesd
import
TAESD
import
comfy.model_management
import
folder_paths
import
comfy.utils
import
logging
...
...
@@ -43,7 +44,7 @@ class Latent2RGBPreviewer(LatentPreviewer):
latents_ubyte
=
(((
latent_image
+
1
)
/
2
)
.
clamp
(
0
,
1
)
# change scale from -1..1 to 0..1
.
mul
(
0xFF
)
# to 0..255
).
to
(
device
=
"cpu"
,
dtype
=
torch
.
uint8
,
non_blocking
=
True
)
).
to
(
device
=
"cpu"
,
dtype
=
torch
.
uint8
,
non_blocking
=
comfy
.
model_management
.
device_supports_non_blocking
(
latent_image
.
device
)
)
return
Image
.
fromarray
(
latents_ubyte
.
numpy
())
...
...
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