Caffe + CUDA7.5 + CuDNNv3 + OpenCV3.0 in UbuntuServer14.04配置

基本依赖项

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev

NVIDIA驱动

sudo apt-get install nvidia-current

CUDA

先安装内核头文件:

sudo apt-get install linux-headers-$(uname -r)

安装cuda(官网下载deb文件):

sudo dpkg -i cuda-repo-<distro>_<version>_<architecture>.deb
sudo apt-get update
sudo apt-get install cuda

环境变量:

export PATH=/usr/local/cuda-7.5/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:$LD_LIBRARY_PATH

测试:

cuda-install-samples-7.5.sh  ~
cd ~/NVIDIA_CUDA-7.5_Samples
cd 1_Utilities/deviceQuery
make

执行deviceQuery,如果成功结尾会是Result = PASS

cuda环境配置:

sudo nano /etc/ld.so.conf.d/cuda.conf
    /usr/local/cuda/lib64
    /lib

完成lib文件的链接操作,执行:

sudo ldconfig -v

BLAS

sudo apt-get install libatlas-base-dev

其他依赖项

sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

OpenCV

#[compiler]
sudo apt-get install build-essential
#[required]
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
#[optional]
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

可以下载opencv的包解压,也可以用最新代码:

git clone https://github.com/Itseez/opencv.git
cd ~/opencv
mkdir build
cd build

这里可以用下载的ippicv_linux_20141027.tgz放进~/opencv/3rdparty/ippicv/downloads/linux-8b449a536a2157bcad08a2b9f266828b/ (cmake之前没这个文件夹,camke的时候会执行下载,20+mb,网速快就不用管了)

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local
#make -j 后面的数字是并行个数,cpu厉害就设大点。一般是用4
make -j7
sudo make install

CuDNN

解压cudnn的包(官网得申请,用网盘搜索能找到最新的),有include和lib64,里面文件复制到对应/usr/local/cuda/对应文件夹里

#进到对应文件夹
sudo cp cudnn.h /usr/local/cuda/include/
#进到对应文件夹
sudo cp lib* /usr/local/cuda/lib64/
#可能要再进行一次 sudo ldconfig -v

不知道这里会不会有文件权限问题,暴力搞一下(这条可先不用)

sudo chmod 777 -R /usr/local/cuda/lib64

Caffe

git clone https://github.com/BVLC/caffe.git
cp Makefile.config.example Makefile.config

修改Makefile.config,去掉cudnn的注释,其他的在当前应用场景可不变。

make all
make test
make runtest

OK了。