Caffe2 Detectron安装错误记录

caffe2

  1. caffe2的安装方法有几种。其中最方便的是conda install。但是要求必须安装Anaconda。
    conda install -c caffe2 caffe2-cuda8.0-cudnn7
    注意:cudnn的版本需要升级,未实验过cudnn5或cudnn6。如果gcc版本小于5,需要指明gcc版本,如:
    conda install -c caffe2 caffe2-cuda8.0-cudnn7-gcc4.8

另一种方式是下载源码编译安装。

  1. 预先安装好Cuda, cudnn, nccl
    安装了caffe的需留意cudnn版本,以及安装nccl
  2. 安装依赖库
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                          
pip install --user \
      future \
      numpy \
      protobuf
# 若系统为Ubuntu 16.04时,需要安装libgflags-dev
sudo apt install -y --no-install-recommends libgflags-dev
# 若系统为Ubuntu 14.04时,需要安装libgflags2
sudo apt-get install -y --no-install-recommends libgflags2
  1. 下载源码安装
    注意下载的是pytorch(版本为1.0),caffe2是作为其中一个模块。
git clone https://github.com/pytorch/pytorch.git && cd pytorch
git submodule update --init --recursive
python setup.py install

测试是否安装成功
cd ~ && python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
如果是Failure,在python终端内输入from caffe2.python import core, 可显示详细错误信息。
错误1: no moudle named past.builtins
解决方法:pip install future


安装Dectron官网教程

  1. 先安装好caffe2
  2. 安装coco API
# 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

在make install 如出现错误error: pycocotools/_mask.c: No such file or directory
解决方法:
pip install cython

测试时,出现错误:Detectron ops lib not found; make sure that your Caffe2 version includes Detectron module
跟踪问题,出现在detectron/utils/env.py文件的 def get_detectron_ops_libs():,函数在环境变量内没找到lib/libcaffe2_detectron_ops_gpu.so。这个文件在前面编译的caffe2(前文的pytorch)的 build/lib文件夹下,因此,在detectron/utils/env.py文件的import sys后追加:
sys.path.insert(0, '/path/to/your/pytorch/build')

posted @ 2018-09-18 17:05  alanma  阅读(1390)  评论(0编辑  收藏  举报