Ubuntu caffe-SSD安裝配置
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
整個完整的環境安裝大概就這樣,中間任何一個環節出錯都有可能導致後面的安裝不成功,所以只能一步步嘗試,有時還可能與網路有關