24 lines
1.1 KiB
Python
24 lines
1.1 KiB
Python
"""Deck-owned Comfy node: Qwen text encoder explicitly on the second visible GPU."""
|
|
import torch
|
|
import comfy.sd
|
|
import folder_paths
|
|
|
|
class DeckTextEncoderLoader:
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {'required':{'clip_name':(folder_paths.get_filename_list('text_encoders'),)}}
|
|
RETURN_TYPES=('CLIP',)
|
|
FUNCTION='load_clip'
|
|
CATEGORY='Deck'
|
|
def load_clip(self,clip_name):
|
|
if torch.cuda.device_count()!=2:raise RuntimeError('Deck requires the two reserved GPUs.')
|
|
device=torch.device('cuda:1')
|
|
path=folder_paths.get_full_path_or_raise('text_encoders',clip_name)
|
|
clip=comfy.sd.load_clip(ckpt_paths=[path],embedding_directory=folder_paths.get_folder_paths('embeddings'),clip_type=comfy.sd.CLIPType.QWEN_IMAGE,
|
|
model_options={'load_device':device,'offload_device':torch.device('cpu'),'initial_device':torch.device('cpu')})
|
|
if clip.patcher.load_device!=device:raise RuntimeError('Textencoder could not be assigned to the reserved GPU.')
|
|
return (clip,)
|
|
|
|
NODE_CLASS_MAPPINGS={'DeckTextEncoderLoader':DeckTextEncoderLoader}
|
|
NODE_DISPLAY_NAME_MAPPINGS={'DeckTextEncoderLoader':'Deck · Textencoder auf zweiter GPU'}
|