add multi-gpu image sneder

This commit is contained in:
marduk191
2024-09-11 01:05:18 -05:00
parent e255b86bc5
commit d681f21ede
2 changed files with 47 additions and 0 deletions
+1
View File
@@ -9,6 +9,7 @@ import folder_paths
node_list = [
"marnodes",
"img2dev",
]
NODE_CLASS_MAPPINGS = {}
+46
View File
@@ -0,0 +1,46 @@
import torch
import comfy.sd
current_device = "cuda:0"
def get_torch_device_patched():
global current_device
if (
not torch.cuda.is_available()
or comfy.model_management.cpu_state == comfy.model_management.CPUState.CPU
):
return torch.device("cpu")
return torch.device(current_device)
class ImageToDevice:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"image": ("IMAGE",),
"device": ([f"cuda:{i}" for i in range(torch.cuda.device_count())],),
}
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "execute"
CATEGORY = "marduk191/image utils"
def execute(self, image, device):
image = image.clone().to(device)
torch.cuda.empty_cache()
return (image,)
NODE_CLASS_MAPPINGS = {
# Image analysis
"ImageToDevice": ImageToDevice,
}
NODE_DISPLAY_NAME_MAPPINGS = {
# Image analysis
"ImageToDevice": "marduk191's Image Sender",
}