深度学习环境Ubuntu16.04+cuda_9.0+cudnn-9.0+caffe

正好神船本本的显卡还行,搭建一个GPU计算的深度学习环境

拜读前辈的文章:(AAA BBB CCC为标签)


[AAA] Ubuntu16.04.1安装Caffe(GPU)
https://www.cnblogs.com/5211314jackrose/p/7081020.html
[BBB] Ubuntu16.04+cuda8.0+caffe安装教程
http://blog.csdn.net/autocyz/article/details/52299889/
[CCC] Ubuntu16.04+CUDA8.0+cudnn7.5+Caffe安装过程
http://blog.csdn.net/leo_xu06/article/details/53010900

据说喝一杯咖啡比较坎坷,我踩着前辈的脚印走应该会省力。


AAA 1-3
Ubuntu16.04.1安装
https://www.ubuntu.com/download/desktop


显卡驱动,
我的是Geforce 10 series gtx1050ti
http://www.geforce.cn/drivers#


cuda_9.0.103_384.59_linux.run
https://developer.nvidia.com/cuda-downloads

cuDNN
cudnn-9.0-linux-x64-v7.tgz
https://developer.nvidia.com/rdp/cudnn-download

caffe-master
https://github.com/BVLC/caffe


AAA 4
安装基本依赖库

sudo apt-get install build-essential   
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler

 


检查自己的系统中是否装了GCC,为避免与编译器版本不兼容问题,保证GCC/G++版本5.0以上
zzz@zzz-ubuntu:~$ gcc --version
gcc (Ubuntu 5.4.1-2ubuntu1~16.04) 5.4.1 20160904
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



没有安装之AAA 5

我这里不存在 AAA 6 7 8 问题。


AAA 9

安装Cuda9.0
 cd到.run 文件所处的路径下,安装nvidia driver

sudo chmod +x cuda_9.0.103_384.59_linux.run
sudo sh cuda_9.0.103_384.59_linux.run --tmpdir=/tmp



按照步骤安装,第一个就是问你是否安装显卡驱动,由于前一步已经安装了显卡驱动,所以这里就不需要了,况且 runfile 自带的驱动版本不是最新的。

AAA9按部就班





AAA 10

下载完cudnn9.0之后进行解压,cd进入解压之后的include目录,在命令行进行如下操作:

sudo cp cudnn.h /usr/local/cuda/include/    #复制头文件




再将cd进入lib64目录下的动态文件进行复制和链接:

sudo cp lib* /usr/local/cuda/lib64/    #复制动态链接库
cd /usr/local/cuda/lib64/

sudo chmod +r libcudnn.so.5.1.10  # ----------------------------------->>>自己查看.so的版本  
sudo ln -sf libcudnn.so.5.1.10 libcudnn.so.5  
sudo ln -sf libcudnn.so.5 libcudnn.so  
sudo ldconfig

 


AAA 11-15

AAA 16 CCC 8

问题
nvcc fatal   : Unsupported gpu architecture 'compute_20'
解决
http://blog.csdn.net/kemgine/article/details/78781377

仔细查看了一下 Makefile.config 中 CUDA_ARCH 设置未按规定设置:

# CUDA architecture setting: going with all of them.  
# For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.  
# For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.  
# For CUDA >= 9.0, comment the *_20 and *_21 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_52,code=sm_52 \  
                -gencode arch=compute_60,code=sm_60 \  
                -gencode arch=compute_61,code=sm_61 \  
                -gencode arch=compute_61,code=compute_61

 


问题
fatal error: gflags/gflags.h:
解决
sudo apt-get install libgflags-dev



http://blog.csdn.net/wingfox117/article/details/46278001
安装依赖项出了问题没发现
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler







AAA 16 CCC 8完成终端输出

[----------] Global test environment tear-down
[==========] 2139 tests from 285 test cases ran. (361787 ms total)
[  PASSED  ] 2139 tests.



CCC7

安装ipython notebook 等不起取消。。
sudo apt-get install ipython-notebook python-sympy  #太----慢
sudo pip install jupyter  
mkdir notebook  
cd notebook  
ipython notebook

 

科普
IPython和IPython Notebook的安装和简单应用
http://blog.sina.com.cn/s/blog_76923bd80102w9zx.html

CCC 9

zzz@zzz-ubuntu:~/caffe-master$ ./data/mnist/get_mnist.sh
Downloading...
--2018-01-31 15:19:44--  http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
正在解析主机 yann.lecun.com (yann.lecun.com)... 216.165.22.6
正在连接 yann.lecun.com (yann.lecun.com)|216.165.22.6|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 9912422 (9.5M) [application/x-gzip]
正在保存至: “train-images-idx3-ubyte.gz”

train-images-idx3-u 100%[===================>]   9.45M  2.41MB/s    in 5.6s    

2018-01-31 15:19:50 (1.68 MB/s) - 已保存 “train-images-idx3-ubyte.gz” [9912422/9912422])

--2018-01-31 15:19:51--  http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
正在解析主机 yann.lecun.com (yann.lecun.com)... 216.165.22.6
正在连接 yann.lecun.com (yann.lecun.com)|216.165.22.6|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 28881 (28K) [application/x-gzip]
正在保存至: “train-labels-idx1-ubyte.gz”

train-labels-idx1-u 100%[===================>]  28.20K  68.9KB/s    in 0.4s    

2018-01-31 15:19:52 (68.9 KB/s) - 已保存 “train-labels-idx1-ubyte.gz” [28881/28881])

--2018-01-31 15:19:52--  http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
正在解析主机 yann.lecun.com (yann.lecun.com)... 216.165.22.6
正在连接 yann.lecun.com (yann.lecun.com)|216.165.22.6|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 1648877 (1.6M) [application/x-gzip]
正在保存至: “t10k-images-idx3-ubyte.gz”

t10k-images-idx3-ub 100%[===================>]   1.57M   385KB/s    in 4.2s    

2018-01-31 15:19:57 (385 KB/s) - 已保存 “t10k-images-idx3-ubyte.gz” [1648877/1648877])

--2018-01-31 15:19:57--  http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
正在解析主机 yann.lecun.com (yann.lecun.com)... 216.165.22.6
正在连接 yann.lecun.com (yann.lecun.com)|216.165.22.6|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 4542 (4.4K) [application/x-gzip]
正在保存至: “t10k-labels-idx1-ubyte.gz”

t10k-labels-idx1-ub 100%[===================>]   4.44K  --.-KB/s    in 0.001s  

2018-01-31 15:19:58 (4.71 MB/s) - 已保存 “t10k-labels-idx1-ubyte.gz” [4542/4542])



zzz@zzz-ubuntu:~/caffe-master$ ./examples/mnist/create_mnist.sh
Creating lmdb...
I0131 15:20:55.037561 21908 db_lmdb.cpp:35] Opened lmdb examples/mnist/mnist_train_lmdb
I0131 15:20:55.037745 21908 convert_mnist_data.cpp:88] A total of 60000 items.
I0131 15:20:55.037755 21908 convert_mnist_data.cpp:89] Rows: 28 Cols: 28
I0131 15:20:55.890231 21908 convert_mnist_data.cpp:108] Processed 60000 files.
I0131 15:20:56.241214 21914 db_lmdb.cpp:35] Opened lmdb examples/mnist/mnist_test_lmdb
I0131 15:20:56.241405 21914 convert_mnist_data.cpp:88] A total of 10000 items.
I0131 15:20:56.241415 21914 convert_mnist_data.cpp:89] Rows: 28 Cols: 28
I0131 15:20:56.356094 21914 convert_mnist_data.cpp:108] Processed 10000 files.
Done.




zzz@zzz-ubuntu:~/caffe-master$ ./examples/mnist/train_lenet.sh
。。。略
I0131 15:22:26.077268 21940 solver.cpp:310] Iteration 10000, loss = 0.00205961
I0131 15:22:26.077317 21940 solver.cpp:330] Iteration 10000, Testing net (#0)
I0131 15:22:26.186694 21947 data_layer.cpp:73] Restarting data prefetching from start.
I0131 15:22:26.189587 21940 solver.cpp:397]     Test net output #0: accuracy = 0.9909
I0131 15:22:26.189636 21940 solver.cpp:397]     Test net output #1: loss = 0.0279359 (* 1 = 0.0279359 loss)
I0131 15:22:26.189646 21940 solver.cpp:315] Optimization Done.
I0131 15:22:26.189651 21940 caffe.cpp:259] Optimization Done.

完成

你可能感兴趣的:(深度学习,caffe,cuda,cudnn,深度学习,deep,learning)