本文記錄了ubuntu15.10上面安裝caffe和運行fasterRcnn的過程,把其中遇到的問題和解決辦法記錄一下,以備查看。
主要參考
http://ouxinyu.github.io/Blogs/20151108001.html
Caffe + Ubuntu 15.04 + CUDA 7.5 新手安裝配置指南
http://blog.csdn.net/helloeveryon/article/details/48789079
1:安裝Ubuntu
下載ubuntu15.10,用ultraiso做成啟動盤,然后安裝。安裝過程中,忘了手動分配swap交換分區,系統自動分配的
問題:ubuntu系統安裝好后,文件名顯示不全。
解決:是因為顯卡驅動問題,安裝CUDA驅動就可以了。
2:安裝CUDA顯卡驅動
先把錯配的顯卡驅動清理干凈
sudo apt-get --purge remove nvidia-*
到https://developer.nvidia.com/cuda-downloads下載對應的deb文件
到deb的下載目錄下
sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb
sudo apt-get update
sudo apt-get install cuda
sudo reboot
完成,cuda和顯卡驅動就都裝好了;其他的什么都不用動
而網上大部分中文和英文的參考教程都是過時的,折騰幾個小時不說還容易裝不成。
3:安裝ATLAS
安裝Intel MKL 或Atlas,沒有參考博文中的方法,偷懶裝的Atlas
安裝命令:
sudo apt-get install libatlas-base-dev
4:安裝OPENCV3.1.0
ubuntu +opencv3.1 安裝指南
http://www.tuicool.com/articles/nYJrYra
http://my.oschina.net/drjones/blog/521664 這個教程涉及opencv2.4到3.0的升級
問題:
(1):file included from /usr/local/cuda/include/cuda_runtime.h:76:0, from <command-line>:0:/usr/local/cuda/include/host_config.h:115:2: error: #error -- unsupported GNU version! gcc versions later than 4.9 are not supported! #error -- unsupported GNU version! gcc versions later than 4.9 are not supported! ^
You can try install gcc-4.9 and g++-4.9 to solve this problem temporarily. But the linker will report undefined references errors later because all other libraries (protobuf,leveldb,opencv) in Ubuntu 15.10 are compiled with GCC version 5.2. They are not compatible.
--- #error -- unsupported GNU version! gcc versions later than 4.9 are not supported!+++ //#error -- unsupported GNU version! gcc versions later than 4.9 are not supported!
解決:To solve this problem we have to "hack" the CUDA toolkit by editing /usr/local/cuda/include/host_config.h. Comment line 115.
(2)在帶有中文名字的文件夾中進行 make opencv3.0,導致錯誤,以后一定要避免有中文名字。
(3) 修改Makefile文件(不是Makefile.config)
在位置((LIBRARIES+= glog gflags protobuf leveldb snappy \lmdbboost_system hdf5_hl hdf5 m \
opencv_coreopencv_highgui opencv_imgproc opencv_imgcodecs))處
添加opencv_imgcodecs
這一步非常重要,否則編譯后會出現錯誤如下:
原因就是opencv3.0.0把imread相關函數放到imgcodecs.lib中了,而非原來的imgproc.lib
4:安裝FASTER RCNN
博客中內容:將你之前配置過的CaffeMakefile.config拷貝至./faster-rcnn/external/caffe,記得修改Matlab接口,接着編譯就可以了。
(1)這一步,千萬不能把makefile文件也copy過去,否則后面make matcaffe 會導致找不到一些庫文件路徑。找不到GPU的頭文件。
(2)caffe下面生成的build文件夾是軟鏈接不能直接copy使用。
(3)直接copy的其他人的模型,導致出現下面錯誤,還是老實點從作者Baidu雲盤下吧。
MATLAB被殺死,內存如果不足,會提示out of memory。