一、Ubuntu下安装NVIDIA显卡驱动
1.下载驱动文件;
2.添加可执行权限:sudo chmod +x Nvidia….run;
3.进入tty1:ctrl+alt+F1;
4.关闭显示:sudo service lightdm stop;
5.安装驱动:sudo ./Nvidia….run;
6.启动显示:sudo service lightdm start;
7.进入图形界面:ctrl+Alt+F7.
8.查看驱动类型:About this computer。
二、Ubuntu下安装CUDA
1.下载cuda;
2.终端输入:sudo dpkg -i cuda-repo-。。。。。.deb;
3.sudo apt-get update;
4.sudo apt-get install -y cuda;
5.添加环境变量
sudo gedit .bashrc;然后在这文件中加入
export PATH=/usr/local/cuda-7.0/bin:$PATH;
export LD_LIBRARY_PATH=/usr/local/cuda-7.0/lib64:$LD_LIBRARY_PATH.
source .bashrc;//立马生效```
6.查看/验证是否成功:
nvcc --version
7.驱动验证:
cat /proc/driver/nvidia/version
8.Toolkit验证
nvcc -V
9.安装cuda的sample(可选)
1)cuda-install-sample-7.0.sh 安装路径
2)make
10.设备识别
cuda sample下面编译好的deviceQuery来识别
1)进入release目录;
2)/deviceQuery
三、安装cudnn
tar zxvf cudnn-7.5-linux-x64-v5.1.tgz
cd cuda
sudo cp include/cudnn.h /usr/local/include
sudo cp lib64/libcudnn.* /usr/local/lib
sudo ln -sf /usr/local/lib/libcudnn.so.5.1.3 /usr/local/lib/libcudnn.so.5
sudo ln -sf /usr/local/lib/libcudnn.so.5 /usr/local/lib/libcudnn.so
sudo ldconfig -v
四、安装BLAS
这里选择很多,本文采用intel的MKL
1.tar zxvf parallel_studio_xe_2016.tar.gz;
2.chmod a+x parallel_studio_xe_2016 -R;
3.cd parallel_studio_xe_2016;
4.sudo sh install_GUI.sh(注意这里一定要有sudo)。
MKL和CUDA配置:
1.新建instal_mkl.conf,并编辑之
sudo gedit /etc/ld.so.conf.d/intel_mkl.conf
/opt/intel/lib/intel64
/opt/intel/mkl/lib/intel64
也可以安装开源的atlas
sudo apt-get install libatlas-base-dev;
五、安装glog
tar zxvf glog-0.3.3.tar.gz
./configure
make
sudo make install
六、安装其他依赖项
sudo apt-get install -y libprotobuf-dev
ibleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhd
七、安装OpenCV
1.解压Opencv3.0;
2.新建build文件夹;
3.将ippicv_linux_20151201.tgz放到opencv3.0/3rdpart/ippicv/downloads/linux-文件夹下,并解压;
4.用cmake-gui来生成cmake文件;
5.进入build,然后make -j16;
6.添加环境变量:
新建/etc/ld.so.conf.d/opencv.conf;
写入/usr/local/lib。
八、其他依赖库
1.sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev
libopencv-dev libhdf5-serial-dev protobuf-compiler
2.sudo apt-get install –no-install-recommends libboost-all-dev
3.sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
4.# glog
wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz
tar zxvf glog-0.3.3.tar.gz
cd glog-0.3.3
./configure
make && make install
gflags
wget https://github.com/schuhschuh/gflags/archive/master.zip
unzip master.zip
cd gflags-master
mkdir build && cd build
export CXXFLAGS=”-fPIC” && cmake .. && make VERBOSE=1
make && make install
lmdb
git clone https://github.com/LMDB/lmdb
cd lmdb/libraries/liblmdb
make && make install
九、编译Caffe
make all -j16
make test -j16
make runtest -j16
make pycaffe -j16
make matcaffe -j16
具体可以参考:
http://blog.csdn.net/shiorioxy/article/details/52652831
十、问题集锦
1.编译caffe的时候遇到/usr/bin/ld:cannot find -lsnappy
原因:这个问题是由于ld在进行库连接的时候找不到库文件所致;
或者链接错误所致!
解决方案:
cd /usr/lib;
ll |grep libsnappy;
ln -s ./libsnappy.so.1 ./libsnappy.so
2.caffe安装错误 /usr/bin/ld: cannot find -lcblas /usr/bin/ld: cannot find -latlas 原因:没有安装好atlas库 解决:sudo apt-get install libatlas-base-dev即可!