Our Colab Notebook
has step-by-step instructions that install detectron2.
The Dockerfile
also installs detectron2 with a few simple commands.
pip install git+https://github.com/facebookresearch/fvcorepip install cython; pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPIAfter having the above dependencies, run:
git clone https://github.com/facebookresearch/detectron2.git
cd detectron2
python setup.py build develop
# or if you are on macOS
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py build develop
# or, as an alternative to `setup.py`, do
# pip install [--editable] .
Note: you may need to rebuild detectron2 after reinstalling a different build of PyTorch.
Undefined torch/aten symbols, or segmentation fault immediately when running the library.
This may be caused by the following reasons:
detectron2 or torchvision is not compiled with the version of PyTorch you're running.
If you use a pre-built torchvision, uninstall torchvision & pytorch, and reinstall them
following pytorch.org.
If you manually build detectron2 or torchvision, remove the files you built (build/, **/*.so)
and rebuild them.
detectron2 or torchvision is not compiled using gcc >= 4.9.
You'll see a warning message during compilation in this case. Please remove the files you build,
and rebuild them.
Technically, you need the identical compiler that's used to build pytorch to guarantee
compatibility. But in practice, gcc >= 4.9 should work OK.
Undefined cuda symbols. The version of NVCC you use to build detectron2 or torchvision does
not match the version of cuda you are running with.
This happens sometimes when using anaconda.
"Not compiled with GPU support": make sure
python -c 'import torch; from torch.utils.cpp_extension import CUDA_HOME; print(torch.cuda.is_available(), CUDA_HOME)'
int valid outputs at the time you build detectron2.
"invalid device function" or "no kernel image is available for execution": two possibilities:
TORCH_CUDA_ARCH_LIST environment variable during installation.