Caffe研究实践 一 ------环境搭建
2016-05-11 09:08
357 查看
和TensorFlow对应的是Theano,Torch;
Caffe专精于图像处理,Caffe方便,更快入门上手;
在通用的DL task上,Caffe不如Theano。
CNN(卷积神经网络)、RNN(循环神经网络)、DNN(深度神经网络)
开发环境搭建:
一、没有GPU
二、ubuntu版本
三、gcc
四、安装依赖库
![](http://img.blog.csdn.net/20160511093310795)
![](http://img.blog.csdn.net/20160511093814193)
![](http://img.blog.csdn.net/20160511094016072)
五、安装python
六、安装Opencv
安装Opencv
http://blog.csdn.net/forest_world/article/details/51372703Ubuntu
七、安装依赖库
learning@learning-virtual-machine:~$ sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
[sudo] password for learning:
Reading package lists… Done
![](http://img.blog.csdn.net/20160511130233187)
八、下载Caffe
![](http://img.blog.csdn.net/20160511131100725)
九、修改
Makefile 修改:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs
这一块代码不需要修改
![](http://img.blog.csdn.net/20160511134234738)
修改处:
caffe/examples/cpp_classification/classification.cpp文件
![](http://img.blog.csdn.net/20160511133107035)
十、编译
learning@learning-virtual-machine:~/caffe$ gedit Makefile.config
![](http://img.blog.csdn.net/20160511134723970)
learning@learning-virtual-machine:~/caffe$ make all
出现问题:
解决:
Makefile.config
INCLUDE_DIRS
/usr/include/hdf5/serial/
Makefile
LIBRARIES
hdf5_hl and hdf5 改为 hdf5_serial_hl ,hdf5_serial
![](http://img.blog.csdn.net/20160511141203432)
![](http://img.blog.csdn.net/20160511141215870)
出现问题:
解决方法:
Makefile
修改:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs
编译成功:
![](http://img.blog.csdn.net/20160511144323896)
make test
![](http://img.blog.csdn.net/20160511150519877)
make runtest
![](http://img.blog.csdn.net/20160511150612159)
十一、配置pycaffe
sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython ipython
sudo apt-get install protobuf-c-compiler protobuf-compiler
learning@learning-virtual-machine:~/caffe$ make pycaffe
sudo gedit /etc/profile
末尾添加: export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH
用完整路径
source /etc/profile
learning@learning-virtual-machine:~/caffe$ python
Python 2.7.10 (default, Oct 14 2015, 16:09:02)
[GCC 5.2.1 20151010] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
.>>>
出现问题:
解决方法:
sudo gedit /etc/profile
export PYTHONPATH=$PYTHONPATH:/home/learning/caffe/python
source /etc/profile
![](http://img.blog.csdn.net/20160511160728195)
补充:baidu解释
Python(英国发音:/ˈpaɪθən/ 美国发音:/ˈpaɪθɑːn/), 是一种面向对象、解释型计算机程序设计语言,由Guido van Rossum于1989年发明,第一个公开发行版发行于1991年。
Python是纯粹的自由软件, 源代码和解释器CPython遵循 GPL(GNU General Public License)协议[1] 。
Python语法简洁清晰,特色之一是强制用空白符(white space)作为语句缩进。
Python具有丰富和强大的库。它常被昵称为胶水语言,能够把用其他语言制作的各种模块(尤其是C/C++)很轻松地联结在一起。常见的一种应用情形是,使用Python快速生成程序的原型(有时甚至是程序的最终界面),然后对其中[2] 有特别要求的部分,用更合适的语言改写,比如3D游戏中的图形渲染模块,性能要求特别高,就可以用C/C++重写,而后封装为Python可以调用的扩展类库。需要注意的是在您使用扩展类库时可能需要考虑平台问题,某些可能不提供跨平台的实现。
参考资料:Ubuntu14.04 安装Caffe
/article/2934997.html
Caffe专精于图像处理,Caffe方便,更快入门上手;
在通用的DL task上,Caffe不如Theano。
CNN(卷积神经网络)、RNN(循环神经网络)、DNN(深度神经网络)
开发环境搭建:
一、没有GPU
learning@learning-virtual-machine:~$ lspci | grep -i nvidia learning@learning-virtual-machine:~$
二、ubuntu版本
learning@learning-virtual-machine:~$ uname -m && cat /etc/*release x86_64 DISTRIB_ID=Ubuntu DISTRIB_RELEASE=15.10 DISTRIB_CODENAME=wily DISTRIB_DESCRIPTION="Ubuntu 15.10" NAME="Ubuntu" VERSION="15.10 (Wily Werewolf)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 15.10" VERSION_ID="15.10" HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" learning@learning-virtual-machine:~$
三、gcc
learning@learning-virtual-machine:~$ gcc --version gcc.real (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. learning@learning-virtual-machine:~$
四、安装依赖库
learning@learning-virtual-machine:~$ sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler [sudo] password for learning: Reading package lists... Done Building dependency tree
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libatlas-base-dev
五、安装python
六、安装Opencv
安装Opencv
http://blog.csdn.net/forest_world/article/details/51372703Ubuntu
七、安装依赖库
learning@learning-virtual-machine:~$ sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
[sudo] password for learning:
Reading package lists… Done
八、下载Caffe
learning@learning-virtual-machine:~$ git clone git://github.com/BVLC/caffe.git Cloning into 'caffe'... remote: Counting objects: 34637, done. Receiving objects: 100% (34637/34637), 47.81 MiB | 81.00 KiB/s, done. remote: Total 34637 (delta 0), reused 0 (delta 0), pack-reused 34636 Resolving deltas: 100% (23287/23287), done. Checking connectivity... done.
九、修改
Makefile 修改:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs
这一块代码不需要修改
修改处:
caffe/examples/cpp_classification/classification.cpp文件
十、编译
learning@learning-virtual-machine:~/caffe$ cp Makefile.config.example Makefile.config learning@learning-virtual-machine:~/caffe$ ls caffe.cloc data INSTALL.md matlab src cmake docker LICENSE models tools CMakeLists.txt docs Makefile python CONTRIBUTING.md examples Makefile.config README.md CONTRIBUTORS.md include Makefile.config.example scripts learning@learning-virtual-machine:~/caffe$
learning@learning-virtual-machine:~/caffe$ gedit Makefile.config
learning@learning-virtual-machine:~/caffe$ make all
出现问题:
learning@learning-virtual-machine:~/caffe$ make all PROTOC src/caffe/proto/caffe.proto CXX .build_release/src/caffe/proto/caffe.pb.cc CXX src/caffe/data_transformer.cpp CXX src/caffe/common.cpp CXX src/caffe/internal_thread.cpp CXX src/caffe/blob.cpp CXX src/caffe/data_reader.cpp CXX src/caffe/parallel.cpp CXX src/caffe/util/hdf5.cpp In file included from src/caffe/util/hdf5.cpp:1:0: ./include/caffe/util/hdf5.hpp:6:18: fatal error: hdf5.h: No such file or directory compilation terminated. Makefile:572: recipe for target '.build_release/src/caffe/util/hdf5.o' failed make: *** [.build_release/src/caffe/util/hdf5.o] Error 1 learning@learning-virtual-machine:~/caffe$
解决:
Makefile.config
INCLUDE_DIRS
/usr/include/hdf5/serial/
Makefile
LIBRARIES
hdf5_hl and hdf5 改为 hdf5_serial_hl ,hdf5_serial
出现问题:
LD -o .build_release/lib/libcaffe.so.1.0.0-rc3 CXX tools/finetune_net.cpp CXX/LD -o .build_release/tools/finetune_net.bin CXX tools/net_speed_benchmark.cpp CXX/LD -o .build_release/tools/net_speed_benchmark.bin CXX tools/compute_image_mean.cpp CXX/LD -o .build_release/tools/compute_image_mean.bin .build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)' .build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)' .build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)' collect2: error: ld returned 1 exit status Makefile:616: recipe for target '.build_release/tools/compute_image_mean.bin' failed make: *** [.build_release/tools/compute_image_mean.bin] Error 1
解决方法:
Makefile
修改:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs
编译成功:
make test
make runtest
[----------] 2 tests from BatchReindexLayerTest/0, where TypeParam = caffe::CPUDevice<float> [ RUN ] BatchReindexLayerTest/0.TestForward [ OK ] BatchReindexLayerTest/0.TestForward (0 ms) [ RUN ] BatchReindexLayerTest/0.TestGradient [ OK ] BatchReindexLayerTest/0.TestGradient (373 ms) [----------] 2 tests from BatchReindexLayerTest/0 (374 ms total) [----------] Global test environment tear-down [==========] 1058 tests from 146 test cases ran. (134225 ms total) [ PASSED ] 1058 tests. learning@learning-virtual-machine:~/caffe$
十一、配置pycaffe
sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython ipython
sudo apt-get install protobuf-c-compiler protobuf-compiler
learning@learning-virtual-machine:~/caffe$ make pycaffe
learning@learning-virtual-machine:~/caffe$ make pycaffe CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp touch python/caffe/proto/__init__.py PROTOC (python) src/caffe/proto/caffe.proto learning@learning-virtual-machine:~/caffe$
sudo gedit /etc/profile
末尾添加: export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH
用完整路径
source /etc/profile
learning@learning-virtual-machine:~/caffe$ python
Python 2.7.10 (default, Oct 14 2015, 16:09:02)
[GCC 5.2.1 20151010] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
.>>>
出现问题:
.>>> import caffe Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named caffe
解决方法:
sudo gedit /etc/profile
export PYTHONPATH=$PYTHONPATH:/home/learning/caffe/python
source /etc/profile
补充:baidu解释
Python(英国发音:/ˈpaɪθən/ 美国发音:/ˈpaɪθɑːn/), 是一种面向对象、解释型计算机程序设计语言,由Guido van Rossum于1989年发明,第一个公开发行版发行于1991年。
Python是纯粹的自由软件, 源代码和解释器CPython遵循 GPL(GNU General Public License)协议[1] 。
Python语法简洁清晰,特色之一是强制用空白符(white space)作为语句缩进。
Python具有丰富和强大的库。它常被昵称为胶水语言,能够把用其他语言制作的各种模块(尤其是C/C++)很轻松地联结在一起。常见的一种应用情形是,使用Python快速生成程序的原型(有时甚至是程序的最终界面),然后对其中[2] 有特别要求的部分,用更合适的语言改写,比如3D游戏中的图形渲染模块,性能要求特别高,就可以用C/C++重写,而后封装为Python可以调用的扩展类库。需要注意的是在您使用扩展类库时可能需要考虑平台问题,某些可能不提供跨平台的实现。
参考资料:Ubuntu14.04 安装Caffe
/article/2934997.html
相关文章推荐
- js实现a标签超链接提交form表单的方法
- C#中 GenerateResource”任务意外失败。 System.NullReferenceException: 未将对象引用设置到对象的实例。
- javaScript的闭包
- Html5入门学习资料,应用技巧,初学者必读
- JQuery DOM 事件冒泡
- angular $emit发送 后退时$on多次接收
- JavaScript停止冒泡和阻止浏览器默认行为
- CSS魔法堂:Box-Shadow没那么简单啦:)
- Javascript 动态合并table单元格
- 实现一个简单的Javascript级联下拉菜单
- JavaScript的DOM操作
- .innerhtml 与.innertext
- jQuery中each的用法之退出循环和结束本次循环
- JavaScript 事件管理
- [转载]js正则表达式语法
- H5制作1--母亲节快乐
- jQuery全屏动画焦点图
- LeetCode 025 Reverse Nodes in k-Group
- ES6新特性:Javascript中的Reflect对象
- 小公司的前端应该怎么做?