最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

macos - Detectron2 Faster R-CNN Training on Mac M3 (MPS) Fails Due to Missing Operator (`aten::_foreach_add.List`) - Stack Overf

programmeradmin2浏览0评论

Issue:

I am trying to train a Faster R-CNN model using Detectron2 on my MacBook Pro (M3, macOS Sonoma) with MPS (Metal Performance Shaders).

However, I keep running into missing operator issues during training:

from detectron2.engine import DefaultTrainer

trainer = DefaultTrainer(cfg)
trainer.resume_or_load(resume=False)  # Start from scratch
trainer.train()

Error message:

device_grads = torch._foreach_add(device_grads, device_params, alpha=weight_decay)
    295 if momentum != 0:
    296     bufs = []

NotImplementedError: The operator 'aten::_foreach_add.List' 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 . As a temporary fix, you can set the environment variable `PYTORCH_ENABLE_MPS_FALLBACK=1` to use the CPU as a fallback for this op. WARNING: this will be slower than running natively on MPS.


import os
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"

import torch
print(f"Using MPS: {torch.backends.mps.is_available()} (Fallback Enabled: {os.environ['PYTORCH_ENABLE_MPS_FALLBACK']})")

Has anyone successfully trained Faster R-CNN or Mask R-CNN on Mac M3 with MPS without running into missing operator issues? Is there a better workaround to enable missing ops without fully relying on CPU fallback?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论