kijai / ComfyUI-DepthAnythingV2

Simple DepthAnythingV2 inference node for monocular depth estimation
193 stars 14 forks source link

Error: Input type (float) and bias type (c10::Half) should be the same #6

Open ionflow opened 4 months ago

ionflow commented 4 months ago

Getting the following error on all fp16 models running on mac osx apple silicone with PYTORCH_ENABLE_MPS_FALLBACK=1

No problems with fp32 models.

Error occurred when executing DepthAnything_V2:

Input type (float) and bias type (c10::Half) should be the same

File "/Users/username/Sites/ComfyUI/execution.py", line 151, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "/Users/username/Sites/ComfyUI/execution.py", line 81, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "/Users/username/Sites/ComfyUI/execution.py", line 74, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "/Users/username/Sites/ComfyUI/custom_nodes/ComfyUI-DepthAnythingV2/nodes.py", line 146, in process
depth = model(img.unsqueeze(0).to(device))
File "/Users/username/Sites/ComfyUI/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/Users/username/Sites/ComfyUI/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "/Users/username/Sites/ComfyUI/custom_nodes/ComfyUI-DepthAnythingV2/depth_anything_v2/dpt.py", line 188, in forward
features = self.pretrained.get_intermediate_layers(x, self.intermediate_layer_idx[self.encoder], return_class_token=True)
File "/Users/username/Sites/ComfyUI/custom_nodes/ComfyUI-DepthAnythingV2/depth_anything_v2/dinov2.py", line 308, in get_intermediate_layers
outputs = self._get_intermediate_layers_not_chunked(x, n)
File "/Users/username/Sites/ComfyUI/custom_nodes/ComfyUI-DepthAnythingV2/depth_anything_v2/dinov2.py", line 272, in _get_intermediate_layers_not_chunked
x = self.prepare_tokens_with_masks(x)
File "/Users/username/Sites/ComfyUI/custom_nodes/ComfyUI-DepthAnythingV2/depth_anything_v2/dinov2.py", line 214, in prepare_tokens_with_masks
x = self.patch_embed(x)
File "/Users/username/Sites/ComfyUI/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/Users/username/Sites/ComfyUI/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "/Users/username/Sites/ComfyUI/custom_nodes/ComfyUI-DepthAnythingV2/depth_anything_v2/dinov2_layers/patch_embed.py", line 76, in forward
x = self.proj(x) # B C H W
File "/Users/username/Sites/ComfyUI/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/Users/username/Sites/ComfyUI/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "/Users/username/Sites/ComfyUI/.venv/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/username/Sites/ComfyUI/.venv/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 456, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
kijai commented 4 months ago

I don't know how to make fp16 work on MPS, it's same issue with a lot of stuff. In this case it shouldn't matter as the fp32 versions are actually lot better.