一直想將DL用於自己目前研究的image retrieval中,實際上,本小子在之前的博文Deep Learning for Content-Based Image Retrieval關於用DL做檢索的paper也做了些調研。可以看出,雖然DL現在很火,但是將其用於image retrieval似乎還並不多。這連天正好忙裡偷閒,在Ubuntu12.04中把caffe搗鼓了一番,成功,只能說配置起來真的很egg pain。下面是自己在配置過程中出現的一些問題,配置的時候自己特地做了筆記,便於後面查閱。
1、 CUDA內建了顯卡驅動,安裝後圖形介面解析度變模糊,NVIDIA圖形配置是出現:
You do not appear to be using the NVIDIA X driver. Please edit your X configuration file (just run nvidia-xconfig as root), and restart the X server
主要是由於沒啟用安裝的顯卡:
I was also facing the same problem. Now that you asked it, I wanted to fix >in my computer as well. So here is how you do it.
EDIT: sudo apt-get install nvidia-current
sudo nvidia-xconfig. This will just create the file /etc/X11/xorg.conf. Next do
sudo software-properties-gtk
答案連結按照上面安裝後,重啟,完成啟用。
2、/include/caffe/common.hpp:5:27: 致命錯誤: gflags/gflags.h:沒有那個檔案或目錄編譯中斷。make: *** [.build_release/src/caffe/common.o] 錯誤。可以看出跟gflags有關,大概推測是gflags沒裝,於是按照教程把下面的都安裝了:
# 安裝glog/gflags/lmdb# glogwget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gztar zxvf glog-0.3.3.tar.gzcd glog-0.3.3./configuremake && make install# gflagswget https://github.com/schuhschuh/gflags/archive/master.zipunzip master.zipcd gflags-mastermkdir build && cd buildexport CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1make && make install# lmdbgit clone https://gitorious.org//mdb/mdb.gitcd mdb/libraries/liblmdbmake && make install
3、如果用make all編譯caffe時出現mkl錯誤:./include/caffe/util/mkl_alternate.hpp:6:17: 致命錯誤: mkl.h:沒有那個檔案或目錄 編譯中斷。主要是因為MKL與CUDA的環境設定沒設定好。另外安裝MKL時最好選擇預設路徑:
/opt/intel/lib/intel64/opt/intel/mkl/lib/intel64
4、出現:/usr/bin/ld: cannot find -lboost_system collect2: ld 返回 1make: *** [.build_release/lib/libcaffe.so] 錯誤。這個需要安裝libboost-dev,運行下面命令即可完成按照:
sudo apt-get install libboost-all-dev
安裝Caffe並測試。切換到Caffe的下載檔案夾,然後執行:
$ cp Makefile.config.example Makefile.config
修改新產生的Makefile.config檔案,修改“BLAS := mkl”,這個非常重要。
$ make clean$ make all$ make test$ make runtest
建立cuda.conf,並編輯之:
$ sudo touch cuda.conf$ sudo vim cuda.conf
在建立的cuda.conf中添加:
/usr/local/cuda/lib64/lib
完成lib檔案的連結操作,執行:
$ sudo ldconfig -v
5、When ./create_mnist.sh, fault: convert_mnist_data.bin: not found
這個問題,在caffe github上有人提出了issue,連結傳送門,按照答案說的,對於caffe,必須得在caffe的根目錄,所以根目錄運行指令碼吧。
最後,如果沒用GPU的話,在examples/mnist/lenet_solver.prototxt最後一行修改GPU為CPU。 caffe python介面安裝
1、 如果沒有pip的話,先安裝pip。進入caffe python目錄,安裝所需要的依賴關係:
sudo pip install -r requirement.txt
用requirements.txt失敗,用 Anaconda安裝sudo pip install -r /path/to/caffe/python/requirements.txt在執行上述命令時, 會報錯導致不能完整安裝所有需要的包。 可以按照官方建議安裝anaconda包。 在anaconda官網下載.sh檔案,執行,最後添加bin目錄到環境變數即可(在安裝的時候會詢問你時是否添加)。
注意:Anaconda安裝的庫並沒有在python的庫目錄中。
2、 錯誤:libm.so.6: GLIBC_2.15 not found, required by libopencv。。。將libm.so.6和libm.so重新命名為別的即可,比如:
sudo mv libm.so.6 libm.so.6.backupsudo mv libm.so libm.so.backup
3、 你需要安裝ipython和ipython qtconsole。安裝完後可以用下面的指令碼測試:
import syssys.path.append('/home/yong/anaconda/lib/python2.7/site-packages')sys.path.append('/usr/lib/python2.7/dist-packages')import numpy as npimport matplotlib.pyplot as plt%matplotlib inline# Make sure that caffe is on the python path:caffe_root = '../' # this file is expected to be in {caffe_root}/examplessys.path.insert(0, caffe_root + 'python')import caffeplt.rcParams['figure.figsize'] = (10, 10)plt.rcParams['image.interpolation'] = 'nearest'plt.rcParams['image.cmap'] = 'gray'
參考:
caffe官網
Ubuntu12.04上面用CPU編譯使用caffe(不完整安裝)
Caffe + Ubuntu 14.04 + CUDA 6.5 新手安裝配置指南
Caffe配置過程
DIY Deep Learning for Vision: a Hands-On Tutorial with Caffe from: http://yongyuan.name/blog/problems-when-configing-caffe.html