有必要重新整理一下 Caffe 的安装方法,很多教程已经过时,并且装了很多没有必要的东西。本文就是关注如何能够快速地安装并使用 Caffe。
1. 安装 Linux
最好去买第二块硬盘,这样你会省去很多没有必要的麻烦。直接装 Ubuntu 16.04,即目前最新的 LTS 版本,原因我会后边说。
2. 安装驱动和 cuda
在系统设置的软件和更新中,安装 NVIDIA 和 Intel 的专有驱动。
装 16.04 的原因是,如果你有双显卡,它会自动地帮你找到你独立显卡的驱动,省得你自己瞎搞会出现各种错误。
Ubuntu 下安装 cuda 十分简单,就一条命令:
- sudo apt - get updatesudo apt - get install nvidia - cuda - toolkit
默认安装的是 cuda 7.5。
3. 让 cuda 支持 gcc 5
记住:不要降级 gcc!!!虽然你要处理 cuda 7.5 不支持 gcc 5 以上的问题,但是不要降级 gcc。因为如果你降级 gcc 后,其它包会出现问题,因为其它包是在 gcc 5 下编译的。正确方法是把 cuda 黑了:在 / usr/include/host_config.h 内把下面这几句话注释掉
- // #if __GNUC__ > 5// #error -- unsupported GNU version! gcc versions later than 5 are not supported!// #endif /* __GNUC__ > 5 */
4. 安装 Caffe
Caffe 的安装方法也比较简单
1. 安装 Caffe 所需要依赖包
- sudo apt - get install build - essential#basic requirementsudo apt - get install libprotobuf - dev libleveldb - dev libsnappy - dev libopencv - dev libboost - all - dev libhdf5 - serial - dev libgflags - dev libgoogle - glog - dev liblmdb - dev protobuf - compiler#required by caffe
2. 安装 Atlas
- sudo apt - get install libatlas - base - dev
3. 安装 opencv
- sudo apt - get install libopencv - dev
4. 下载 Caffe
- git clone https: //github.com/BVLC/caffe.git
5. 修改 Makefile
- ---NVCCFLAGS += -ccbin = $(CXX) - Xcompiler - fPIC $(COMMON_FLAGS)+++NVCCFLAGS += -D_FORCE_INLINES - ccbin = $(CXX) - Xcompiler - fPIC $(COMMON_FLAGS)
上面的意思是把第一行替换成第二行
6. 修改 Makefile.config
- cp Makefile.config.example Makefile.config
这里仅标出需要修改的地方。
- CUDA_DIR: =/usrBLAS := atlasINCLUDE_DIRS := $(PYTHON_INCLUDE) /usr / local / include / usr / lib / x86_64 - linux - gnu / hdf5 / serial / includeLIBRARY_DIRS: =$(PYTHON_LIB) / usr / local / lib / usr / lib / usr / lib / x86_64 - linux - gnu / hdf5 / serial
就爱阅读 www.92to.com 网友整理上传, 为您提供最全的知识大全, 期待您的分享,转载请注明出处。
来源: http://www.92to.com/bangong/2016/12-06/13930242.html