ubuntu18.04 caffe CPU安装

装了好几遍GPU版本的,出现了各种错误,所以简单装一个CPU版本先用,记录一下各种错误。

安装依赖包

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install python-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install python-opencv

如果安装过程中出现无法定位软件包

sudo apt-get update

下载caffe

git clone git://github.com/BVLC/caffe.git

cd caffe
cp Makefile.config.example Makefile.config


修改 Makefile.config   
gedit Makefile.config     

去掉CPU_ONLY :=1的注释 
注释掉CUDA有关的行: 
#CUDA_DIR := /usr/local/cuda 
#CUDA_DIR := /usr 
#CUDA_ARCH := .... 
#TEST_GPUID := 0 
去掉WITH_PYTHON_LAYER := 1的注释

修改这一行:
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib  /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial


修改 Makefile   
gedit Makefile    

opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs     
加入 opencv_imgcodecs  


再修改文件时,如果打开的文件是空白的,可能是路径不对,修改路径后重新打开。

修改   caffe/examples/cpp_classification/classification.cpp文件

加入

#include 
#include 

修改完成后编译

make all 
make test
make runtest

没有错误就是编译成功

接下来编译pycaffe

make pycaffe

编译完成后测试是否可用

cd python
python

#如果出现
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
>>>


参考博客:

https://blog.csdn.net/u011762313/article/details/47262549

https://blog.csdn.net/zhang_shuai12/article/details/52289825

https://blog.csdn.net/yggaoeecs/article/details/79163789

https://blog.csdn.net/a_z666666/article/details/72853346

你可能感兴趣的:(caffe)