anaconda3安装caffe

使用anaconda3安装caffe踩坑无数次,放弃治疗,直接在~/.bashrc中删除anaconda的路径,备份一下等要用的时候再写上,用默认的python2.7系统环境安装

要使用人脸检测项目中的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







posted @ 2019-01-03 20:09 amazingym 阅读(...) 评论(...) 编辑 收藏