-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
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在mac设备上使用mps加速出现的各种问题 #13226
Comments
👋 Hello @xxxkkw, 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 a minimum reproducible example to help us debug it. If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results. RequirementsPython>=3.8.0 with all requirements.txt installed including PyTorch>=1.8. 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, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit. Introducing YOLOv8 🚀We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀! Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects. Check out our YOLOv8 Docs for details and get started with: pip install ultralytics |
@xxxkkw hello, Thank you for providing a detailed description of the issue you're encountering with YOLOv5 on your Mac device using MPS acceleration. It seems like you've done a thorough job of setting up your environment and troubleshooting the problem. Let's address the issues step-by-step: Deprecation WarningThe warning message you encountered:
This is a known issue with the latest versions of PyTorch. While it doesn't affect the training process, it indicates that the codebase needs to be updated to align with the latest PyTorch API changes. You can safely ignore this warning for now, but it's good to keep your packages updated to avoid such warnings in the future. Video Detection Issues with MPSThe issue with the detection results being incorrect when using MPS but correct when using CPU suggests a potential problem with the MPS backend in PyTorch. Here are a few steps you can take to troubleshoot and potentially resolve this issue:
Using Pretrained ModelsThe fact that using Example Code for CPU InferenceHere's an example of how you can run inference using the CPU to avoid MPS-related issues: python detect.py --weights your_custom_model.pt --source your_video.mp4 --device cpu Reporting BugsIf the issue persists, consider reporting it to the PyTorch team with detailed information about your setup and the problems you're encountering. This helps improve the MPS backend for everyone. Thank you for your patience and for being a part of the YOLO community. If you have any further questions or need additional assistance, feel free to ask! |
Search before asking
YOLOv5 Component
Training, Detection
Bug
首先从训练模型讲起,我使用的设备是一台MacOS 14的设备,m1max芯片,如果使用
也就是仅使用官方的训练数据,训练的过程中会出现
虽然这并不影响训练的过程,最终还是可以正常的输出训练好的模型。
在我使用这个训练好的模型对 yolov5/data/images 文件夹内的图片进行检测,检测结果是正常的,但当我使用这个训练好的模型进行检测的时候,最终输出的视频文件是乱的,体现在
这个是我在视频里面截取的一帧,并且整个视频中框都呈现类似的错误,而我如果换用cpu进行检测的时候,检测结果就正常了
并且,如果我使用yolov5文件夹内的yolov5s.pt进行检测的时候,这种问题又消失了,检测的结果就是正常的,这就让人非常不能理解,我认为yolov5s.pt文件的训练集与我使用该命令的数据集
应该是一致的,为什么会出现这样的错误?
还有,我在使用我自己的数据集的过程中,我曾经在服务器上训练好了一个模型,并且在那边使用的是cuda,并且确定这个模型文件是可用的,在服务器上对视频进行识别是正常的,但在我的设备上,使用这个模型对视频文件进行检测,结果就类似于我给出的图片一致,如果使用mps加速,结果就出现错乱,但使用cpu,结果就是符合预期的,我想知道这到底是什么问题。
Environment
YOLOv5 🚀 v7.0-348-g6deb2d75 Python-3.11.9 torch-2.5.0.dev20240727 CPU
Apple M1 Max 32G
MacOS 14.5 (23F79)
Minimal Reproducible Example
我使用的是anaconda创建版本为Python 3.11.9的虚拟环境,并使用
在此时,删除现有的pytorch,安装最新版的nightly版
此时我所有包的版本如下:
按照这个步骤应该就能跟我的环境一致,然后就能按照我的步骤还原问题
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: