Caffe2源码编译安装

参考了https://blog.csdn.net/hyk900817/rss/list,但有些情况不一样,记录如下:


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

2、cd pytorch,mkdir build

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

4、pip install flask graphviz hypothesis jupyter matplotlib pydot pyyaml requests scikit-image scipy setuptools tornado

5、mv ./

6、cd build 

6、cmake -DCMAKE_PREFIX_PATH=~/anaconda2 -DCMAKE_INSTALL_PREFIX=~/anaconda2 -DUSE_NATIVE_ARCH=ON ..

7、将  eigen  放在/usr/include/eigen3位置

8、pytorch->caffe2->CMakefiles.txt 

添加如下到最后行就可以了: 

SET(CMAKE_C_COMPILER mpicc) 

SET(CMAKE_CXX_COMPILER mpicxx) 

include_directories(MPI_INCLUDE_PATH)

target_link_libraries(mpi_test ${MPI_LIBRARIES})

9、make  install

10、将export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/bainuo/anaconda2/lib

11:测试方式   python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"

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


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

cd detectron        ,make

测试:  python ./tests/test_spatial_narrow_as_op.py

你可能感兴趣的:(Caffe2源码编译安装)