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

Update requirements.txt comment https://pytorch.org/get-started/locally/ #9576

Merged
merged 3 commits into from
Sep 25, 2022
Merged

Conversation

davidamacey
Copy link
Contributor

@davidamacey davidamacey commented Sep 25, 2022

Problem: When using default requirements file, package install does not automatically included CUDA version of PyTorch, thus not allowing me to use local GPUs on my system.

Proposed Solution: Add '--extra-index-url https://download.pytorch.org/whl/cu116' URL to requirements file under any PyTorch requirement (torch, torchvision, torchaudio) for ease of creating venv with CUDA enabled PyTorch. Otherwise CPU PyTorch is installed and unable to take advantage of local GPUs.

Example:
Using my local machine using this workflow:
git clone https://github.com/ultralytics/yolov5.git
python3 -m venv .yoloenv
source .yoloenv/bin/activate
pip3 install -r requirements.txt

Opening and running tutotial.ipynb, I get the following errors:
yolov5_env_standard

After updating requirements with proposed changes, I removed the venv .yoloenv and recreated new venv (same as above).

Now running tutorial.ipynb, I am able to use my GPUs with CUDA enabled:
yolov5_with_extraurl_req

I understand not all users have local access to GPUs; but this change will allow users to quickly reference the CUDA version of PyTorch on install. For wide dissemination, the extra-index-url could be included in requirements, but commented out for users who would like to use for installing requirements more easily.

Signed-off-by: David A. Macey davidamacey@gmail.com

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Enhanced installation guidance for PyTorch in the YOLOv5 requirements.

📊 Key Changes

  • Updated requirements.txt with a comment for PyTorch installation guidance.

🎯 Purpose & Impact

  • 🔍 Provides users with a direct link to the PyTorch installation page for more detailed installation instructions.
  • 🤝 Helps to ensure users select the correct version of PyTorch for their system, leading to smoother installations and fewer compatibility issues.

Added --extra-index-url https://download.pytorch.org/whl/cu116 URL to requirements file for ease of creating venv with CUDA enabled PyTorch.  Otherwise CPU PyTorch is installed an unable to use local GPUs.

Signed-off-by: David A. Macey <davidamacey@gmail.com>
Copy link
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 @davidamacey, 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 ultralytics/yolov5 master branch. If your PR is behind you can update your code by clicking the 'Update branch' button or by running git pull and git merge master locally.
  • ✅ Verify all YOLOv5 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
Member

@davidamacey thanks for the PR!

This message typically appears for newer GPUs when the base torch CUDA version has not caught up yet to the new hardware.

Since unfortunately there's no one-size fits all torch version it's usually worth a trip over to https://pytorch.org/get-started/locally/ to get the optimal install command for your particular situation.

I don't know what effect the additional --extra-index-url would have across the userbase, but if it made sense to use this as the default then I'm sure torch would already be doing this.

In contrast some CPU only installs benefit from a separate --extra-index-url, so I don't think its a good idea to include one in requirements.txt by default since it might differ with manual user additions.

pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu

@davidamacey
Copy link
Contributor Author

@glenn-jocher Good Morning! Thank you for the prompt response. I appreciate the thorough answer. Given the wide range of users configurations, I understand this would be difficult to mitigate.

What about amending the requirements file to include a comment to the PyTorch Link?
"# For loading CUDA PyTorch please visit: https://pytorch.org/get-started/locally/"

Just a suggestion.

Thanks again for taking the time to review my PR!

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@glenn-jocher glenn-jocher changed the title Update Requirements with PyTorch CUDA Update requirements.txt comment https://pytorch.org/get-started/locally/ Sep 25, 2022
@glenn-jocher glenn-jocher merged commit ee91dc9 into ultralytics:master Sep 25, 2022
@glenn-jocher
Copy link
Member

@davidamacey yes good idea. I've added a comment to visit https://pytorch.org/get-started/locally/

PR is merged. Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐

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.

None yet

2 participants