caffe-cuda测试

4. 安装CUDA Sample 及 ATLAS

4.1 Build sample

cd /usr/local/cuda/samples
sudo make all -j8

我电脑是八核的,所以make 时候用-j8参数,大家根据情况更改,整个过程有点长,十分钟左右。

4.2 查看驱动是否安装成功

cd bin/x86_64/linux/release
./deviceQuery

出现以下信息则成功:

./deviceQuery Starting...

CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GTX 670"
CUDA Driver Version / Runtime Version          6.5 / 6.5
CUDA Capability Major/Minor version number:    3.0
Total amount of global memory:                 4095 MBytes (4294246400 bytes)
( 7) Multiprocessors, (192) CUDA Cores/MP:     1344 CUDA Cores
GPU Clock rate:                                1098 MHz (1.10 GHz)
Memory Clock rate:                             3105 Mhz
Memory Bus Width:                              256-bit
L2 Cache Size:                                 524288 bytes
Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
Total amount of constant memory:               65536 bytes
Total amount of shared memory per block:       49152 bytes
Total number of registers available per block: 65536
Warp size:                                     32
Maximum number of threads per multiprocessor:  2048
Maximum number of threads per block:           1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch:                          2147483647 bytes
Texture alignment:                             512 bytes
Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
Run time limit on kernels:                     Yes
Tntegrated GPU sharing Host Memory:            No
Support host page-locked memory mapping:       Yes
Alignment requirement for Surfaces:            Yes
Device has ECC support:                        Disabled
Device supports Unified Addressing (UVA):      Yes
Device PCI Bus ID / PCI location ID:           1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 6.5, CUDA Runtime Version = 6.5, NumDevs = 1, Device0 = GeForce GTX 670
Result = PASS

4.3 安装ATLAS

ATLAS是做线性代数运算的,还有俩可以选:一个是Intel 的 MKL,这个要收费,还有一个是OpenBLAS,这个比较麻烦;但是运行效率ATLAS < OpenBLAS < MKL

我就用ATLAS咯:

sudo apt-get install libatlas-base-dev


5. 安装Caffe需要的Python包

网上介绍用现有的anaconda,我反正不建议,因为路径设置麻烦,很容易出错,而且自己安装很简单也挺快的。

首先需要安装pip

sudo apt-get install python-pip

再下载caffe,我把caffe放在用户目录下

cd
git clone https://github.com/BVLC/caffe.git

再转到caffe的python目录,安装scipy

cd caffe/python
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose

最后安装requirement里面的包,需要root权限

sudo su
for req in $(cat requirements.txt); do pip install $req; done

如果提示报错,一般是缺少必须的包引起的,直接根据提示 pip install 就行了。

安装完后退出root权限

exit


6. 编译caffe

首先修改配置文件,回到caffe目录

cd ~/caffe
cp Makefile.config.example Makefile.config
gedit Makefile.config

这里仅需修改两处:

i) 使用cuDNN

# USE_CUDNN := 1

这里去掉#,取消注释为

USE_CUDNN := 1

ii) 修改python包目录,这句话

PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include

改为

PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/local/lib/python2.7/dist-packages/numpy/core/include

因为新安装的python包目录在这里: /usr/local/lib/python2.7/dist-packages/

接下来就好办了,直接make

make all -j8
make test
make runtest
make pycaffe

这时候cd 到caffe 下的 python 目录,试试caffe 的 python wrapper安装好没有:

python
import caffe

如果不报错,那就说明安装好了。

你可能感兴趣的:(cuda,caffe)