How to install Detectron2
Asked Answered
A

4

5

I am installing layout-parser and following this link. Did not face any issues with the following packages.  

pip install layoutparser    
pip install "layoutparser[effdet]"    
pip install layoutparser torchvision     
pip install "layoutparser[paddledetection]"    
pip install "layoutparser[ocr]" 

But I am not able to install detectron2

pip install "git+https://github.com/facebookresearch/[email protected]#egg=detectron2" 

while installing this package I am getting this error    

ERROR: Could not find a version that satisfies the requirement detectron2 (unavailable) (from versions: none)

ERROR: No matching distribution found for detectron2 (unavailable)

I followed the same installation guide in Google collab and it worked but not able to install them in my Azure workspace.  

Asymmetry answered 6/2, 2023 at 6:19 Comment(0)
P
7

Open a terminal or command prompt. Create a new environment called detectron2-env with the following command:

conda create --name detectron2-env python==3.9 -y

Activate the environment with the following command:

Linux

conda activate detectron2-env

Windows

activate detectron2-env

Install the dependencies with the following commands:

pip3 install torch torchvision torchaudio
git clone https://github.com/facebookresearch/detectron2.git
python -m pip install -e detectron2

For more help, please refer to the following documentation:

https://detectron2.readthedocs.io/en/latest/tutorials/install.html

Physical answered 19/5, 2023 at 7:52 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Sciuroid
E
6

Check your python version. If you have Python version as 3.10 or higher you will face this issue. This is because detectron2 library has only wheels for <= Python 3.9.

Ephemerid answered 16/2, 2023 at 7:53 Comment(1)
The list of whl files and supported Python versions can be found here . E.g. for cuda 11.3 whl the link for whl is this and supported versions are: detectron2-0.6+cu113-cp39-cp39-linux_x86_64.whl detectron2-0.6+cu113-cp38-cp38-linux_x86_64.whl detectron2-0.6+cu113-cp37-cp37m-linux_x86_64.whl detectron2-0.6+cu113-cp36-cp36m-linux_x86_64.whlNingsia
B
0

In colab, I use:

!pip install -q torch torchvision --index-url https://download.pytorch.org/whl/cu118
!pip install -q 'git+https://github.com/facebookresearch/detectron2.git'

For windows, there is the great conda issue.

Bosom answered 19/1 at 0:41 Comment(0)
D
0

I found extremely tricky to get all the dependencies right, to install detectron2. So I am leaving here the complete set of instructions to set up the environment (only with conda and pip).

# Create conda env
conda create --name detectron2 python==3.9 -y
conda activate matcher

# Install torch
pip install torch torchvision

# Install gcc and g++ with conda 
conda install -c conda-forge pybind11
conda install -c conda-forge gxx
conda install -c anaconda gcc_linux-64
conda upgrade -c conda-forge --all

# Install detectron2 (specific version)
pip install 'git+https://github.com/facebookresearch/[email protected]'
Dashpot answered 26/4 at 11:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.