下載caffe并保存到一個目錄下(推薦放到 /home 目錄)
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler sudo apt-get install --no-install-recommends libboost-all-dev sudo apt-get install libatlas-base-dev sudo apt-get install python-dev sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev sudo apt-get install python-lmdb sudo apt-get install python-pip 5.下載Caffe: sudo apt-get install git 并修改配置文件 cd caffe 備份文件 cp Makefile.config.example Makefile.config
gedit Makefile.config # Whatever else you find you need goes here. INCLUDE_DIRS := $(Python_INCLUDE) /usr/local/include LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib 修改為 # Whatever else you find you need goes here. INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial /usr/local/cuda-7.5/targets/x86_64-linux/ LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib/ /usr/lib/x86_64-linux-gnu/hdf5/serial /usr/local/cuda-7.5/targets/x86_64-linux/ LIBRARIES += glog gflags protobuf leveldb snappy lmdb boost_system hdf5_hl hdf5 m opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs 編譯caffe: make all -j4 make test -j4 make runtest make all時有cublas_v2.h: No such file or directory的錯誤 原以為是caffe編譯時沒有正確編譯CPU版本,或者caffe/util/device_alternate.hpp里未能正確判斷,但查看源文件發(fā)現(xiàn)此處正常,原來是我的項目中,在編譯時需要指定CPU_ONLY選項,即在我的項目Makefile里添加下面一句即可 CXXFLAGS += -DCPU_ONLY=1 如果只時使用CPU,打開注釋CPU_ONLY=1即可 參考鏈接:https://blog.csdn.net/qq_38451119/article/details/81126692 去掉CPU—only選項前的注釋,使之生效,若需Python layer,則還需去掉WITH_PYTHON_LAYER :=1前的注釋 編譯python接口 sudo pip install -r python/requirements.txt make pycaffe 編譯matlab接口 make matcaffe gedit ~/.bashrc 最后面添加: rm *~ 可考慮刪除因修改而自動生成的備份文件 安裝GPU版本 CUDA安裝推薦鏈接: |
|