[深度學習] FAIR Detectron2安裝

GitHub原鏈接:https://github.com/facebookresearch/detectron2/blob/master/INSTALL.md

安裝

Colab Notebook有安裝Detectron2的說明.
Dockerfile也可以通過簡單的操作安裝Detectron2.

環境

  • Linux或macOS,Python ≥ 3.6
  • PyTorch ≥ 1.4
  • 與PyTorch版本一致的torchvision。一般在PyTorch安裝時就已經安裝。
  • OpenCV,可選,Demo和Visualization會用到
  • pycocotools: pip install cython; pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'

Build Detectron2 from Source

需要gcc & g++ ≥ 5。ninja 用來快速安裝.
執行:

python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
# (add --user if you don't have permission)

# 或者通過本地clone的工程
git clone https://github.com/facebookresearch/detectron2.git
python -m pip install -e detectron2

# 或者如果是MacOS
# CC=clang CXX=clang++ python -m pip install -e .

在重新編譯detectron2時,需要用rm -rf build/ **/*.so將原來的殘留文件刪除。在重裝PyTorch時,常常需要重裝Detectron2。

Install Pre-Built Detectron2 (只有Linux需要)

# for CUDA 10.1:
python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/index.html

可以根據實際需要替換cu101爲"cu{100,92}“或者"cpu”。

注意:

  1. 此安裝必須與PyTorch官方發行版一起使用。如releases 需要。它不適用於其他版本的PyTorch或非官方的PyTorch版本。
  2. 有可能此版本時過時的,與實際使用的版本不匹配,參見 projects or meshrcnn.

常見安裝問題(後續)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章