ubuntu14.04 caffe2安装

参考链接:https://blog.youkuaiyun.com/u014525760/article/details/79862218

https://blog.youkuaiyun.com/weixin_37251044/article/details/82259230

这里我使用系统自带的python2.7对于caffe2进行安装,因为

系统自带的python2.7的环境变量设置:

alias python='/usr/bin/python2.7'

cmake要大于等于3.5,protobuf的版本需要时2.6.1,太高不支持

最后的环境变量需要设置为:

#这个需要注意:在环境变量当中只能有一个PYTHONPATH,多了的需要注释掉
export PYTHONPATH=pytorch根目录/build:$PYTHONPATH

一,依赖项安装

 
  1. sudo apt-get update

  2. sudo apt-get install -y --no-install-recommends \

  3. build-essential \

  4. cmake \

  5. git \

  6. libgoogle-glog-dev \

  7. libgtest-dev \

  8. libiomp-dev \

  9. libleveldb-dev \

  10. liblmdb-dev \

  11. libopencv-dev \

  12. libopenmpi-dev \

  13. libsnappy-dev \

  14. libprotobuf-dev \

  15. openmpi-bin \

  16. openmpi-doc \

  17. protobuf-compiler \

  18. python-dev \

  19. python-pip

  20. sudo pip install \

  21. future \

  22. numpy \

  23. protobuf

Note libgflags2 is for Ubuntu 14.04. libgflags-dev is for Ubuntu 16.04.

 
  1. # for Ubuntu 14.04

  2. sudo apt-get install -y --no-install-recommends libgflags2

  3. # for Ubuntu 16.04

  4. sudo apt-get install -y --no-install-recommends libgflags-dev

二,caffe2安装

 
  1. # Clone Caffe2's source code from our Github repository

  2. git clone --recursive https://github.com/pytorch/pytorch.git && cd pytorch

  3. git submodule update --init

  4.  
  5. # Create a directory to put Caffe2's build files in

  6. mkdir build && cd build

  7.  
  8. # Configure Caffe2's build

  9. # This looks for packages on your machine and figures out which functionality

  10. # to include in the Caffe2 installation. The output of this command is very

  11. # useful in debugging.

  12. #指定python路径

  13. sudo cmake .. -DPYTHON_INCLUDE_DIR=/usr/include/python2.7  -DUSE_MPI=OFF.

  14.  
  15. # Compile, link, and install Caffe2

  16. sudo make install

三,测试

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

If this fails, then get a better error message by running Python in your home directory and then running from caffe2.python import coreinside Python.

 

If this fails with a message about not finding caffe2.python or not finding libcaffe2.so, please see this info on how Caffe2 installs in Python.

If you installed with GPU support, test that the GPU build was a success with this command (run from the top level pytorch directory). You will get a test output either way, but it will warn you at the top of the output if CPU was used instead of GPU, along with other errors such as missing libraries.

python caffe2/python/operator_test/relu_op_test.py

 

错误总结

1), #error "Caffe2 requires Eigen to be at least 3.3.0.";

The solution is:

  1. Check the Eigen version with:   cat /usr/include/eigen3/Eigen/src/Core/util/Macros.h | grep VERSION
  2. It will show some version variable values like below:

     EIGEN_WORLD_VERSION 3 

     EIGEN_MAJOR_VERSION 2 

     EIGEN_MINOR_VERSION 192

These values are telling your problem directly. Your Eigen version is 3.2.192 instead of 3.3.0. So we need to upgrade this package.

  1. Install the latest version of eigen from http://eigen.tuxfamily.org/index.php?title=Main_Page .

  2. Extract the file wherever you want and rename it to eigen3.

  3. cd /usr/include

  4. sudo rm -rf eigen3/

  5. Place the file you just extracted withsudo mv path/of/eigen3 /usr/include/

  6. Lastly check the version again with cat /usr/include/eigen3/Eigen/src/Core/util/Macros.h | grep VERSION

You should see these variables:

     EIGEN_WORLD_VERSION 3

     EIGEN_MAJOR_VERSION 3

     EIGEN_MINOR_VERSION 4

You can run sudo make install again in the caffe2 directory and you will see that everything will be installed succesfully!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值