[Python] YOLO11 failing with C++ ops error on M3 Mac - PyTorch/MPS issue?

Discussão em 'Python' iniciado por Stack, Fevereiro 5, 2025.

  1. Stack

    Stack Membro Participativo

    I'm having issues trying to get YOLOv11 working with PyTorch MPS on apple silicon. Keep getting this C++ ops error and can't figure out what's wrong.

    Here's my setup:

    • M3 Pro MacBook
    • Python 3.9
    • torch 2.6.0
    • torchvision 0.21.0
    • torchaudio 2.6.0
    • ultralytics 8.3.70

    Simple test code that's failing:

    from ultralytics import YOLO

    model = YOLO("yolov8n.pt")
    results = model.train(data="coco8.yaml", epochs=100, imgsz=640, device="mps")


    This is the error I keep getting:

    RuntimeError: Couldn't load custom C++ ops. This can happen if your PyTorch and torchvision versions are incompatible, or if you had errors while compiling torchvision from source. For further information on the compatible versions, check https://github.com/pytorch/vision#installation for the compatibility matrix.

    MPS is available (checked with torch.backends.mps.is_available()). I've tried the obvious stuff - reinstalling the packages, updating to latest versions, etc. No luck. Also tried using nightly versions, and following the ultralytics/Apple docs but they are very limited: https://developer.apple.com/metal/pytorch/

    https://docs.ultralytics.com/modes/train/#can-i-train-yolo11-models-on-apple-silicon-chips

    Anyone run into this before? Really want to use my M3's GPU if possible rather than falling back to CPU.

    Thanks!

    Continue reading...

Compartilhe esta Página