Ubuntu 14.04安裝 Caffe

安裝Caffe的過程,是在前幾篇博客先安裝CUDA 6.5然後再安裝openCV, MATLAB,Python成功基礎上安裝成功,

因此,最終Caffe安裝的成功,也需要參考前幾篇博客!可參考序號步驟進行安裝!


7. 安裝Caffe
7.1 先裝git: sudo apt-get install git
7.2 初始化遠程服務器地址: git init
7.3 添加遠程服務器地址: git remote add mycaffe https://github.com/BVLC/caffe/
7.4 克隆遠程服務器caffe文件到本地硬盤/home/wangchuan/ caffe_install文件夾中: git clone https://github.com/BVLC/caffe/ caffe_install
7.5 在caffe_install文件夾下,複製Makefile.config.example然後修改Makefile.config中的設置:
sudo cp Makefile.config.example Makefile.config
7.6 修改Makefile.config中的參數設置: sudo gedit Makefile.config
   修改參數包括: CPU_PNLY是否只用CPU模式,沒有安裝GPU的可以取消註釋這個選項
BLAS:使用Intel MKL還是 OpenBLAS
 MATLAB_DIR需要指定matlab安裝路徑,比如本機路徑爲/usr/local/MATLAB/R2013a(注意該目錄下需要包含bin文件夾,

bin下包含mex二進制程序)
DEBUG 是否使用debug模式
        7.7 保存退出,在/home/wangchuan/caffe_install 目錄下開始編譯:
make all -j4   如果是8核cpu, -j8

PS:
7.7.1 在make編譯時,可能會出現/usr/lib/x86_64-linux-gnu/libx264.so.142: undefined reference to `__powf_finite@GLIBC_2.15'
collect2: error: ld returned 1 exit status
或者bc:symbol lookup error
               等編譯錯誤時,一般刪除anaconda/lib下的動態鏈接庫: sudo rm ~/anaconda/libm.*
               然後再編譯make
7.7.2 在make編譯時出現libopencv_highgui.so:undefined reference to 'TIFFIsTiled@LIBTIFF_4.0'
在openCV_install文件夾下,修改install.sh中添加cmake -D BUILD_TIFF=ON


7.8 安裝最新的libhdf5, http://www.hdfgroup.org/HDF5/release/obtain5.html下載


7.9 將解壓的目錄拷貝到/usr下的對應路徑:
sudo cp -r ./bin /usr
sudo cp -r ./include /usr
sudo cp -r ./lib /usr
sudo cp -r ./share /usr

7.10 執行: make test

7.11 執行: make runtest

出現信息: YOU HAVE 2 DISABLED TESTS 說明Caffe runtest 成功!



8. 測試Caffe
8.1 在/home/wangchuan/caffe_install目錄下執行編譯MATLAB接口: make matcaffe
8.2 在/home/wangchuan/caffe_install目錄下執行編譯Python接口: make pycaffe
8.3 更新Matlab使用的c++庫:
   必須在/usr/local/R2013a/sys/os/glnxa64/ 運行
   sudo ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19 libstdc++.so.6
8.4 下載測試模型bvlc_reference_caffenet.caffemodel,

網址https://github.com/BVLC/caffe/tree/master/models/bvlc_reference_caffenet
8.5 拷貝到/home/wangchuan/caffe_install/models/bvlc_reference_caffenet/路徑下,並執行權限:
   sudo chmod 777 bvlc_reference_caffenet.caffemodel
8.6 打開Matlab找到/home/wangchuan/caffe_install/matlab/caffe路徑,輸入指令:
>> im = imread('/home/wangchuan/caffe_install/examples/images/cat.jpg');
>> scores = matcaffe_demo(im, 1);
8.7 運行返回一組數組,說明Caffe運行demo成功!


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章