YOLOV5 在 mac 上运行

问题描述 投票:0回答:1

我已将环境配置为在新的 Metal Performance Shaders (MPS) 后端上运行,以用于 PyTorch 的 GPU 训练加速,并且在我的 Macbook M2 Air 上运行 Yolov5 时,它总是会产生错误。

RES_DIR = set_res_dir()
    if TRAIN:
        !python /Users/krishpatel/yolov5/train.py --data /Users/krishpatel/yolov5/roboflow/data.yaml --weights yolov5s.pt \
        --img 640 --epochs {EPOCHS} --batch-size 32 --device mps  --name {RES_DIR} 

这是错误

screenshot of the error

UserWarning: The operator 'aten::nonzero' 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:11.)
  t = t[j]  # filter
  0%|          | 0/20 [00:16<?, ?it/s]                                          
Traceback (most recent call last):
  File "/Users/krishpatel/yolov5/train.py", line 630, in <module>
    main(opt)
  File "/Users/krishpatel/yolov5/train.py", line 524, in main
    train(opt.hyp, opt, device, callbacks)
  File "/Users/krishpatel/yolov5/train.py", line 307, in train
    loss, loss_items = compute_loss(pred, targets.to(device))  # loss scaled by batch_size
  File "/Users/krishpatel/yolov5/utils/loss.py", line 125, in __call__
    tcls, tbox, indices, anchors = self.build_targets(p, targets)  # targets
  File "/Users/krishpatel/yolov5/utils/loss.py", line 213, in build_targets
    j, k = ((gxy % 1 < g) & (gxy > 1)).T
NotImplementedError: The operator 'aten::remainder.Tensor_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 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.

我该怎么办?因为当只在 cpu 中运行时需要非常非常长的时间?任何建议将不胜感激。

所以我试着到处搜索,但找不到任何适用于 macbook 的东西。我认为如果它没有帮助,我将不得不在谷歌 colab 上运行它,但是购买昂贵的 macbook 而不使用 gpu 运行的意义何在?

macos performance deep-learning artificial-intelligence yolov5
1个回答
-3
投票

同理,mac m1,我也想换成gpu跑yolov5,但是不知道train.py里面修改什么代码,希望大神帮帮我 我以前见过这个错误,因为你的 pytorch 不是 nightly。只需每晚下载并重新配置您的环境

© www.soinside.com 2019 - 2024. All rights reserved.