ubuntu 14.04上安装Caffe
2018-09-09 本文已影响0人
crazyhank
- 从github上下载代码
#git clone https://github.com/BVLC/caffe.git
- 如果使用python进行开发,需要安装依赖的库
#cat python/requirements.txt | xargs -L 1 sudo pip install
- 准备Makefile
#cp Makefile.config.example Makefile.config
- 修改Makefile
(1)我这里只编译CPU版本,将Makefile.config文件中的“CPU_ONLY := 1”一行注释符号去掉。
(2)因为之前安装python依赖库的时候路径有点出入,修改
PYTHON_INCLUDE := /usr/include/python2.7 \ /usr/lib/python2.7/dist-packages/numpy/core/include
变成
PYTHON_INCLUDE := /usr/include/python2.7 \ /usr/local/lib/python2.7/dist-packages/numpy/core/include
(3)要在Makefile文件中,针对编译器选项上显式的加上C++11支持,如下:
# Automatic dependency generation (nvcc is handled separately)
CXXFLAGS += -MMD -MP -std=c++11
LINKFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS) -std=c++11
- 编译
#make pycaffe
#make all
- 测试
测试之前需要将caffe的python模块路径加入到PYTHON_PATH中去:
#echo "PYTHONPATH=/home/hank/Study/CV/caffe.git/python" >> ~/.bashrc
#source ~/.bashrc
然后执行一下:
hank@hank-desktop:~/Study/CV/caffe.git$ python
Python 2.7.6 (default, Nov 23 2017, 15:49:48)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
>>> print caffe.__version__
1.0.0
>>>
安装完成!