Skip to content

Commit 24de8dc

Browse files
gschreiberalexisrollandKosinkadink
authored
Fix SolidMask and MaskComposite device mismatch with --gpu-only (Comfy-Org#13296)
SolidMask had a hardcoded device="cpu" while other nodes (e.g. EmptyImage) follow intermediate_device(). This causes a RuntimeError when MaskComposite combines masks from different device sources under --gpu-only. - SolidMask: use intermediate_device() instead of hardcoded "cpu" - MaskComposite: align source device to destination before operating Co-authored-by: Alexis Rolland <alexisrolland@hotmail.com> Co-authored-by: Jedrzej Kosinski <kosinkadink1@gmail.com>
1 parent c0d77a5 commit 24de8dc

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

comfy_extras/nodes_mask.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import scipy.ndimage
33
import torch
44
import comfy.utils
5+
import comfy.model_management
56
import node_helpers
67
from typing_extensions import override
78
from comfy_api.latest import ComfyExtension, IO, UI
@@ -188,7 +189,7 @@ def define_schema(cls):
188189

189190
@classmethod
190191
def execute(cls, value, width, height) -> IO.NodeOutput:
191-
out = torch.full((1, height, width), value, dtype=torch.float32, device="cpu")
192+
out = torch.full((1, height, width), value, dtype=torch.float32, device=comfy.model_management.intermediate_device())
192193
return IO.NodeOutput(out)
193194

194195
solid = execute # TODO: remove
@@ -262,6 +263,7 @@ def define_schema(cls):
262263
def execute(cls, destination, source, x, y, operation) -> IO.NodeOutput:
263264
output = destination.reshape((-1, destination.shape[-2], destination.shape[-1])).clone()
264265
source = source.reshape((-1, source.shape[-2], source.shape[-1]))
266+
source = source.to(output.device)
265267

266268
left, top = (x, y,)
267269
right, bottom = (min(left + source.shape[-1], destination.shape[-1]), min(top + source.shape[-2], destination.shape[-2]))

0 commit comments

Comments
 (0)