-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YOLOv5: MPS on Macbook Air M1 NotImplementedError: Could not run 'aten::empty.memory_format' with arguments... #77748
Comments
Hi, The version of python that you're using is |
@albanD thanks for the pointer! My python install workflow for macOS is to go here and download the only available option: Is there another method I should be using? |
@albanD I see here that as of 3.9.1 this should fully support arm64 in the same macOS executable? Maybe I just got unlucky installing 3.9.0, I'll try again with 3.9.1. |
Yes, you can see the latest python download page: https://www.python.org/downloads/macos/ note that this will also mean that you won't have to go through the Rosetta layer to run your python code which might be faster :) |
@albanD I installed Python 3.9.1 universal binary and saw significant speedup with PyTorch stable (torch==1.11.0 torchvision 0.12.0) for CPU ops (not MPS), but am not able to run nightly because it seems the pip installer is pairing torch nightly 1.12 with torchvision stable 0.12 (which appear incompatible). This is the error message (YOLOv5 uses torchvision for NMS):
This is the version info I have now:
Code to reproduce (run in new macOS arm64 python>=3.9.1 venv): git clone https://github.com/ultralytics/yolov5
cd yolov5
pip install --pre -r requirements.txt --extra-index-url https://download.pytorch.org/whl/nightly/cpu
python detect.py |
@albanD perhaps we should change the |
PR ready: #77767 |
Fixing #77748 Pull Request resolved: #77767 Approved by: https://github.com/soulitzer
@glenn-jocher do you still have this issue if you install a nightly version of torchvision alongside the nightly version of torch ? |
@albanD I'm not able to install torchvision nightly with arm64 python for some reason. This is what I see: EDIT: if I force a search of only pytorch.org/whl/nightly/cpu no matching distributions are found. My pip is the latest (22.1). |
I had to compile torchvision from source to get it working. |
@acostin1 did the same and am now able to use torch and torchvision arm64 nightly. @albanD after installing torch nightly (pip) and torchvision nightly (from source) I'm now seeing a new
Reproduce (after installing torch and torchvision arm64 nightly): git clone https://github.com/ultralytics/yolov5 -b apple/mps
cd yolov5
pip install -r requirements.txt
python detect.py --weights yolov5n.pt --device cpu # verify CPU inference (45ms/image on Macbook Air M1)
python detect.py --weights yolov5n.pt --device mps # error on MPS inference Versions
|
… (#77767) Summary: Fixing #77748 Pull Request resolved: #77767 Approved by: https://github.com/soulitzer Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/dcd2ba353844bbc7d480bf3aa15fd0eeb0d55e78 Reviewed By: seemethere Differential Revision: D36494371 Pulled By: albanD fbshipit-source-id: 8c3d1b33272f100ee70880390c7e53e5b37b6f40
@albanD So how is it going? |
Closing as original issue is resolved. PyTorch team seems to have a few TODOs on their side to complete before YOLOv5 MPS will work correctly though:
|
🐛 Describe the bug
Following official example here causes an error.
https://pytorch.org/docs/master/notes/mps.html
Versions
The text was updated successfully, but these errors were encountered: