安装caffe2 Ubuntu

1.安装一些依赖包

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
#  Ubuntu 14.04  //按版本选一个安装
sudo apt-get install -y --no-install-recommends libgflags2
#  Ubuntu 16.04
sudo apt-get install -y --no-install-recommends libgflags-dev

2.git克隆

# 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

如果报错:

[ 93%] Linking CXX executable ../bin/mpi_test
/usr/bin/ld: CMakeFiles/mpi_test.dir/mpi/mpi_test.cc.o: undefined reference to symbol '_ZN3MPI8Datatype4FreeEv'
//usr/lib/libmpi_cxx.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
caffe2/CMakeFiles/mpi_test.dir/build.make:100: recipe for target 'bin/mpi_test' failed
make[3]: *** [bin/mpi_test] Error 1
make[3]: Leaving directory '/home/suda/caffe2/build'
CMakeFiles/Makefile2:2750: recipe for target 'caffe2/CMakeFiles/mpi_test.dir/all' failed
make[2]: *** [caffe2/CMakeFiles/mpi_test.dir/all] Error 2
make[2]: Leaving directory '/home/suda/caffe2/build'
Makefile:138: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/suda/caffe2/build'
Makefile:4: recipe for target 'all' failed

make: *** [all] Error 2

使用命令:cmake .. -DUSE_MPI=OFF 可以解决

DUSE_MPI是多机并行计算才会用到,一般没有用,可以关闭

ps:心得,似乎好多问题百度并不能解决,建议去github源码的issue那里搜索,比如这个问题

https://github.com/caffe2/caffe2/issues/2144


3.测试是否安装成功

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

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页