ArtBot2023 / CharacterFaceSwap

56 stars 6 forks source link

Mac M2 - Torch not compiled with CUDA enabled #8

Open eliganim opened 5 months ago

eliganim commented 5 months ago

I get this error on Mac M2. According to what I read, CUDA isn't supported on Mac, so I probably need to use the CPU instead. I read that replacing occurrences of cuda() with to(torch.device("mps")) should fix the issue, but it didn't work.

Can you please advise?

Error occurred when executing Load RetinaFace:

Torch not compiled with CUDA enabled

File "/Users/eliga/Desktop/ai/ComfyUI/execution.py", line 152, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "/Users/eliga/Desktop/ai/ComfyUI/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/eliga/Desktop/ai/ComfyUI/execution.py", line 70, in map_node_over_list
results.append(getattr(obj, func)())
File "/Users/eliga/Desktop/ai/ComfyUI/custom_nodes/CharacterFaceSwap/nodes.py", line 85, in load
return (init_detection_model("retinaface_resnet50", model_rootpath=self.models_dir), )
File "/Users/eliga/Desktop/ai/ComfyUI/venv/lib/python3.10/site-packages/facexlib/detection/__init__.py", line 10, in init_detection_model
model = RetinaFace(network_name='resnet50', half=half, device=device)
File "/Users/eliga/Desktop/ai/ComfyUI/venv/lib/python3.10/site-packages/facexlib/detection/retinaface.py", line 86, in __init__
self.mean_tensor = torch.tensor([[[[104.]], [[117.]], [[123.]]]], device=self.device)
File "/Users/eliga/Desktop/ai/ComfyUI/venv/lib/python3.10/site-packages/torch/cuda/__init__.py", line 289, in _lazy_init
raise AssertionError("Torch not compiled with CUDA enabled")
mattmusk commented 3 months ago

Save problem for me.

mattmusk commented 3 months ago

I get this error on Mac M2. According to what I read, CUDA isn't supported on Mac, so I probably need to use the CPU instead. I read that replacing occurrences of cuda() with to(torch.device("mps")) should fix the issue, but it didn't work.

Can you please advise?

Error occurred when executing Load RetinaFace:

Torch not compiled with CUDA enabled

File "/Users/eliga/Desktop/ai/ComfyUI/execution.py", line 152, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "/Users/eliga/Desktop/ai/ComfyUI/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/eliga/Desktop/ai/ComfyUI/execution.py", line 70, in map_node_over_list
results.append(getattr(obj, func)())
File "/Users/eliga/Desktop/ai/ComfyUI/custom_nodes/CharacterFaceSwap/nodes.py", line 85, in load
return (init_detection_model("retinaface_resnet50", model_rootpath=self.models_dir), )
File "/Users/eliga/Desktop/ai/ComfyUI/venv/lib/python3.10/site-packages/facexlib/detection/__init__.py", line 10, in init_detection_model
model = RetinaFace(network_name='resnet50', half=half, device=device)
File "/Users/eliga/Desktop/ai/ComfyUI/venv/lib/python3.10/site-packages/facexlib/detection/retinaface.py", line 86, in __init__
self.mean_tensor = torch.tensor([[[[104.]], [[117.]], [[123.]]]], device=self.device)
File "/Users/eliga/Desktop/ai/ComfyUI/venv/lib/python3.10/site-packages/torch/cuda/__init__.py", line 289, in _lazy_init
raise AssertionError("Torch not compiled with CUDA enabled")

You can change nodes.py in the root directory to fix it, in line 85: Change to below: return (init_detection_model("retinaface_resnet50", model_rootpath=self.models_dir, device='cuda' if torch.cuda.is_available() else 'cpu'), ) Remember to restart your comfyui. This error should be disapear.

Or: Just download my code to replace current one named ‘CharacterFaceSwap’ in your custom_nodes directory:
https://github.com/mattmusk/CharacterFaceSwap