kijai / ComfyUI-DepthAnythingV2

Simple DepthAnythingV2 inference node for monocular depth estimation
158 stars 10 forks source link

Running the node on M1 MacBook Pro #12

Open Enuriru opened 1 month ago

Enuriru commented 1 month ago

I'm trying to run the node on M1 MacBook Pro, getting this error:

Error occurred when executing DepthAnything_V2: The operator 'aten::upsample_bicubic2d.out' is not currently implemented for the MPS device. If you want this op to be added in priority during the prototype phase of this feature, please comment on https://github.com/pytorch/pytorch/issues/77764. As a temporary fix, you can set the environment variablePYTORCH_ENABLE_MPS_FALLBACK=1to use the CPU as a fallback for this op. WARNING: this will be slower than running natively on MPS.

With fallback activated, Comfy crashes with error:

got prompt
Loading model from: /Users/enuriru/ComfyUI/models/depthanything/depth_anything_v2_vits_fp16.safetensors
using MLP layer as FFN
/Users/enuriru/ComfyUI/myenv/lib/python3.11/site-packages/torch/nn/functional.py:4592: UserWarning: The operator 'aten::upsample_bicubic2d.out' is not currently supported on the MPS backend and will fall back to run on the CPU. This may have performance implications. (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/aten/src/ATen/mps/MPSFallback.mm:13.)
  return torch._C._nn.upsample_bicubic2d(
loc("mps_add"("(mpsFileLoc): /AppleInternal/Library/BuildRoots/91a344b1-f985-11ee-b563-fe8bc7981bff/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShadersGraph/mpsgraph/MetalPerformanceShadersGraph/Core/Files/MPSGraphUtilities.mm":233:0)): error: input types 'tensor<1x1297x1536xf32>' and 'tensor<1536xf16>' are not broadcast compatible
LLVM ERROR: Failed to infer result type(s).
zsh: abort      python3.11 main.py

Any ideas? Thanks in advance!

kijai commented 1 month ago

This happens with fp32 model too? The fallback errors out on getting fp16 tensor it seems, which shouldn't happen if you use fp32 model.

Enuriru commented 1 month ago

Yes, it works with fp32 — thanks! I'm pretty new with this stuff, is there a way to run fp16 model? trying to save a bit more vram :)

HansonChan commented 1 month ago

I saw apple releaseed model trained for coreml, will this be supported in the future version of this custom nodes? Model: https://huggingface.co/apple/coreml-depth-anything-v2-small

kijai commented 1 month ago

I saw apple releaseed model trained for coreml, will this be supported in the future version of this custom nodes? Model: https://huggingface.co/apple/coreml-depth-anything-v2-small

I don't have any Apple devices, so probably not by me.