官方安装指导
0. 安装Cuda9.0+cuDNN7.4
1. anaconda创建虚拟环境:conda create -n detectron python=3.6.7
,进入环境,conda activate detectron
2. 进入pytorch官网https://pytorch.org/get-started/locally/ 安装pytorch: conda install pytorch torchvision cudatoolkit=9.0 -c pytorch
3. 验证pytorch内含的caffe2和能否用GPU:
我的笔记本安装pytorch能够import caffe2,但是from caffe2.python import core失败提示没有google模块。。。pip install google 还是提示报错。。后来按照Detectron安装配置与训练自己的数据文中的方法安装。
不过这里遇到了 No module named google.protobuf.internal 需要装2个包 protobuf
和feature
conda install protobuf
conda install future
验证通过
python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
Success
python -c 'from caffe2.python import workspace; print(workspace.NumCudaDevices())'
1
4. 安装cocoapi
在环境里提前安装好cython pip install cython
# 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
python setup.py install --user
5. 安装detectron:
# 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):
python $DETECTRON/detectron/tests/test_spatial_narrow_as_op.py