DepthMap Workflow for Mac M3?
Has anyone managed to get these working on a Mac silicon machine? When I get to the XLabsSampler stage I get "Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead." and I'm not entirely sure where to go from there. If anyone can help I'd be really grateful. I do use depthmaps in other workflows, so I'm guessing there must be a way of doing this.
Hello, perhaps you can try this (work in progress) method.
About the Float32 problem I find this on Internet. Works for me.
Run Python :
Python
Import numpy
import numpy as np
Creating a numpy array
arr = np.ones(4,dtype="float64")
Display original array
print("Original Array:\n",arr,"\n")
Display type of original array
print("type of Original Array:\n",arr.dtype,"\n")
Converting array into float32
arr = np.float32(arr)
Display type of modified array
print("type of modified array:\n",arr.dtype,"\n")
The output of the above program will be:
Original Array :
[1. 1. 1. 1.]
Type of Original Array:
Float64
Type of modified array:
Float64
Thanks Emilune - it does indeed work perfectly with Version 3 of the model. I'm very grateful for your help
Hi, I'm trying to get this to work on Mac as well (M1 Max, 64GB RAM) using the workflow seen below. I get an error message saying that CUDA is not enabled. How did you tell controlnet (or pytorch?) to not try to run on CUDA? Thanks in advance for any help!
!!! Exception during processing !!! Torch not compiled with CUDA enabled
Traceback (most recent call last):
File "/Applications/Flux/ComfyUI/execution.py", line 317, in execute
output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/Flux/ComfyUI/execution.py", line 192, in get_output_data
return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/Flux/ComfyUI/execution.py", line 169, in _map_node_over_list
process_inputs(input_dict, i)
File "/Applications/Flux/ComfyUI/execution.py", line 158, in process_inputs
results.append(getattr(obj, func)(**inputs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/Flux/ComfyUI/custom_nodes/x-flux-comfyui/nodes.py", line 304, in sampling
if torch.cuda.is_bf16_supported():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/Flux/ComfyUI/pytorch_env/lib/python3.12/site-packages/torch/cuda/init.py", line 128, in is_bf16_supported
device = torch.cuda.current_device()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/Flux/ComfyUI/pytorch_env/lib/python3.12/site-packages/torch/cuda/init.py", line 778, in current_device
_lazy_init()
File "/Applications/Flux/ComfyUI/pytorch_env/lib/python3.12/site-packages/torch/cuda/init.py", line 284, in _lazy_init
raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
Hello,
I suggest you replace the x-flux-comfyui folder located in the custom-nodes folder with the following folder:
https://drive.google.com/drive/folders/1uwiELHM_aXEY9y4J4LMUCIQkiV3-kZL5?usp=sharing
This is the same extension but modified so that it works under Mac Silicon. On my Mac M2, it works perfectly by using (via Terminal) the following command to launch ComfyUI: PYTORCH_ENABLE_PS_FALLBACK=1 python main.py
I am also Newbie in this field and it is by searching on the internet that I found this solution.
You have to choose "Default" parameter with the Load Diffusion model node.
Thanks so much Emilune for your explanations. Unfortunately I still get the same "CUDA" error but I will try a clean reinstall using your link and hope it works.
Don't forget to launch ComfyUI with the following command : PYTORCH_ENABLE_PS_FALLBACK=1 python main.py
I still get the MPS float32 issue. Any help for running on an M2 Max 64GB?
ComfyUI Error Report
Error Details
- Node Type: XlabsSampler
- Exception Type: TypeError
- Exception Message: Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead.
Stack Trace
File "/Users/jonny/ComfyUI/execution.py", line 323, in execute
output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
File "/Users/jonny/ComfyUI/execution.py", line 198, in get_output_data
return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
File "/Users/jonny/ComfyUI/execution.py", line 169, in _map_node_over_list
process_inputs(input_dict, i)
File "/Users/jonny/ComfyUI/execution.py", line 158, in process_inputs
results.append(getattr(obj, func)(**inputs))
File "/Users/jonny/ComfyUI/custom_nodes/x-flux-comfyui/nodes.py", line 458, in sampling
x = denoise_controlnet(
File "/Users/jonny/ComfyUI/custom_nodes/x-flux-comfyui/sampling.py", line 282, in denoise_controlnet
block_res_samples = container.controlnet(
File "/Users/jonny/miniconda3/envs/comfyui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/Users/jonny/miniconda3/envs/comfyui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
File "/Users/jonny/ComfyUI/custom_nodes/x-flux-comfyui/xflux/src/flux/controlnet.py", line 188, in forward
pe = self.pe_embedder(ids)
File "/Users/jonny/miniconda3/envs/comfyui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/Users/jonny/miniconda3/envs/comfyui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
File "/Users/jonny/ComfyUI/custom_nodes/x-flux-comfyui/xflux/src/flux/modules/layers.py", line 21, in forward
[rope(ids[..., i], self.axes_dim[i], self.theta) for i in range(n_axes)],
File "/Users/jonny/ComfyUI/custom_nodes/x-flux-comfyui/xflux/src/flux/modules/layers.py", line 21, in <listcomp>
[rope(ids[..., i], self.axes_dim[i], self.theta) for i in range(n_axes)],
File "/Users/jonny/ComfyUI/custom_nodes/x-flux-comfyui/xflux/src/flux/math.py", line 17, in rope
scale = torch.arange(0, dim, 2, dtype=torch.float64, device=pos.device) / dim
System Information
- ComfyUI Version: v0.2.2-49-g7183fd1
- Arguments: main.py --force-fp32
- OS: posix
- Python Version: 3.10.14 (main, May 6 2024, 14:42:37) [Clang 14.0.6 ]
- Embedded Python: false
- PyTorch Version: 2.6.0.dev20240916
Devices
- Name: mps
- Type: mps
- VRAM Total: 68719476736
- VRAM Free: 21167931392
- Torch VRAM Total: 68719476736
- Torch VRAM Free: 21167931392
Logs
2024-09-17 09:16:27,511 - root - INFO - Total VRAM 65536 MB, total RAM 65536 MB
2024-09-17 09:16:27,511 - root - INFO - pytorch version: 2.6.0.dev20240916
2024-09-17 09:16:27,511 - root - INFO - Forcing FP32, if this improves things please report it.
2024-09-17 09:16:27,511 - root - INFO - Set vram state to: SHARED
2024-09-17 09:16:27,511 - root - INFO - Device: mps
2024-09-17 09:16:28,105 - root - INFO - Using sub quadratic optimization for cross attention, if you have memory or speed issues try using: --use-split-cross-attention
2024-09-17 09:16:28,631 - root - INFO - [Prompt Server] web root: /Users/jonny/ComfyUI/web
2024-09-17 09:16:29,863 - root - WARNING - Traceback (most recent call last):
File "/Users/jonny/ComfyUI/nodes.py", line 1994, in load_custom_node
module_spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/Users/jonny/ComfyUI/custom_nodes/ComfyUI_Qwen2-VL-Instruct/__init__.py", line 3, in <module>
from .path_nodes import MultiplePathsInput
File "/Users/jonny/ComfyUI/custom_nodes/ComfyUI_Qwen2-VL-Instruct/path_nodes.py", line 1, in <module>
from decord import VideoReader, cpu # pip install decord
ModuleNotFoundError: No module named 'decord'
2024-09-17 09:16:29,863 - root - WARNING - Cannot import /Users/jonny/ComfyUI/custom_nodes/ComfyUI_Qwen2-VL-Instruct module for custom nodes: No module named 'decord'
2024-09-17 09:16:30,001 - root - INFO -
Import times for custom nodes:
2024-09-17 09:16:30,001 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/websocket_image_save.py
2024-09-17 09:16:30,001 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/cg-image-picker
2024-09-17 09:16:30,001 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/ComfyUI-Prompt-Preview
2024-09-17 09:16:30,001 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/wlsh_nodes
2024-09-17 09:16:30,001 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/ComfyUI-Dev-Utils
2024-09-17 09:16:30,002 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/ComfyUI_Qwen2-Audio-7B-Instruct-Int4
2024-09-17 09:16:30,002 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/ComfyUI-Custom-Scripts
2024-09-17 09:16:30,002 - root - INFO - 0.0 seconds (IMPORT FAILED): /Users/jonny/ComfyUI/custom_nodes/ComfyUI_Qwen2-VL-Instruct
2024-09-17 09:16:30,002 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/rgthree-comfy
2024-09-17 09:16:30,002 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/x-flux-comfyui
2024-09-17 09:16:30,002 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/Flux-Prompt-Generator
2024-09-17 09:16:30,002 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/ComfyUI-GGUF
2024-09-17 09:16:30,002 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/ComfyUI_essentials
2024-09-17 09:16:30,002 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/comfyui_controlnet_aux
2024-09-17 09:16:30,002 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/ComfyUI-Inspire-Pack
2024-09-17 09:16:30,002 - root - INFO - 0.0 seconds: /Users/jonny/ComfyUI/custom_nodes/ComfyUI_smZNodes
2024-09-17 09:16:30,002 - root - INFO - 0.1 seconds: /Users/jonny/ComfyUI/custom_nodes/ComfyUI-Manager
2024-09-17 09:16:30,002 - root - INFO - 0.1 seconds: /Users/jonny/ComfyUI/custom_nodes/comfyui-ollama
2024-09-17 09:16:30,002 - root - INFO - 0.1 seconds: /Users/jonny/ComfyUI/custom_nodes/ComfyUI-Impact-Pack
2024-09-17 09:16:30,002 - root - INFO - 0.2 seconds: /Users/jonny/ComfyUI/custom_nodes/ComfyUI-Florence2
2024-09-17 09:16:30,002 - root - INFO - 0.6 seconds: /Users/jonny/ComfyUI/custom_nodes/was-node-suite-comfyui
2024-09-17 09:16:30,002 - root - INFO -
2024-09-17 09:16:30,007 - root - INFO - Starting server
2024-09-17 09:16:30,007 - root - INFO - To see the GUI go to: http://127.0.0.1:8188
2024-09-17 09:16:48,998 - root - INFO - got prompt
2024-09-17 09:16:49,128 - root - INFO - Using split attention in VAE
2024-09-17 09:16:49,128 - root - INFO - Using split attention in VAE
2024-09-17 09:16:53,005 - root - INFO - Requested to load FluxClipModel_
2024-09-17 09:16:53,005 - root - INFO - Loading 1 new model
2024-09-17 09:16:53,009 - root - INFO - loaded completely 0.0 9319.23095703125 True
2024-09-17 09:17:09,158 - root - WARNING - clip missing: ['text_projection.weight']
2024-09-17 09:17:17,886 - root - INFO - model weight dtype torch.float32, manual cast: None
2024-09-17 09:17:17,886 - root - INFO - model_type FLUX
2024-09-17 09:17:40,901 - root - INFO - Requested to load Flux
2024-09-17 09:17:40,901 - root - INFO - Loading 1 new model
2024-09-17 09:19:38,393 - root - INFO - loaded completely 0.0 45400.195556640625 True
2024-09-17 09:19:42,661 - root - ERROR - !!! Exception during processing !!! Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead.
2024-09-17 09:19:42,663 - root - ERROR - Traceback (most recent call last):
File "/Users/jonny/ComfyUI/execution.py", line 323, in execute
output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
File "/Users/jonny/ComfyUI/execution.py", line 198, in get_output_data
return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
File "/Users/jonny/ComfyUI/execution.py", line 169, in _map_node_over_list
process_inputs(input_dict, i)
File "/Users/jonny/ComfyUI/execution.py", line 158, in process_inputs
results.append(getattr(obj, func)(**inputs))
File "/Users/jonny/ComfyUI/custom_nodes/x-flux-comfyui/nodes.py", line 458, in sampling
x = denoise_controlnet(
File "/Users/jonny/ComfyUI/custom_nodes/x-flux-comfyui/sampling.py", line 282, in denoise_controlnet
block_res_samples = container.controlnet(
File "/Users/jonny/miniconda3/envs/comfyui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/Users/jonny/miniconda3/envs/comfyui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
File "/Users/jonny/ComfyUI/custom_nodes/x-flux-comfyui/xflux/src/flux/controlnet.py", line 188, in forward
pe = self.pe_embedder(ids)
File "/Users/jonny/miniconda3/envs/comfyui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/Users/jonny/miniconda3/envs/comfyui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
File "/Users/jonny/ComfyUI/custom_nodes/x-flux-comfyui/xflux/src/flux/modules/layers.py", line 21, in forward
[rope(ids[..., i], self.axes_dim[i], self.theta) for i in range(n_axes)],
File "/Users/jonny/ComfyUI/custom_nodes/x-flux-comfyui/xflux/src/flux/modules/layers.py", line 21, in <listcomp>
[rope(ids[..., i], self.axes_dim[i], self.theta) for i in range(n_axes)],
File "/Users/jonny/ComfyUI/custom_nodes/x-flux-comfyui/xflux/src/flux/math.py", line 17, in rope
scale = torch.arange(0, dim, 2, dtype=torch.float64, device=pos.device) / dim
TypeError: Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead.
Additional Context
(Please add any additional context or steps to reproduce the error here)
Hello,
To use XlabsSampler on Mac, you could use this modified Xlabs folder nodes (for Mac : https://drive.google.com/drive/folders/1uwiELHM_aXEY9y4J4LMUCIQkiV3-kZL5?usp=sharing)
After that, try to launch comfy with this command which works on my M2 Ultra 64GB :
python3 -m venv venv
source ./venv/bin/activate
PYTORCH_ENABLE_MPS_FALLBACK=1 python3 main.py
I hope it helps you.
Thank you for your response. the workflow now runs without the MPS abort. However, after running with dev-fp8 model for 25 minutes (~60% complete) the preview was just a black image.
I'll keep looking.