StartHua / Comfyui_CXH_joy_caption

Recommended based on comfyui node pictures:Joy_caption + MiniCPMv2_6-prompt-generator + florence2
Apache License 2.0
444 stars 26 forks source link

User specified an unsupported autocast device_type 'cuda:0' #37

Open langbowang opened 2 months ago

langbowang commented 2 months ago

image

ComfyUI Error Report

Error Details

nosdregamon commented 2 months ago

Got the same error, even when switching to cpu

File ".../custom_nodes/ComfyUI_HF_Servelress_Inference/nodes/Joy_Caption.py", line 171, in gen with torch.amp.autocast_mode.autocast(DEVICE, enabled=True): File ".../ComfyUI_windows_portable/python_embeded/Lib/site-packages/torch/amp/autocast_mode.py", line 241, in init raise RuntimeError( RuntimeError: User specified an unsupported autocast device_type 'cpu'

Perhaps a "autocast_mode.py" problem?

specblades commented 2 months ago

same here

AlexBenjarmin commented 2 months ago

No solution?

kesyn commented 2 months ago

You can fix it by modifying the Joy_caption_node.py file. Specifically, change the line:

with torch.amp.autocast_mode.autocast(str(DEVICE), enabled=True):

to

with torch.amp.autocast_mode.autocast(device_type=DEVICE.type, enabled=True):

This change ensures that autocast receives the correct device type ('cuda' or 'cpu') instead of the specific device name ('cuda:0').

Positliver commented 2 months ago

with torch.amp.autocast_mode.autocast(DEVICE, enabled=True): to with torch.cuda.amp.autocast(enabled=True):

AlexBenjarmin commented 2 months ago

with torch.amp.autocast_mode.autocast(DEVICE, enabled=True): to with torch.cuda.amp.autocast(enabled=True):

which file? Joy_caption_node.py?

Positliver commented 2 months ago

with torch.amp.autocast_mode.autocast(DEVICE, enabled=True): to with torch.cuda.amp.autocast(enabled=True):

which file? Joy_caption_node.py?

yes, Joy_caption_node.py

Gonng commented 2 months ago

You can fix it by modifying the Joy_caption_node.py file. Specifically, change the line:

with torch.amp.autocast_mode.autocast(str(DEVICE), enabled=True):

to

with torch.amp.autocast_mode.autocast(device_type=DEVICE.type, enabled=True):

This change ensures that autocast receives the correct device type ('cuda' or 'cpu') instead of the specific device name ('cuda:0').

thank you,it works for me!改完这一行代码,保存后,就正常运行了

specblades commented 2 months ago

Doesnt work for me. Nor with torch.cuda.amp.autocast(enabled=True): nor with torch.amp.autocast_mode.autocast(device_type=DEVICE.type, enabled=True):

eoris commented 2 months ago

replacing DEVICE = get_torch_device() with DEVICE = torch.device("cuda") also can help