Ubuntu 64bit下手动安装深度学习包Caffe记录(CPU)
2017-10-31 23:14
591 查看
前言
之前在电脑上安装Caffe都是使用的简单安装(sudo…sudo..do),这几天闲下来折腾起了手动安装。这样做主要是为了方便进行移植,这里将所有的依赖库安装到了
整篇文章基本讲干货,其他的什么介绍之类的就省略了-_-||…
安装完成之后为了校验安装的正确性,查看对应目录下有没有protoc文件
为了能在命令行运行,将该目录加入到PATH中去
若未能识别ccmake需要执行下面命令进行安装
按照上面的进行配置完成之后按C键,之后G键生成Makefile文件
CFLAGS在Caffe中主要起到命令行参数解析的作用,这与protobuf功能类似,只是参数输入源不同。CFLAGS的使用方法可参考Caffe源码中的tools/caffe.cpp
将生成的lmdb.h拷贝到
在所有的附加库安装完成之后得到的2级目录结构是这样的
编辑好config文件之后就是进行编译了,就是make命令。之后为了检验安装是否成功需要进行如下验证
本人在其中遇到这个错误
解决办法:
在/home/pc_name/下编辑.bashrc文件,添加
之前在电脑上安装Caffe都是使用的简单安装(sudo…sudo..do),这几天闲下来折腾起了手动安装。这样做主要是为了方便进行移植,这里将所有的依赖库安装到了
/home/pc_name(你自己的电脑账户名,下同)/local_install/目录下。博主在Ubuntu 64bit上安装成功,现在将整个的安装过程记录下来,希望对各位看官有所帮助。若各位看官需要本次安装所需的全部安装包可以QQ联系我(2414385027)。
整篇文章基本讲干货,其他的什么介绍之类的就省略了-_-||…
1. Protobuf安装
tar zxvf protobuf-cpp-3.4.1.tar.gz cd protobuf-cpp-3.4.1/ ./configure --prefix=/home/pc_name/local_install make make install
安装完成之后为了校验安装的正确性,查看对应目录下有没有protoc文件
ls ~/local_install/bin/ protoc
为了能在命令行运行,将该目录加入到PATH中去
export PATH=~/local_install/bin/:$PATH将其写入到
/home/pc_name/.bashrc
2. BOOST安装
tar zxvf boost_1_56_0.tar.gz cd boost_1_56_0/ ./bootstrap.sh --with-libraries=system,thread,python ./b2 ./b2 install cp -r boost/ /home/pc_name/local_install/include/ cp stage/lib/* /home/pc_name/local_install/lib/
3. CFLAGS安装
tar zxvf gflags-2.2.1.tar.gz cd gflags-2.2.1/ mkdir build && cd build cmake .. ccmake ..
若未能识别ccmake需要执行下面命令进行安装
sudo apt-get install cmake-curses-gui
按照上面的进行配置完成之后按C键,之后G键生成Makefile文件
make make install
CFLAGS在Caffe中主要起到命令行参数解析的作用,这与protobuf功能类似,只是参数输入源不同。CFLAGS的使用方法可参考Caffe源码中的tools/caffe.cpp
4. GLOG安装
tar zxvf glog-0.3.5.tar.gz cd glog-0.3.5/ ./configure --prefix=/home/pc_name/local_install/ make make install
5. OpenBLAS安装
unzip OpenBLASv0.2.20.zip make –j make PREFIX=/home/pc_name/local_install/ install
6. HDF5安装
tar xvf hdf5-1.10.1.tar cd hdf5-1.10.1/ ./configure --prefix=/home/pc_name/local_install/ make -j && make install
7. OpenCV安装
unzip opencv-3.0.0.zip cd opencv-3.0.0/ mkdir build && cd build cmake .. ccmake ..
make make install
8. LMDB安装
tar zxvf lmdb-LMDB_0.9.21.tar.gz cd lmdb-LMDB_0.9.21/ make
将生成的lmdb.h拷贝到
/home/pc_name/local_install/include目录下,liblmdb.so拷贝到
/home/pc_name/local_install/lib目录下。
9. LEVELDB安装
tar zxvf leveldb-1.20.tar.gz cd leveldb-1.20/ make cp -r include/leveldb ~/local_install/include/ cp libleveldb.so* ~/local_install/lib/
10. Snappy安装
tar zxvf snappy-1.1.1.tar.gz cd snappy-1.1.1/ ./configure --prefix=/home/pc_name/local_install/ make && make install
在所有的附加库安装完成之后得到的2级目录结构是这样的
. ├── bin ├── include │ ├── boost │ ├── gflags │ ├── glog │ ├── google │ ├── leveldb │ ├── opencv │ └── opencv2 ├── lib │ ├── cmake │ └── pkgconfig └── share ├── doc ├── hdf5_examples └── OpenCV 16 directories
11. Caffe安装
至于Caffe的安装需要的是配置好Makefile.config文件就好了,下面提供本次讲解使用的文件内容(只是用CPU)## Refer to http://caffe.berkeleyvision.org/installation.html # Contributions simplifying and improving our build system are welcome! # cuDNN acceleration switch (uncomment to build with cuDNN). # USE_CUDNN := 1 # CPU-only switch (uncomment to build without GPU support). CPU_ONLY := 1 # uncomment to disable IO dependencies and corresponding data layers # USE_OPENCV := 0 # USE_LEVELDB := 0 # USE_LMDB := 0 # uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary) # You should not set this flag if you will be reading LMDBs with any # possibility of simultaneous read and write # ALLOW_LMDB_NOLOCK := 1 # Uncomment if you're using OpenCV 3 OPENCV_VERSION := 3 # To customize your choice of compiler, uncomment and set the following. # N.B. the default for Linux is g++ and the default for OSX is clang++ # CUSTOM_CXX := g++ # CUDA directory contains bin/ and lib/ directories that we need. CUDA_DIR := /usr/local/cuda # On Ubuntu 14.04, if cuda tools are installed via # "sudo apt-get install nvidia-cuda-toolkit" then use this instead: # CUDA_DIR := /usr # CUDA architecture setting: going with all of them. # For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility. # For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility. CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \ -gencode arch=compute_20,code=sm_21 \ -gencode arch=compute_30,code=sm_30 \ -gencode arch=compute_35,code=sm_35 \ -gencode arch=compute_50,code=sm_50 \ -gencode arch=compute_52,code=sm_52 \ -gencode arch=compute_60,code=sm_60 \ -gencode arch=compute_61,code=sm_61 \ -gencode arch=compute_61,code=compute_61 # BLAS choice: # atlas for ATLAS (default) # mkl for MKL # open for OpenBlas BLAS := open # Custom (MKL/ATLAS/OpenBLAS) include and lib directories. # Leave commented to accept the defaults for your choice of BLAS # (which should work)! # BLAS_INCLUDE := `/path/to/your/blas # BLAS_LIB := /path/to/your/blas # Homebrew puts openblas in a directory that is not on the standard search path # BLAS_INCLUDE := $(shell brew --prefix openblas)/include # BLAS_LIB := $(shell brew --prefix openblas)/lib # This is required only if you will compile the matlab interface # MATLAB directory should contain the mex binary in /bin. # MATLAB_DIR := /usr/local # MATLAB_DIR := /Applications/MATLAB_R2012b.app # NOTE: this is required only if you will compile the python interface. # We need to be able to find Python.h and numpy/arrayobject.h. PYTHON_INCLUDE := /usr/include/python2.7 \ /usr/lib/python2.7/dist-packages/numpy/core/include # Anaconda Python distribution is quite popular. Include path: # Verify anaconda location, sometimes it's in root. # ANACONDA_HOME := $(HOME)/anaconda # PYTHON_INCLUDE := $(ANACONDA_HOME)/include \ # $(ANACONDA_HOME)/include/python2.7 \ # $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include # Uncomment to use Python 3 (default is Python 2) # PYTHON_LIBRARIES := boost_python3 python3.5m # PYTHON_INCLUDE := /usr/include/python3.5m \ # /usr/lib/python3.5/dist-packages/numpy/core/include # We need to be able to find libpythonX.X.so or .dylib. PYTHON_LIB := /usr/lib # PYTHON_LIB := $(ANACONDA_HOME)/lib # Homebrew installs numpy in a non standard path (keg only) # PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include # PYTHON_LIB += $(shell brew --prefix numpy)/lib # Uncomment to support layers written in Python (will link against Python libs) # WITH_PYTHON_LAYER := 1 # Whatever else you find you need goes here. INCLUDE_DIRS := /home/sucker/local_install/include $(PYTHON_INCLUDE)\ /usr/local/include LIBRARY_DIRS := /home/sucker/local_install/lib $(PYTHON_LIB)\ /usr/local/lib /usr/lib # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies # INCLUDE_DIRS += $(shell brew --prefix)/include # LIBRARY_DIRS += $(shell brew --prefix)/lib # NCCL acceleration switch (uncomment to build with NCCL) # https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0) # USE_NCCL := 1 # Uncomment to use `pkg-config` to specify OpenCV library paths. # (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.) # USE_PKG_CONFIG := 1 # N.B. both build and distribute dirs are cleared on make clean BUILD_DIR := build DISTRIBUTE_DIR := distribute # Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171 # DEBUG := 1 # The ID of the GPU that 'make runtest' will use to run unit tests. TEST_GPUID := 0 # enable pretty build (comment to see full commands) Q ?= @
编辑好config文件之后就是进行编译了,就是make命令。之后为了检验安装是否成功需要进行如下验证
make test make runtest
本人在其中遇到这个错误
.build_release/tools/caffe: error while loading shared libraries: libboost_system.so.1.56.0: cannot open shared object file: No such file or directory make: *** [runtest] Error 127
解决办法:
在/home/pc_name/下编辑.bashrc文件,添加
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/pc_name/local_install/lib
相关文章推荐
- 深度学习之Ubuntu下安装caffe和TensorFlow的cpu版本
- ubuntu下深度学习框架caffe的安装(cpu模式下)
- 深度学习Caffe平台安装——Ubuntu安装CPU模式的caffe
- 深度学习文章1:Caffe安装教程:Ubuntu16.04(CPU)
- 深度学习之Ubuntu下安装caffe和TensorFlow的cpu版本
- 深度学习Caffe平台安装——Ubuntu安装CPU模式的caffe
- 32bit/64bit-Ubuntu14.04+anaconda+CPU版本的Caffe安装教程
- 深度学习caffe编译安装记录
- Dell-1080Ti 深度学习Win 10 + Ubuntu 16.04.02 双系统安装+anaconda2+tensorflow+opencv3.2+caffe
- Ubuntu环境下深度学习cuda,cudnn,caffe,tensorflow的安装
- Caffe深度学习框架安装(Ubuntu14.04+cuda8.0)
- Ubuntu16.04深度学习一键安装脚本(支持pytorch、tensorflow、keras、caffe)
- 深度学习笔记1 ——Ubuntu16.04下caffe环境的配置(仅CPU)
- 【深度学习】Ubuntu 常用软件安装:Tensorflow + TeamViewer + Caffe + ... + Matlab
- 【深度学习】Ubuntu 常用软件安装:Tensorflow + TeamViewer + Caffe + ... + Matlab
- 深度学习之MAC(cpu-only)下利用anaconda安装caffe
- 零错误安装基于ubuntu14.04LTS的CUP版本深度学习框架Caffe
- 深度学习Caffe平台安装前环境准备——1.Ubuntu下在线安装、卸载JDK
- Ubuntu 14.04_64bit+Cuda 7.0配置深度学习框架caffe
- Ubuntu16.04 +Caffe CPU/GPU 深度学习环境