My method to install detectron2 for Windows 10 with Anaconda (April 9th 2022)
Here's the env file consist of 2 types of pytorch, the gpu (that CUDA enable), and the cpu only.
The first thing to do is to clone the detectron2 repository:
git clone https://github.com/facebookresearch/detectron2.git
And the requirements for Windows 10:
- Ninja for Windows (For reference see Ninja Build Website)
- Install MinGW 64-bit (CygWin is also ok)
- Install Visual Code Studio 2019
- Install Nvidia CUDA 11.0 (Or check the recommended version from the guide)
The requirements for your python environment using anaconda:
-
Python 3.8
-
Install pytorch for cuda >=11.0 (for reference see Pytorch Website). Example:
conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch
-
Install Cython
pip install cython
or
conda install -c anaconda cython
-
Install OpenCV
pip install opencv-python
-
Install Pywin32
pip install pywin32
or
conda install -c conda-forge pywin32
-
Install pycocotools
pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
-
Install git (if git doesn't detected on your cmd)
conda install -c anaconda git
For the steps, install these dependencies before install detectron2 to your python environment. For instaling detectron2 see here
Despite of manually install the anaconda environment for installing detectron2, here's the anaconda env (.yaml) file you can use. After import the venv, the next step you need to do is setup the detectron2:
-
Set the distutils
SET DISTUTILS_USE_SDK=1
-
Call the vcvars64.bat file to your cmd window:
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
-
Go to the detectron2 folder, and insert this command:
python setup.py build develop
-
Then, you can check the installation by check pytorch and detectron2 (See the official guide here1 or here2 to confirm the installation).
Detectron2
@misc{wu2019detectron2, author = {Yuxin Wu and Alexander Kirillov and Francisco Massa and Wan-Yen Lo and Ross Girshick}, title = {Detectron2}, howpublished = {\url{https://github.com/facebookresearch/detectron2}}, year = {2019} }
Pytorch
Pytorch Forum
Solution by RujunLong's comment
AugmentedStartups
Got some solution from this video by AugmentedStartups
Github Detectron2 Issue#9
You can see for other solutions here