由于要想要跑RA-CNN的程序看看效果,然而github上在暂时没有人把作者的代码实现为tensorflow和pytorch框架。因此这里记录一次安装ubuntu18.04 安装caffe的过程。希望不要翻车!
1.下载caffe
git clone https://github.com/BVLC/caffe.git
2.进入caffe文件夹,将Makefile.config.example的内容复制到Makefile.config
sudo cp Makefile.config.example Makefile.config
3.参照《深度学习与计算机视觉》](网上有电子版)中的第7章的caffe安装内容,修改Makefile.config 中内容。这里修改如下,
USE_CUDNN := 1 #line 5 使用cudnn
OPENCV_VERSION := 3 #line 21 opencv版本为3
WITH_PYTHON_LAYER := 1 #line 92 使用python 来写自定义曾
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/ #line 95
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial #line 96
4.根据cuda的版本,例如大于cuda > 9, 需要注释以下两行代码
-gencode arch=compute_30,code=sm_20 \
-gencode arch=compute_35,code=sm_21 \
#注意此时的配置是在系统环境中的python2.7里面,没有用到python3以及conda中环境。因此在编译make pycaffe -j 的时候,会报没有numpy的错误(我之前的numpy都安装在conda虚拟环境中),因此需要安装下系统的numpy
sudo apt-get install python-numpy
5.编译测试
sudo make test -j