ubuntu16.04中安装caffe2 和 detectron教程

一,caffe2

我是参考caffe2官网,根据自己电脑的实际情况安装(ubuntu16.04),我安装的源码,不是镜像,为了之后的densepose模型打基础。

ubuntu16.04中安装caffe2 和 detectron教程_第1张图片

1,Install Dependencies(安装依赖项) 

sudo apt-get update
sudo apt-get install -y --no-install-recommends \
      build-essential \
      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 \
      typing \
      hypothesis

ubuntu16.04中安装caffe2 和 detectron教程_第2张图片 

ubuntu16.04中安装caffe2 和 detectron教程_第3张图片 

ubuntu16.04中安装caffe2 和 detectron教程_第4张图片 

 

# for Ubuntu 14.04
sudo apt-get install -y --no-install-recommends \
      libgflags2 \
      cmake3
# for Ubuntu 16.04
sudo apt-get install -y --no-install-recommends \
      libgflags-dev \
      cmake

ubuntu16.04中安装caffe2 和 detectron教程_第5张图片 

 2,Clone & Build

git clone https://github.com/pytorch/pytorch.git && cd pytorch
git submodule update --init --recursive
python setup.py install

注意我们是借助pytorch安装的caffe2

ubuntu16.04中安装caffe2 和 detectron教程_第6张图片

ubuntu16.04中安装caffe2 和 detectron教程_第7张图片 

 上面这个命令失败了不要紧,再下总有可以成功的时候哈哈

ubuntu16.04中安装caffe2 和 detectron教程_第8张图片

报错,没关系,缺什么安什么,pip install pyyaml   这下没问题了

继续。。。 

ubuntu16.04中安装caffe2 和 detectron教程_第9张图片 

3,Test the Caffe2 Installation(测试时候安装caffe2成功)

cd ~ && python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"

如果成功会出现success,如下图:

 

输入下面命令输出大于0就可以了:

python2 -c 'from caffe2.python import workspace; print(workspace.NumCudaDevices())'

 

 

 4,修改环境变量:

sudo gedit ~/.bashrc
在文件末尾输入:
export PYTHONPATH=/usr/local:$PYTHONPATH
export PYTHONPATH=$PYTHONPATH:/home/feng/pytorch/caffe2/build  (后面路径为caffe2的编译路径,在caffe2/build中,命令行输入pwd可以得到这个路径)
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

source ~/.bashrc






ubuntu16.04中安装caffe2 和 detectron教程_第10张图片

5,测试caffe2

ubuntu16.04中安装caffe2 和 detectron教程_第11张图片 

 二,安装detectron

参考官网:https://github.com/facebookresearch/Detectron/blob/master/INSTALL.md

1,定位到要下载的文件下面,我为了方便也下了pytorch里面了

git clone https://github.com/facebookresearch/detectron

ubuntu16.04中安装caffe2 和 detectron教程_第12张图片 

 

2,Install Python dependencies:

pip install -r $DETECTRON/requirements.txt

ubuntu16.04中安装caffe2 和 detectron教程_第13张图片

3,安装

cd $DETECTRON && make

ubuntu16.04中安装caffe2 和 detectron教程_第14张图片 

4,测试是否成功

python $DETECTRON/detectron/tests/test_spatial_narrow_as_op.py

ubuntu16.04中安装caffe2 和 detectron教程_第15张图片 

 出现以上界面就算成功了。。。

 

 

你可能感兴趣的:(ubuntu16.04中安装caffe2 和 detectron教程)