caffe-ssd 安装
sudo apt-get update
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev
sudo apt-get install -y python-numpy python-scipy
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install python-skimage python-protobuf
sudo apt-get install git
git clone https://github.com/weiliu89/caffe.git
ls
cd caffe
git checkout ssd
cp Makefile.config.example Makefile.config
make之前需要修改Makefile.config 和Makefile里的相关内容
(用gedit的方式打开,vim可能需要修改文件的读写权限才能修改)
eg:Makefile.config
# Uncomment if you're using OpenCV 3
OPENCV_VERSION := 3
# CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the lines after *_35 for compatibility.
CUDA_ARCH := #-gencode arch=compute_20,code=sm_20 \ //这一行要注释掉
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_61,code=sm_61
# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include //一定要改成这样,不然caffe模块的导入只能被限制在caffe/python/这个路径下的Python终端
# 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的修改:
eg:Makefile
180行左右:LIBRARIES += glog gflags protobuf boost_system boost_filesystem boost_regex m hdf5_serial_hl hdf5_serial
265行左右:LIBRARIES += boost_thread stdc++ boost_regex
410行左右:NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
修改上面两个文件的配置之后要执行下面的指令才能生效:
sudo gedit ~/.bashrc //会打开一个文件,在文件的最后面添加下面两行
export PYTHONPATH=/home/你的路径/caffe/python:$PYTHONPATH //我这里就是我的name(wssfan)
export PYTHONPATH=/usr/local/lib/python2.7/dist-packages/:$PYTHONPATH
source ~/.bashrc //最后生效一下
修改好之后就可以执行下面的命令:
make clean
make all -j4
make test
make runtest
sudo make pycaffe
(选择性执行下面的这条,防止导入时报某些模块的导入错误)
sudo make distribute
如果在python终端导入caffe时报下面的错误
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: libopencv_core.so.3.4: cannot open shared object file: No such file or directory
执行:sudo ldconfig
整个完整的环境安装大概就这样,中间任何一个环节出错都有可能导致后面的安装不成功,所以只能一步步尝试,有时还可能与网络有关
(如果按照上面的方法无法安装成功一般还是在你们的那两个配置文件,可以问我要)