[一]更新源:
1、复制原文件备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2、编辑源列表文件
sudo gedit /etc/apt/sources.list
3、将原来的列表删除,添加如下内容
deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
4、运行sudo apt-get update
5、运行sudo apt-get upgrade
Note:与ubuntu16的版本对应
[二]NVIDIA显卡驱动安装
http://www.nvidia.com/Download/index.aspx?lang=en-us
把noveau加入黑名单
sudo gedit /etc/modprobe.d/blacklist-nouveau.conf
添加blacklist nouveau 保存退出
sudo update-initramfs -u 更新
reboot 重启
C+Alt+F1进入tty1
登入用户 login:用户名
Password:密码
lspci | grep nouveau 查看是否有内容 没有内容 ,说明禁成功
sudo servic e lightdm stop 结束x-window的服务:桌面显示环境管理器(图形环境)
sudo ./NVIDIA-Linux-x86_64-384.90.run 安装驱动 Note:事先保存在主机中
reboot
安装过程中出现一系列的选择 基本上都是选择accept、continue install、yes、ok。
-----------------------------------------------
http://jingyan.baidu.com/article/066074d6443227c3c21cb091.html
若NVIDIA-Linux-x86_64-384.90.run在U盘中,在C+Alt+F1进入tty1之后:
插入U盘,使用fdisk -l查看U盘是否被识别
如图,U盘位置为/dev/Sdd1
之后运行挂载的命令:“mount -t vfat /dev/sdd1 /media” /media为根目录下的一个文件夹
运行命令“cd media”进入挂载U盘的主目录,查看U盘下的文件
拷贝文件NVIDIA-Linux-x86_64-384.90.run到主机:cp /NVIDIA-Linux-x86_64-384.90.run /home/Downloads
[三]cuda安装
https://developer.nvidia.com/cuda-downloads
空格至
如果出现下图的结果,表明你已经安装成功了,虽然有一个警告和一个特别注意但是不影响结果
从上图可是,下载的例子里面是缺少一些支持库的,现在我们安装这些库:
[html] view plain copy
1. sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
从上图可以看出来,有一个特别注意,所以我们做如下配置:打开.bashrc来进行配置,命令如下
[html] view plain copy
1. sudo vim ~/.bashrc
并将如下的几行内容复制的到.bashrc文件的最下面
[html] view plain copy
1. export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
[html] view plain copy
1. export LD_LIBRARY_PATH=/usr/local/cuda8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
现在就开始测试一下看看cuda是否安装成功吧!输入如下命令打开测试的代码位置:
[html] view plain copy
1. cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery
编译这些代码:
[html] view plain copy
1. sudo make -j4
执行代码
[html] view plain copy
1. ./deviceQuery
如果出现如下结果---显卡的配置信息,恭喜你,这就证明你成功的安装了cuda
[四]cuDNN安装
[html] view plain copy
1. tar -xvf cudnn-8.0-linux-x64-v5.1.tgz
执行如下操作:
[html] view plain copy
1. cd cuda/include/
[html] view plain copy
1. sudo cp cudnn.h /usr/local/cuda/include/
[html] view plain copy
1. cd ../lib64/
[html] view plain copy
1. sudo cp lib* /usr/local/cuda/lib64/
[html] view plain copy
1. cd /usr/local/cuda/lib64/
[html] view plain copy
1. sudo rm -rf libcudnn.so libcudnn.so.5
[html] view plain copy
1. sudo ln -s libcudnn.so.5.1.10 libcudnn.so.5
2. 可能是sudo ln -s libcudnn.so.5.1.5 libcudnn.so.5
[html] view plain copy
1. sudo ln -s libcudnn.so.5 libcudnn.so
Note:libcudnn.so后面跟的数字可能和你下载的 cudnn 包小版本的不同而不同,去~/cuda/lib64下看一眼,相对应地进行修改
[五]OpenCV2.4.13安装
下载地址:http://opencv.org/
安装相关依赖项:
[html] view plain copy
1. sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libdc1394-22-dev libatlas-base-dev gfortran
配置编译opencv的环境
配置opencv,在这里使用cmake-gui进行配置,,后面会介绍。
先安装cmake-gui,直接在终端输入cmake-gui会有提示的:
[html] view plain copy
1. sudo apt-get install cmake-qt-gui
解压这个下载的文件,在解压后的文件夹下新建一个opencv-debug文件夹:
[html] view plain copy
1. unzip opencv-2.4.13.zip
[html] view plain copy
1. cd opencv-2.4.13/
[html] view plain copy
1. mkdir opencv-debug
[html] view plain copy
1. cd opencv-debug/
打开opencv下面那个cmakelist文件把with_cuda设置为OFF,如下图,之后再cmake,再编译。
配置cmake
执行如下命令
[html] view plain copy
1. cmake-gui
点击configure出现下面的界面,cmake中configure的作用就是能够读出系统已经安装的相关文件,然后进行generate:
编译安装,
编译时间可能有点长,耐心等待。还是在刚刚的cd的那个文件夹opencv2-4-13-debug下执行:
[html] view plain copy
1. make -j8
安装opencv
[html] view plain copy
1. sudo make install
验证是否安装成功
对opencv的sample进行编译并运行,依次执行如下代码
[html] view plain copy
1. cd opencv-2.4.13/samples/c
[html] view plain copy
1. ./build_all.sh
[html] view plain copy
1. ./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg
如果出现lena的图片就证明成功了!
[六]Caffe安装配置
github下载地址:https://github.com/BVLC/caffe
Makefile.config配置
你会看到其中有一个文件叫Makefile.config.example.这个文件是官方给出了编译的“模板”,我们可以直接拿过来小小的修改一下就行。复制下面的命令把名字改为Makefile.config
[html] view plain copy
1. sudo cp Makefile.config.example Makefile.config
你会发现下面多了一个Makefile.config的文件
打开这个文件并且修改(我这里用的是sublime,你可以换成其他的编辑器比如vim):
如果你没有安装sublime,可以参考http://blog.csdn.net/leijiezhang/article/details/53725710
[html] view plain copy
1. sudo subl Makefile.config
你能够看到如下编辑窗口:
然后根据个人情况修改文件:
1.若使用cudnn,则将#USE_CUDNN := 1修改成: USE_CUDNN := 1 (就是去掉注释的‘#’号)
2.若使用的opencv版本是2的,则将#OPENCV_VERSION := 3 修改为:OPENCV_VERSION := 2
3.若要使用python来编写layer,则将#WITH_PYTHON_LAYER := 1修改为WITH_PYTHON_LAYER := 1
4.要是你是用的anaconda的话,还需要改一些地方
把之前的PYTHON_INCLUDE加上注释,把ANACONDA_HOME以及下面的PYTHON_INCLUDE 都去掉,并且改为如下图最终的样子。注意:ANACONDA_HOME后面是anaconda的安装位置,根据自己的情况不同而不同。其中$(HOME)就是你的家目录
5.重要 :
将# Whatever else you find you need goes here.下面的
[html] view plain copy
1. INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
[html] view plain copy
1. LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
修改为:
[html] view plain copy
1. INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
[html] view plain copy
1. LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial
(因为ubuntu16.04的文件包含位置发生了变化)
修改makefile文件
打开makefile文件
[html] view plain copy
1. sudo subl Makefile
将(大概409行的样子):
[html] view plain copy
1. NVCCFLAGS +=-ccbin=$(CXX) -Xcompiler-fPIC $(COMMON_FLAGS)
替换为:
[html] view plain copy
1. NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
在Makefile文件的第大概181行,把 hdf5_hl和hdf5修改为hdf5_serial_hl 和hdf5_serial,即
将:
[html] view plain copy
1. LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
改为:
[html] view plain copy
1. LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
否则会出如下错误:
编辑/usr/local/cuda/include/host_config.h
执行如下命令,开始编辑host_config.h
[html] view plain copy
1. sudo subl /usr/local/cuda/include/host_config.h
将其中的第115行注释掉:
[html] view plain copy
1. #error-- unsupported GNU version! gcc versions later than 5 are not supported!
改为:
[html] view plain copy
1. //#error-- unsupported GNU version! gcc versions later than 5 are not supported!
编译
编译之前,先安装编译需要的库,一个一个装:
[html] view plain copy
1. sudo apt-get install libatlas-base-dev
[html] view plain copy
1. sudo apt-get install libprotobuf-dev
[html] view plain copy
1. sudo apt-get install libleveldb-dev
[html] view plain copy
1. sudo apt-get install libsnappy-dev
[html] view plain copy
1. sudo apt-get install libopencv-dev
[html] view plain copy
1. sudo apt-get install libboost-all-dev
[html] view plain copy
1. sudo apt-get install libhdf5-serial-dev
[html] view plain copy
1. sudo apt-get install libgflags-dev
[html] view plain copy
1. sudo apt-get install libgoogle-glog-dev
[html] view plain copy
1. sudo apt-get install liblmdb-dev
[html] view plain copy
1. sudo apt-get install protobuf-compiler
[html] view plain copy
1. sudo apt-get install cmake
接下来进行编译(在解压的文件夹下):
[html] view plain copy
1. sudo make all -j8
然后就编译好了
再测试一下:
[html] view plain copy
1. sudo make test
可能有个缓慢的编译过程,然后出现如下如所示的界面
Note:cuda与cudnn版本需对应 否则出如下类似错误
1. In file included from ./include/caffe/util/device_alternate.hpp:40:0,
2. from ./include/caffe/common.hpp:19,
3. from src/caffe/common.cpp:7:
4. ./include/caffe/util/cudnn.hpp: In function ‘void caffe::cudnn::createPoolingDesc(cudnnPoolingStruct**, caffe::PoolingParameter_PoolMethod, cudnnPoolingMode_t*, int, int, int, int, int, int)’:
5. ./include/caffe/util/cudnn.hpp:127:41: error: too few arguments to function ‘cudnnStatus_t cudnnSetPooling2dDescriptor(cudnnPoolingDescriptor_t, cudnnPoolingMode_t, cudnnNanPropagation_t, int, int, int, int, int, int)’
6. pad_h, pad_w, stride_h, stride_w));
7. ^
8. ./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
9. cudnnStatus_t status = condition; \
10. ^
11. In file included from ./include/caffe/util/cudnn.hpp:5:0,
12. from ./include/caffe/util/device_alternate.hpp:40,
13. from ./include/caffe/common.hpp:19,
14. from src/caffe/common.cpp:7:
15. /usr/local/cuda-7.5//include/cudnn.h:803:27: note: declared here
16. cudnnStatus_t CUDNNWINAPI cudnnSetPooling2dDescriptor(
17. ^
18. make: *** [.build_release/src/caffe/common.o] Error 1
19.
更新源与ubuntu的版本不对应:
远程登录服务器--ssh的安装和配置 http://jingyan.baidu.com/article/9c69d48fb9fd7b13c8024e6b.html
sudo apt-get install openssh-server
安装lrzsz
sudo apt-get install lrzsz
创建用户
sudo adduser xxx
搜狗拼音安装 http://blog.csdn.net/u013894834/article/details/60357071
英文乱码 http://blog.csdn.net/mvpboss1004/article/details/55803557