五,安装caffe2

1,创建anaconda3下面的虚拟环境:

conda create -n caffe2_py3 python=3.6

source activate caffe2_py3

2,安装python需要的包

conda install -y future
conda install -y gflags
conda install -y leveldb
conda install -y mkl   
conda install -y mkl-include  
conda install -y numpy   
conda install -y opencv   
conda install -y protobuf  
conda install -y six
conda install -y lmdb

conda install -y matplotlib

conda install -y flask
conda install -y graphviz

conda install -y hypothesis
conda install -y jupyter
conda install -y pydot
conda install -y pyyaml
conda install -y requests
conda install -y scikit-image
conda install -y scipy
conda install -y setuptools
conda install -y tornado

conda install -c menpo opencv3 

conda install -y cython  ipython h5py nose pandas protobuf

conda install -y spyder

3,下载caffe2 编译

cd ~

git clone --recursive https://github.com/pytorch/pytorch.git

cd pytorch

git submodule update --init

 mkdir build && cd build

cmake -DCMAKE_PREFIX_PATH=~/anaconda3/envs/caffe2_py3 -DCMAKE_INSTALL_PREFIX=~/anaconda3/envs/caffe2_py3 -DUSE_NATIVE_ARCH=ON  ..

make

caffe2的好处是: Makefile中会根据你的库进行make,省去了makefile.config的设置步骤。

make install

4,测试:

cd  /home/xxxxx/Downloads/caffe/pytorch/build

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

2)执行 python

import caffe2.python.core #导入这个包,看看是否成功,如果没报错,就OK了。

猜你喜欢

转载自blog.csdn.net/yanlizhong62/article/details/84100647