Skip to content

Update hubconf.py#8207

Closed
QuentinCouton wants to merge 2 commits intoultralytics:masterfrom
QuentinCouton:patch-1
Closed

Update hubconf.py#8207
QuentinCouton wants to merge 2 commits intoultralytics:masterfrom
QuentinCouton:patch-1

Conversation

@QuentinCouton
Copy link
Copy Markdown

@QuentinCouton QuentinCouton commented Jun 14, 2022

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Support for Apple's Metal Performance Shaders (MPS) backend added to the YOLOv5 model selection logic.

📊 Key Changes

  • Updated the device selection logic in hubconf.py.
  • Integrated a check for MPS (Metal Performance Shaders) availability.

🎯 Purpose & Impact

  • Purpose: To extend YOLOv5 support to Apple Silicon (M1/M2 chips) by utilizing the MPS backend, which allows for GPU acceleration on macOS.
  • Impact: Users with Apple Silicon devices can now leverage the performance benefits of their hardware when using YOLOv5, leading potentially to faster model inference and improved efficiency. 🍏💨

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Hello @QuentinCouton, thank you for submitting a YOLOv5 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • ✅ Verify your PR is up-to-date with upstream/master. If your PR is behind upstream/master an automatic GitHub Actions merge may be attempted by writing /rebase in a new comment, or by running the following code, replacing 'feature' with the name of your local branch:
git remote add upstream https://github.com/ultralytics/yolov5.git
git fetch upstream
# git checkout feature  # <--- replace 'feature' with local branch name
git merge upstream/master
git push -u origin -f
  • ✅ Verify all Continuous Integration (CI) checks are passing.
  • ✅ Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." -Bruce Lee

@glenn-jocher
Copy link
Copy Markdown
Member

@QuentinCouton PR CI is failing most checks. Please review and fix.

@glenn-jocher
Copy link
Copy Markdown
Member

Maybe try using hasattr(torch, 'has_mps') before checking availability

@glenn-jocher
Copy link
Copy Markdown
Member

@QuentinCouton I've created PR #8210 which should automatically prefer MPS over CPU if supported/available for all YOLOv5 ops: train/val/detect/hub etc. Can you try this PR and let me know if this works for you? i.e.:

import torch

# Model
model = torch.hub.load('ultralytics/yolov5:mps/prefer', 'yolov5s')  # <-- PR here
model.cpu()
# Images
dir = 'https://ultralytics.com/images/'
imgs = [dir + f for f in ('zidane.jpg', 'bus.jpg')]  # batch of images

# Inference
results = model(imgs)
results.print()  # or .show(), .save()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants