* Ubuntu14.04+cuda-8.0+opencv-3.0+cudcnn-6.0
http://blog.csdn.net/yhl_leo/article/details/50961542
http://blog.csdn.net/ubunfans/article/details/47724341
http://blog.sina.com.cn/s/blog_752c8c4e0102w9tc.html
http://blog.csdn.net/xuezhisdc/article/details/47075401
http://coldmooon.github.io/2015/08/03/caffe_install/
http://blog.sina.com.cn/s/blog_752c8c4e0102w9tc.html
http://osdf.github.io/blog/intel-integrated-graphics-dedicated-gpu-for-cuda-and-ubuntu-1310.html
- Ubuntu 14.04(64-bit)
- NVIDIA 650M
- CUDA 7.5
http://www.jianshu.com/p/9e0a18608527
1. 安装前的准备
1.1 安装基本包
sudo apt-get install build-essential
&& 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
&& sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev
&& sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install aptitude
sudo apt-get install libglew-dev libcheese7 libcheese-gtk23 libclutter-gst-2.0-0 libcogl15 libclutter-gtk-1.0-0 libclutter-1.0-0 xserver-xorg-input-all
sudo apt-get install freeglut3 freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev gcc g++ gcc-4.6 g++-4.6 linux-headers-generic linux-source
1.2 禁用nouveau
lsmod|grep nouveau
- 生产文件 /etc/modprobe.d/blacklist-nouveau.conf,添加如下内容
gksudo gedit /etc/modprobe.d/blacklist-nouveau.conf
->文件中添加
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
echo options nouveau modeset=0 |
sudo tee -a /etc/modprobe.d/nouveau-kms.conf
sudo update-initramfs -u
- reboot
1.3 卸载显卡
- 1.3.1 显示显卡
lspci | grep VGA
sudo apt-cache search "NVIDIA binary driver"
sudo dpkg --get-selections | grep nvidia
- 1.3.2 查看推荐的n卡驱动
sudo ubuntu-drivers devices
- 1.3.3 删除已有显卡
sudo apt-get --purge remove nvidia-*
&& sudo apt-get --purge remove bumblebee*
&& sudo apt-get --purge remove xserver-xorg-video-nouveau
&& sudo apt-get --purge remove nvidia* && sudo apt-get autoremove
&& sudo rm -rf/etc/X11/xorg.conf
1.3 安装显卡
http://askubuntu.com/questions/451221/ubuntu-14-04-install-nvidia-driver
http://coldmooon.github.io/2015/08/03/caffe_install/
N卡驱动安装
查找显卡的驱动
http://www.nvidia.cn/Download/index.aspx?lang=cn
- 1.3.1 安装附加库
sudo apt-get install dkms fakeroot build-essential linux-headers-generic
reboot
1.3.5 ppa安装
GPU:650M——375
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-375 nvidia-settings nvidia-prime
*1.3.6 查询
prime-select query
cat /proc/driver/nvidia/version
*1.3.7 显卡的切换
sudo update-alternatives --config x86_64-linux-gnu_gl_conf
sudo ldconfig -n
sudo update-initramfs -u
1.4 下载 bumblebee
http://blog.sina.com.cn/s/blog_6dee445401013sss.html
* 1.4.1 查看
lspci | grep -i vga
- 1.4.2 安装bumblebee
sudo add-apt-repository ppa:bumblebee/stable
sudo apt-get update
sudo apt-get install bumblebee bumblebee-nvidia
- 1.4.3 使用
使用”optirun 程序名“手动开启nvidia来运行需要加速的程序,如
optirun vmware。
1.5 下载cuda toolkits
下载地址:
https://developer.nvidia.com/cuda-downloads
将cuda拷贝到 /home/mishaohua/cuda文件夹下
验证cuda安装包
md5sum cuda...
1.6 安装
不添加opengl-libs
重启系统
- Before logging in, I do Ctrl + Alt + F1 and I login to my username.
- $sudo service lightdm stop
sudo bash cuda-7.0.28_linux.run --no-opengl-libs
* 安装库
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
* $sudo service lightdm start
* bug: “Ubuntu is running in low-graphics mode?”
- 安装nvidia-current
- 重启后再安装一遍nvidia-375
1.7 环境变量
- 在/etc/profile中添加:
export PATH=$PATH:/usr/local/cuda/bin
source /etc/profile
- 创建文件/etc/ld.so.conf.d/cuda.conf:
在/etc/ld.so.conf.d加入文件cuda.conf,写入
/usr/local/cuda-6.5/lib64
同样,执行下列命令使其立即生效
sudo ldconfig
1.8 编译SAMPLE
*进入/usr/local/cuda/samples:
sudo make all -j4
- 完成后进入samples/bin/x86_64/linux/release:
./deviceQuery
*bug错误:samples
解决:删除运行CUDA的deviceQuery时得到FAIL结果。解决方法就是移除Nvidia-304。
再次,安装nvidia-375
* bug: make[1]: * [cudaDecodeGL] 错误 1
http://blog.csdn.net/dawncan/article/details/50889759
sudo ./deviceQuery
1.9 cudaDNN
$ sudo tar xvf cudnn-8.0-linux-x64-v5.0-prod.tgz
//解压后生产cuda文件
速度orecu
$ cd cuda/include
$ sudo cp *.h /usr/local/include/
$ cd ../lib64
$ sudo cp lib* /usr/local/lib/
$ cd /usr/local/lib
$ sudo chmod +r libcudnn.so.4.0.4
$ sudo ln -sf libcudnn.so.4.0.4 libcudnn.so.4
$ sudo ln -sf libcudnn.so.4 libcudnn.so
$ sudo ldconfig
1.10 安装Intel MKL 或Atlas
sudo apt-get install libatlas-base-dev
1.11 anaconda(python环境)
bash Anaconda-2.3.0-Linux-x86_64.sh
- vim /etc/profile
export PATH=~/anaconda2/bin:$PATH
安装 accelerate:
conda update conda
conda install accelerate
conda install iopro
conda update ipython
conda update ipython-notebook
conda update ipython-qtconsole
ipython notebook
1.12 安装opencv 3.0
http://sysads.co.uk/2014/05/install-opencv-2-4-9-ubuntu-14-04-13-10/
http://www.ozbotz.org/opencv-installation/
http://karytech.blogspot.jp/2012/05/opencv-24-on-ubuntu-1204.html
- 安装脚本
https://github.com/jayrambhia/Install-OpenCV
* 安装脚步有错误,修改后安装
- 进入目录 Install-OpenCV/Ubuntu/2.4
sudo ./dependencies.sh
sudo ./open2_4_9.sh
其中第一步是安装依赖项,第二部是安装opencv,这个过程大概二三十分钟,慢慢等。
* opencv3.0
http://coderlin.coding.me/2016/03/02/Install-OpenCV-3-1-0-in-Ubuntu-14-04-13-10/
* 可以安装opencv3.0和opencv_contrib_master
1.13 安装其他
- Openblas
http://www.openblas.net/
$ make -j 8
$ make install PREFIX=your_directory
根据具体的安装路径设置:
export LD_LIBRARY_PATH=/opt/OpenBLAS/lib
2 安装 caffe
* Makefil_config文件
- 若使用opencv3,则文件OPENCV_VERSION:=3
# cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := 1
# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1
# 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 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_50,code=compute_50
# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := mkl
# 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
# MATLAB directory should contain the mex binary in /bin.
MATLAB_DIR := /home/your_username/MATLAB/R2014b
# MATLAB_DIR := /Applications/MATLAB_R2012b.app
# 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 \
# We need to be able to find libpythonX.X.so or .dylib.
# PYTHON_LIB := /usr/lib
PYTHON_LIB := $(ANACONDA_HOME)/lib
# Uncomment to support layers written in Python (will link against Python libs)
# WITH_PYTHON_LAYER := 1
电脑没有 nvidia 显卡的配置:
# cuDNN acceleration switch (uncomment to build with cuDNN).
# USE_CUDNN := 1
# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY := 1
# 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 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_50,code=compute_50
...
其余部分保持不变
安装命令
make clean
make all -j 8
make test -j 8
make runtest -j 8
接下来编译 python 接口和 matlab 接口:
make pycaffe -j 8
make matcaffe -j 8
* 安装 matlab
Bug
- bug : sudo apt-get update时候(hash sum mismatch)
sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update
bug 解决:
http://askubuntu.com/questions/575548/system-settings-stopped-showing-up
密码:19840813bug:sudo prime-select query 的方法
sudo update-alternatives --remove i386-linux-gnu_gl_conf /usr/lib/i386-linux-gnu/mesa/ld.so.conf
sudo update-alternatives --remove x86_64-linux-gnu_gl_conf /usr/lib/x86_64-linux-gnu/mesa/ld.so.conf
*bug
* opencv3 -install
http://coderlin.coding.me/2016/03/02/Install-OpenCV-3-1-0-in-Ubuntu-14-04-13-10/