1 sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler 2 sudo apt-get install --no-install-recommends libboost-all-dev 3 sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev 4 sudo apt-get install libatlas-base-dev
sudo apt-get install python-dev
下載地址 https://github.com/BVLC/caffepython
下載獲得caffe-master.zip,用unzip命令解壓。linux
(1)切換到Caffe所在目錄,複製一個Makefile.configgit
cp Makefile.config.example Makefile.config
(2)修改配置文件Makefile.configgithub
1 INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include 2 LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
1 INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial 2 LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial
計算能力 mkl > openlas >atlas,爲了簡便,默認atlas
1 make all -j16 2 make test -j16 3 make runtest -j16
-j16表示使用16核,這樣更快,根據本身電腦狀況。不用則單核app
sudo apt-get install python-pip
在caffe根目錄的python文件夾下,有一個requirements.txt的清單文件,上面列出了須要的依賴庫,按照這個清單安裝就能夠了。python2.7
在安裝scipy庫的時候,須要fortran編譯器(gfortran),若是沒有這個編譯器就會報錯,所以,咱們能夠先安裝一下。ui
首先回到caffe的根目錄,而後執行安裝代碼:google
1 cd ~/caffe-master 2 sudo apt-get install gfortran 3 cd ./python 4 for req in $(cat requirements.txt); do pip install $req; done
安裝完成之後,再次回到caffe根目錄咱們能夠執行:spa
1 cd .. 2 sudo pip install -r python/requirements.txt
就會看到,安裝成功的,都會顯示Requirement already satisfied, 沒有安裝成功的,會繼續安裝。操作系統
make pycaffe -j16
用python import caffe看接口成功沒有