Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sam2Segmentation mps runtime error Input type (float) and bias type (c10::Half) should be the same #46

Open
orbenda83 opened this issue Oct 13, 2024 · 1 comment

Comments

@orbenda83
Copy link

Hello,

I am running comfyui on M1 macbook and when the sam2segmentation node starts it gets the following error:
!!! Exception during processing !!! Input type (float) and bias type (c10::Half) should be the same

I have set the Load sam model with mps and pf16.

File "/Users/orbend/pinokio/api/comfyui/app/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/orbend/pinokio/api/comfyui/app/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/orbend/pinokio/api/comfyui/app/execution.py", line 169, in _map_node_over_list
process_inputs(input_dict, i)
File "/Users/orbend/pinokio/api/comfyui/app/execution.py", line 158, in process_inputs
results.append(getattr(obj, func)(**inputs))
File "/Users/orbend/pinokio/api/comfyui/app/custom_nodes/ComfyUI-segment-anything-2/nodes.py", line 314, in segment
model.set_image(image_np[i])
File "/Users/orbend/pinokio/api/comfyui/app/env/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/Users/orbend/pinokio/api/comfyui/app/custom_nodes/ComfyUI-segment-anything-2/sam2/sam2_image_predictor.py", line 97, in set_image
backbone_out = self.model.forward_image(input_image)
File "/Users/orbend/pinokio/api/comfyui/app/custom_nodes/ComfyUI-segment-anything-2/sam2/modeling/sam2_base.py", line 469, in forward_image
backbone_out = self.image_encoder(img_batch)
File "/Users/orbend/pinokio/api/comfyui/app/env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/Users/orbend/pinokio/api/comfyui/app/env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "/Users/orbend/pinokio/api/comfyui/app/custom_nodes/ComfyUI-segment-anything-2/sam2/modeling/backbones/image_encoder.py", line 31, in forward
features, pos = self.neck(self.trunk(sample))
File "/Users/orbend/pinokio/api/comfyui/app/env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/Users/orbend/pinokio/api/comfyui/app/env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "/Users/orbend/pinokio/api/comfyui/app/custom_nodes/ComfyUI-segment-anything-2/sam2/modeling/backbones/hieradet.py", line 283, in forward
x = self.patch_embed(x)
File "/Users/orbend/pinokio/api/comfyui/app/env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/Users/orbend/pinokio/api/comfyui/app/env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "/Users/orbend/pinokio/api/comfyui/app/custom_nodes/ComfyUI-segment-anything-2/sam2/modeling/backbones/utils.py", line 92, in forward
x = self.proj(x)
File "/Users/orbend/pinokio/api/comfyui/app/env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/Users/orbend/pinokio/api/comfyui/app/env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "/Users/orbend/pinokio/api/comfyui/app/env/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 460, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/Users/orbend/pinokio/api/comfyui/app/env/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 456, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Input type (float) and bias type (c10::Half) should be the same

Please help on this.

@balmasi
Copy link

balmasi commented Nov 8, 2024

Seeing the same thing on M2, even on CPU and fp32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants