anaconda3安装caffe
Posted yamin
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了anaconda3安装caffe相关的知识,希望对你有一定的参考价值。
要使用人脸检测项目中的caffe,因为该项目需要重新编译安装caffe,所以需要搭建一个新的环境,对于Python3.5版本
参考:https://blog.csdn.net/qq_33039859/article/details/80377356
首先创建先的环境
conda create -n caffe python=3.5
激活环境
source activate caffe
cp Makefile.config.example Makefile.config
因为是用anaconda安装所以要修改makefile.config
USE_INDEX_64 := 1
OPENCV_VERSION := 3
#PYTHON_INCLUDE := /usr/include/python2.7
#/usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it‘s in root.
ANACONDA_HOME := $(HOME)/anaconda3/envs/caffe
PYTHON_INCLUDE := $(ANACONDA_HOME)/include
$(ANACONDA_HOME)/include/python3.5m
$(ANACONDA_HOME)/lib/python3.5/site-packages/numpy/core/include
# Uncomment to use Python 3 (default is Python 2)
PYTHON_LIBRARIES := boost_python3 python3.5m
PYTHON_INCLUDE := /usr/include/python3.5m
/usr/lib/python3.5/dist-packages/numpy/core/include
# We need to be able to find libpythonX.X.so or .dylib.
# PYTHON_LIB := /usr/lib
PYTHON_LIB := $(ANACONDA_HOME)/lib
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
因为把路径换成了anaconda里面的Python路径,所以要在编译前敲如下命令
export CPLUS_INCLUDE_PATH=/home/amazing/anaconda3/envs/py27/include/python2.7
# Adjust Makefile.config (for example, if using Anaconda Python, or if cuDNN is desired)
make all
make test
make runtest
遇上了几个坑,usr/bin/ld:找不到Lxxx:解决办法:https://blog.csdn.net/bangdingshouji/article/details/52876051
其中hdf5要到/usr/lib/x86_64-linux-gnu/中找,把libhdf5_serial.so的建立一个软连接到libhdf5.so
找不到libcudnn.so.5:https://blog.csdn.net/weixin_43439673/article/details/84198228
安装python依赖项
for req in $(cat requirements.txt); do pip install $req; done
最后make pycaffe
以上是关于anaconda3安装caffe的主要内容,如果未能解决你的问题,请参考以下文章
Ubuntu16.04+CUDA9.0+CUDNNv7.1+opencv3.4.0+anaconda3+Matlab 2017a+caffe安装