安装detectron需要安装Caffe2
caffe2安装步骤:
可参考:
点击打开链接
caffe2官方链接
caffe2 build from source
打开上述链接
两种方式供你选择:
1. Pre-Built Binaries
创建名为caffe2_py2的conda虚拟环境并激活,以避免与Tensorflow和老版Caffe的干扰(Detectron对Python3.x兼容性不佳,注意Python版本):
conda create -n caffe2_py2 python=2.7 && source activate caffe2_py2
此福利仅供cudnn7用户享用
安装CPU:
conda install -c caffe2 caffe2
安装GPU:
1. CUDA 9 and CuDNN 7 support:
conda install -c caffe2 caffe2-cuda9.0-cudnn7
2. CUDA 8 and CuDNN 7 support:
conda install -c caffe2 caffe2-cuda8.0-cudnn7
2. Build From Source
install Denpendencies
sudo apt-get update sudo apt-get install -y --no-install-recommends \ build-essential \ cmake \ git \ libgoogle-glog-dev \ libgtest-dev \ libiomp-dev \ libleveldb-dev \ liblmdb-dev \ libopencv-dev \ libopenmpi-dev \ libsnappy-dev \ libprotobuf-dev \ openmpi-bin \ openmpi-doc \ protobuf-compiler \ python-dev \ python-pip sudo pip install \ future \ numpy \ protobuf
# for Ubuntu 14.04 sudo apt-get install -y --no-install-recommends libgflags2 # for Ubuntu 16.04 sudo apt-get install -y --no-install-recommends libgflags-dev
Clone & Build
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# Clone Caffe2's source code from our Github repository git clone --recursive https://github.com/pytorch/pytorch.git && cd pytorch git submodule update --init # Create a directory to put Caffe2's build files in mkdir build && cd build # Configure Caffe2's build # This looks for packages on your machine and figures out which functionality # to include in the Caffe2 installation. The output of this command is very # useful in debugging. cmake .. # Compile, link, and install Caffe2 sudo make install |
选择上述中的一种方式进行安装caffe2
安装完成之后,进行Test
cd ~ && python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
如果输出Success安装成功
GPU:
python caffe2/python/operator_test/relu_op_test.py
输出OK安装成功
Other Dependencies
Install Python dependencies:
conda install -y pyyaml=3.12 matplotlib setuptools Cython mock scipy
Installthe
COCOAPI
:
# COCOAPI=/path/to/clone/cocoapi
git clone https://github.com/cocodataset/cocoapi.git $COCOAPI
cd $COCOAPI/PythonAPI
# Install into global site-packages
make install
# Alternatively, if you do not have permissions or prefer
# not to install the COCO API into global site-packages
python2 setup.py install --user
Note that instructions like #COCOAPI=/path/to/install/cocoapi
indicatethat you should pick a path where you'd like to have the softwarecloned and then set an environment variable (COCOAPI
inthis case) accordingly.
Clone the Detectron repository:
# DETECTRON=/path/to/clone/detectron
git clone https://github.com/facebookresearch/detectron $DETECTRON
Install Python dependencies:
pip install -r $DETECTRON/requirements.txt
Set up Python modules:
cd $DETECTRON && make
Check that Detectron tests pass (e.g. for SpatialNarrowAsOp test
):
python2 $DETECTRON/detectron/tests/test_spatial_narrow_as_op.py
输出OK说明安装成功
存在一个error:
需要安装pydot包 conda install -y pydot