Skip to content
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

Negative weights when using Macbook M1 with MPS #13387

Open
1 of 2 tasks
guybashan opened this issue Oct 26, 2024 · 4 comments
Open
1 of 2 tasks

Negative weights when using Macbook M1 with MPS #13387

guybashan opened this issue Oct 26, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@guybashan
Copy link

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

Detection

Bug

Hi,

Indeed I am using the latest code from git (main branch).
I re-run the training using this:
/cam-analyzer/pytorch_metal_env/bin/python ../yolov5/train.py --img 416 --batch 16 --epochs 100 --data ../yolo_cfg/data.yaml --weights yolov5m.pt --device mps
I re-checked my "train" and "val" folders. They look ok and the files look fine. I created the labels using YoloLabel app (open source).
I run the detection using this command:
/cam-analyzer/pytorch_metal_env/bin/python detect.py --save-txt --save-conf --weights /Users/user/Documents/dev/yolo_model/cam_analyzer/weights/best.pt --source /Users/user/Documents/dev/yolo_images --conf 0.1 --project /Users/columbo/Documents/dev/yolo_results --name detections --device mps
I use M1 Max with 64GB memory
I enabled working with GPU

Environment

  • Yolo 5
  • Python 3.13.0

Minimal Reproducible Example

/cam-analyzer/pytorch_metal_env/bin/python detect.py --save-txt --save-conf --weights /Users/user/Documents/dev/yolo_model/cam_analyzer/weights/best.pt --source /Users/user/Documents/dev/yolo_images --conf 0.1 --project /Users/columbo/Documents/dev/yolo_results --name detections --device mps

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@guybashan guybashan added the bug Something isn't working label Oct 26, 2024
@UltralyticsAssistant
Copy link
Member

👋 Hello @guybashan, thank you for reaching out and using YOLOv5 🚀! This is an automated response to confirm that we've received your issue. One of our Ultralytics engineers will assist you soon.

It looks like you're encountering issues with negative weights while using YOLOv5 on a Macbook M1 with MPS. To help us investigate further, please make sure you've provided a minimum reproducible example of your issue. This will greatly assist our team in diagnosing and fixing the problem.

To ensure the correct setup, confirm that you have Python version 3.8.0 or higher installed, along with all dependencies from the requirements.txt file, and that you're running on a compatible environment.

If you have any questions about your custom training setup, it would also be helpful to include dataset image examples, training logs, and verify if you're following best training practices.

Additionally, we're excited to let you know about YOLOv8, our latest state-of-the-art object detection model designed for enhanced performance, accuracy, and usability. Stay tuned for updates and enhancements! 🚀✨

Thank you for your patience and contribution to the YOLOv5 community! 😊

@pderrenger
Copy link
Member

@guybashan thank you for reporting this issue. Please ensure that your PyTorch version supports MPS on Mac M1 and try updating to the latest version if you haven't already. If the problem persists, consider running the training on a different device to isolate the issue.

@guybashan
Copy link
Author

@guybashan thank you for reporting this issue. Please ensure that your PyTorch version supports MPS on Mac M1 and try updating to the latest version if you haven't already. If the problem persists, consider running the training on a different device to isolate the issue.

@pderrenger thanks for your respond.
My PyTouch version does support MPS and I also ran a verification script to make sure of it.
Please note: when I switch to CPU, it all looks fine and I no longer have negative values.
Please also note: it doesn't seems to be related to the training process, since I used a model trained with MPS. When I ran it on MPS I got detections with negative value. When I ran it with CPU detection didn't have negative values.

@pderrenger
Copy link
Member

@guybashan it seems like the issue might be specific to MPS execution. I recommend checking for any known issues with PyTorch MPS support or trying a different PyTorch version that might resolve this discrepancy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants