Search code examples
pythonpytorchobject-detectionyolov5

Installing YOLOv5 dependencies - torchvision?


I want to use yolov5. According to https://pytorch.org/hub/ultralytics_yolov5/, you should have Python>=3.8 and PyTorch>=1.7 installed, as well as YOLOv5 dependencies.

Python and pytorch are up to date:

pip show torch
Version: 1.7.1

python --version
Python 3.9.1

But when I try to install the yolov5 dependencies, I get an error message:

pip install -qr https://raw.githubusercontent.com/ultralytics/yolov5/master/requirements.txt
ERROR: Could not find a version that satisfies the requirement torchvision>=0.8.1
ERROR: No matching distribution found for torchvision>=0.8.1

An updated version of torchvision is needed (???). So I run the update, but when I check the version it hasn't worked.

pip show torchvision
Version: 0.2.2.post3

-m pip install --upgrade torchvision

pip show torchvision
Version: 0.2.2.post3

Is torchvision needed for installing the yolov5 dependencies? How do I move forward? I'm on Windows 10.

Thanks!


Solution

  • I was getting similar error. Installing fresh compatible libraries (torch==1.7.1 & torchvision==0.8.2) worked for me.

    virtualenv -p python3.8 torch17
    source torch17/bin/activate
    pip install cython matplotlib tqdm scipy ipython ninja yacs opencv-python ffmpeg opencv-contrib-python Pillow scikit-image scikit-learn lmfit imutils pyyaml jupyterlab==3
    pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
    

    Be careful about your cuda version and install accordingly. Mine is 10.1. Simply using pip install torch==1.7.1 will install latest cuda version (11) compatible lib which might not be your case.

    Virtual environment activation command will be different for Windows. I am on Linux