Update requirements.txt comment https://pytorch.org/get-started/locally/ #9576
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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](https://user-images.githubusercontent.com/6076456/192139988-48b7347a-56d2-48b9-9ac2-10b7d2911a4a.png)
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](https://user-images.githubusercontent.com/6076456/192140059-ad5c6883-6a01-4c63-9c53-cb9eadfa0b43.png)
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 [email protected]
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Enhanced installation guidance for PyTorch in the YOLOv5 requirements.
📊 Key Changes
requirements.txt
with a comment for PyTorch installation guidance.🎯 Purpose & Impact