安装caffe
前提:安装好cuda8, cudnn, opencv3
参考:
http://caffe.berkeleyvision.org/install_apt.html
https://blog.csdn.net/yhaolpz/article/details/71375762
http://3ms.huawei.com/km/blogs/details/5425467
http://3ms.huawei.com/km/blogs/details/5577119
- git clone https://github.com/BVLC/caffe.git(修改过以适配yolov3)->/data0/hhq/project/caffe-master/
caffe-master, mv Makefile.config.example Makefile.config ```修改 1
2
将
#USE_CUDNN := 11
修改成:
USE_CUDNN := 11
2
将
#OPENCV_VERSION := 31
修改为:
OPENCV_VERSION := 31
2
将
#WITH_PYTHON_LAYER := 11
修改为
WITH_PYTHON_LAYER := 11
2
打开anaconda3下的python并使用boost python
ANACONDA_HOME := /data/softinstall/anaconda3
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
$(ANACONDA_HOME)/include/python3.6m \
$(ANACONDA_HOME)/lib/python3.6/site-packages/numpy/core/include
Uncomment to use Python 3 (default is Python 2)
PYTHON_LIBRARIES := boost_python3 python3.5m1
2
添加include lib
USE_PKG_CONFIG := 1
INCLUDE_DIRS += /usr/include/hdf5/serial /data/soft/opencv-3.4.0/include/
LIBRARY_DIRS += /usr/lib/x86_64-linux-gnu/hdf5/serial/1
2
在文件末尾添加上,添加最后一行是因为编译的时候去conda/lib下去找zlib.so这个包
LINKFLAGS := -Wl,-rpath,/data/softinstall/anaconda3/lib1
2
3
- make -j24
- ```cd caffe-master, make pycaffe -j8
- 测试, import caffe
- 使用的时候,先添加bashrc
1 |
|
caffe_root=’/data/project/caffe/python’
import sys
sys.path.insert(0, caffe_root+’python’)1
2
3
4
### 报错
- ```/data/softinstall/anaconda3/lib/libpng16.so.16:对‘inflateValidate@ZLIB_1.2.9’未定义的引用```,添加```LINKFLAGS := -Wl,-rpath,/data/softinstall/anaconda3/lib
找不到库
1
2
3
4/usr/bin/ld: 找不到 -lboost_python3
/usr/bin/ld: 找不到 -lpython3.5m
/usr/bin/ld: 找不到 -lcblas
/usr/bin/ld: 找不到 -latlas1
2
3先查找,再安装
apt-cache search atlas
sudo apt-get install libatlas-base-dev/usr/lib/x86_64-linux-gnu/``` 1
2
```sudo ln -s libpython3.5m.so.1 libpython3.5m.sosudo ln -s libboost_python-py35.so libboost_python3.so