caffe配置中的一些问题
一直想將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 # glog wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz tar zxvf glog-0.3.3.tar.gz cd glog-0.3.3 ./configure make && make install # gflags wget https://github.com/schuhschuh/gflags/archive/master.zip unzip master.zip cd gflags-master mkdir build && cd build export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1 make && make install # lmdb git clone https://gitorious.org//mdb/mdb.git cd mdb/libraries/liblmdb make && make install3、如果用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/intel644、出現:/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 -v5、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.backup sudo mv libm.so libm.so.backup3、 你需要安裝ipython和ipython qtconsole。安裝完后可以用下面的腳本測試:
import sys sys.path.append('/home/yong/anaconda/lib/python2.7/site-packages') sys.path.append('/usr/lib/python2.7/dist-packages')import numpy as np import 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
總結
以上是生活随笔為你收集整理的caffe配置中的一些问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: OpenCV行人检测
- 下一篇: VLAD教程和资料 All about