-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
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
Training a model on MBP M1 extremely slow #7308
Comments
👋 Hello @lesleypotters, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution. If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you. If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available. For business inquiries or professional support requests please visit https://ultralytics.com or email [email protected]. RequirementsPython>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started: git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit. |
@lesleypotters base M1 is pretty slow, Pro and Max are much faster but still not as fast as a CUDA GPU. Yes your times look right. This is essentially just fast CPU training, the Neural Engine is not being used by PyTorch, but is being used for CoreML exported models. gpu_mem displays CUDA memory usage only. See my Reddit post here: https://www.reddit.com/r/MachineLearning/comments/tbj4lf/comment/i083o5s/?utm_source=share&utm_medium=web2x&context=3 |
@glenn-jocher Many thanks for your answer, very helpful. Can I add |
@lesleypotters yes the PyTorch team is working on M1 support, no current timeline available though. Export is something you do after training has completed. See TFLite, ONNX, CoreML, TensorRT Export tutorial for details. YOLOv5 Tutorials
Good luck 🍀 and let us know if you have any other questions! |
Ok great, thanks for the instant support! I will close this thread. |
@glenn-jocher is this the stuff we need to get faster training speed with yolov5? https://pytorch.org/blog/introducing-accelerated-pytorch-training-on-mac/ also: would it require a lot of work to get yolov5 run with this you think? or would it be enough to bump pytorch to v1.12? |
@sphrak use python universal2 installer for ARM devices and torch nightly if you expect to use MPS |
@glenn-jocher thanks, I think i got it i just pass |
@sphrak yes both, but full MPS support is not working yet due to unsupported pytorch aten ops. Regardless running YOLOv5 with an ARM python version will significantly speed up performance on M1/M2 devices vs Intel CPU speeds (but not as much as full MPS support). |
but if is use --device mps for train.py it is showing not implemented error,but working fine for detect.py |
running
|
Hi, did you solve the problem? I received same error here, running |
Same with me! I Also try to train yolov7 with mps and also have confirmed that mps is available, but I get the same error |
I tried to modify it and eventually could get “mps” activated, but tbh it’s not worthy because there are more incompatibility issues like old ones used float64 which mps doesn’t support. It’s endless. I would suggest just use latest ones. |
@Crear12 thank you for sharing your experience with modifying the torch_utils.py file to activate MPS on YOLOv7. It's good to know that while you were able to modify the file to activate MPS, you have also encountered incompatibility issues which made the whole process not worth the effort. For those who want to use MPS, it is recommended to use the latest versions and updates of YOLOv5 and PyTorch. Thank you again for sharing your experience! |
Using PyTorch Nightly version could solve this problem with adding the flag device=mps |
@ez4bk That's great news! Thank you for sharing your solution with us. It's good to hear that using the PyTorch Nightly version with the |
Search before asking
YOLOv5 Component
Training
Bug
Hi all,
I am working on a MBP M1 in a PyTorch environment with
torchvision 0.12.0
andtorch 1.11.0
(as recommended). I am trying yolov5 out with a wheat detection dataset. When running:python train.py --img 1024 --batch 8 --epochs 100 --data wheat.yaml --cfg models/yolov5s.yaml --name wm
it indeed starts to train for 100 epochs, but the expected time is about an hour per epoch. I find it suspicious that no gpu memory is allocated
gpu_mem 0G
, although I have to say I am a newby to yolov5 and MBP M1.This is a prtscr:
![image](https://user-images.githubusercontent.com/51701144/161926659-eb1faac5-1e77-44a9-a9ca-4da9c1bff329.png)
What could I change to improve? I have tried with --device cpubut to no avail. Any other options? Thanks!
This is my python detect.py output (which, if I am correct, is ok):
![image](https://user-images.githubusercontent.com/51701144/161926722-a209af71-d17e-43fd-b50e-bbc641d5569b.png)
Environment
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: