laksjdjf / IPAdapter-ComfyUI

experimental
GNU General Public License v3.0
217 stars 13 forks source link

Torch not compiled with CUDA enabled #26

Open Poperah opened 1 year ago

Poperah commented 1 year ago

Error occurred when executing IPAdapter:

Torch not compiled with CUDA enabled

File "/Users/zacharycarpenter/Desktop/ComfyUI-master/execution.py", line 152, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) File "/Users/zacharycarpenter/Desktop/ComfyUI-master/execution.py", line 82, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) File "/Users/zacharycarpenter/Desktop/ComfyUI-master/execution.py", line 75, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) File "/Users/zacharycarpenter/Desktop/ComfyUI-master/custom_nodes/IPAdapter-ComfyUI/ip_adapter.py", line 171, in adapter self.ipadapter.to(device, dtype=self.dtype) File "/Users/zacharycarpenter/Library/Python/3.9/lib/python/site-packages/torch/nn/modules/module.py", line 1160, in to return self._apply(convert) File "/Users/zacharycarpenter/Library/Python/3.9/lib/python/site-packages/torch/nn/modules/module.py", line 810, in _apply module._apply(fn) File "/Users/zacharycarpenter/Library/Python/3.9/lib/python/site-packages/torch/nn/modules/module.py", line 810, in _apply module._apply(fn) File "/Users/zacharycarpenter/Library/Python/3.9/lib/python/site-packages/torch/nn/modules/module.py", line 833, in _apply param_applied = fn(param) File "/Users/zacharycarpenter/Library/Python/3.9/lib/python/site-packages/torch/nn/modules/module.py", line 1158, in convert return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) File "/Users/zacharycarpenter/Library/Python/3.9/lib/python/site-packages/torch/cuda/init.py", line 289, in _lazy_init raise AssertionError("Torch not compiled with CUDA enabled")

JosephThomasParker commented 1 year ago

I got the same error trying to run this on a Mac M1. The workaround is to change "device" at line 142 of ip_adapter.py to device = "mps" (or I guess "cpu"). Then restart comfyui and it works. Make sure the dtype is set to fp32 in the LoadIPAdaptor node too!

(This answer is similar to the workaround for A1111: https://github.com/tencent-ailab/IP-Adapter/issues/53#issuecomment-1729322454)

https://github.com/laksjdjf/IPAdapter-ComfyUI/blob/main/ip_adapter.py#L142

laksjdjf commented 1 year ago

Thank you for info!

I don't have a Mac device, so I've put the proposed fix on the dev branch.

https://github.com/laksjdjf/IPAdapter-ComfyUI/blob/4b0ba3b70544993a0389f392b33886439dbd9709/ip_adapter.py#L140-L141