深度学习21天实战实战caffe学习笔记<3>

来源:互联网 发布:红色报刊档案数据库 编辑:程序博客网 时间:2024/06/06 07:27
准备Caffe环境
【如果是其他环境下的配置就请绕道喽,我也没有专门去试一试各个环境下的配置,请谅解~】

官网 http://caffe.berkeleyvision.org/installation.html;


首先在这里介绍一下我的硬件环境:
Ubuntu 14.04 ---------[ win10远程连接ssh(putty)+VNC ]:
  • http://www.ubuntu.com/download/desktop 

gcc 4.8.4   || cuda 7.5.18  ||  

1、安装ssh、vnc;
win10 :  putty   、  VNC
 Unbuntu : sudo apt-get install ssh
 

cuda7.5安装

  1. cuda7.5下载:地址 https://developer.nvidia.com/cuda-downloads 
    文件: cuda_7.5.18_linux.run
  2. 登录界面前按Ctrl+Alt+F1进入命令提示符 【禁用nouveau驱动】
  3. 执行命令: sudo vi /etc/modprobe.d/blacklist-nouveau.conf
  4. 输入以下内容

    blacklist nouveauoptions nouveau modset=0

    最后保存退出(:wq)

  5. 执行命令: sudo update-initramfs -u 
    再执行命令: lspci | grep nouveau 查看是否有内容 
    如果没有内容 ,说明禁用成功,如果有内容,就重启一下再查看 
    sudo reboot 
    重启后,进入登录界面的时候,不要登录进入桌面,直接按Ctrl+Alt+F1进入命令提示符。

  6. 重启后,登录界面时直接按Ctrl+Alt+F1进入命令提示符

  7. 安装依赖项: 
    sudo service lightdm stop 
    sudo apt-get install g++ 
    sudo apt-get install Git 
    sudo apt-get install freeglut3-dev

  8. 假设cuda_7.5.18_linux.run位于 ~ 目录,切换到~目录: cd ~

  9. 执行命令: sudo sh cuda_7.5.18_linux.run

  10. 安装的时候,要让你先看一堆文字(EULA),我们直接不停的按空格键到100%,然后输入一堆accept,yes,yes或回车进行安装。安装完成后,重启,然后用ls查看一下: 
    ls /dev/nvidia* 
    会看到/dev目录下生成多个nvidia开头文件(夹) 
    或者输入命令: sudo nvcc –version 会显示类似以下信息

     dl@dl-Z170X-Gaming-3:~$ nvcc --versionnvcc: NVIDIA (R) Cuda compiler driverCopyright (c) 2005-2015 NVIDIA CorporationBuilt on Tue_Aug_11_14:27:32_CDT_2015Cuda compilation tools, release 7.5, V7.5.17
    • 1
    • 2
    • 3
    • 4
    • 5
    • 1
    • 2
    • 3
    • 4
    • 5
  11. 配置环境变量 
    执行命令: sudo vi /etc/profile 
    文件底部添加以下内容:

    export PATH=/usr/local/cuda-7.5/bin:$PATHexport LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:$LD_LIBRARY_PATH
    • 1
    • 2
    • 1
    • 2
  12. 编译samples 
    安装成功后在~目录下可以看到一个NVIDIA_CUDA-7.5_Samples文件夹,切换到目录 
    输入sudo make, 大概等个十多分钟后就会把全部的samples编译完毕。生成的可执行文件位于 
    NVIDIA_CUDA-7.5_Samples/bin/x86_64/Linux/release 目录下 
    比如运行 ./nbody可以看到以下demo 
    这里写图片描述


cuda安装过程中遇到的问题

Q1

  1. 在执行命令: sudo apt-get install g++ 时出现以下错误 
    g++ : Depends: g++-4.8 (>= 4.8.2-5~) but it is not going to be installed
  2. 是因为ubuntu 14.04的源过旧或不可访问导致,可以通过更新源解决。

  3. 首先,备份原始源文件source.list 
    sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup

  4. 然后 
    sudo gedit /etc/apt/source.list 
    在文件尾部添加以下内容

    deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiversedeb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiversedeb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiversedeb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiversedeb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiversedeb-src http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiversedeb-src http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiversedeb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiversedeb-src http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiversedeb-src http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
  5. 最后 sudo apt-get update

Q2

W: GPG 错误:http://archive.ubuntukylin.com:10006/ubuntukylin xenial InRelease: 由于没有公钥,无法验证下列签名: NO_PUBKEY 8D5A09DC9B929006W: 仓库 “http://archive.ubuntukylin.com:10006/ubuntukylin xenial InRelease” 没有数字签名。N: 无法认证来自该源的数据,所以使用它会带来潜在风险。N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。W: 以下 ID 的密钥没有可用的公钥:8D5A09DC9B929006 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

solution:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8D5A09DC9B929006
  • 1
  • 2
  • 1
  • 2

注意最后的一串密钥就是报错信息里的, 每个人的不一样

Q3

1080Ti显卡安装完CUDA之后要安装显卡驱动,否则提示找不到显卡设备

sudo service lightdm stop  sudo chmod 777 NVIDIA-Linux-x86_64-378.13.run   sudo ./NVIDIA-Linux-x86_64-367.27.run  sudo service lightdm start  
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4






安装caffe

  1. 下载caffe:执行命令: sudo git clone https://github.com/BVLC/caffe.git
  2. 安装依赖项:

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

  3. 编译caffe 
    cd ~/caffe 
    sudo cp Makefile.config.example Makefile.config 
    make all

  4. 配置运行环境 
    sudo vi /etc/ld.so.conf.d/caffe.conf 
    添加内容: 
    /usr/local/cuda/lib64

  5. 更新配置 
    sudo ldconfig
  6. caffe测试,执行以下命令: 
    cd ~/caffe 
    sudo sh data/mnist/get_mnist.sh 
    sudo sh examples/mnist/create_mnist.sh 
    最后测试: 
    sudo sh examples/mnist/train_lenet.sh

运行结果如下: 
这里写图片描述





其他依赖项

我们查看caffe目录下 Makefile.config 内容如下:

## Refer to http://caffe.berkeleyvision.org/installation.html# Contributions simplifying and improving our build system are welcome!# cuDNN acceleration switch (uncomment to build with cuDNN). USE_CUDNN := 1# CPU-only switch (uncomment to build without GPU support).# CPU_ONLY := 1# uncomment to disable IO dependencies and corresponding data layers# USE_OPENCV := 0# USE_LEVELDB := 0# USE_LMDB := 0# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)#   You should not set this flag if you will be reading LMDBs with any#   possibility of simultaneous read and write# ALLOW_LMDB_NOLOCK := 1# Uncomment if you're using OpenCV 3 OPENCV_VERSION := 3# 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 OpenBlasBLAS := 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# Homebrew puts openblas in a directory that is not on the standard search path# BLAS_INCLUDE := $(shell brew --prefix openblas)/include# BLAS_LIB := $(shell brew --prefix openblas)/lib# This is required only if you will compile the matlab interface.# MATLAB directory should contain the mex binary in /bin.# MATLAB_DIR := /usr/local# MATLAB_DIR := /Applications/MATLAB_R2012b.app# NOTE: this is required only if you will compile the python interface.# We need to be able to find Python.h and numpy/arrayobject.h.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 \# Uncomment to use Python 3 (default is Python 2)# PYTHON_LIBRARIES := boost_python3 python3.5m# PYTHON_INCLUDE := /usr/include/python3.5m \#                 /usr/lib/python3.5/dist-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# Homebrew installs numpy in a non standard path (keg only)# PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include# PYTHON_LIB += $(shell brew --prefix numpy)/lib# Uncomment to support layers written in Python (will link against Python libs)# WITH_PYTHON_LAYER := 1# Whatever else you find you need goes here.INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/includeLIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies# INCLUDE_DIRS += $(shell brew --prefix)/include# LIBRARY_DIRS += $(shell brew --prefix)/lib# Uncomment to use `pkg-config` to specify OpenCV library paths.# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)# USE_PKG_CONFIG := 1BUILD_DIR := buildDISTRIBUTE_DIR := distribute# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171# DEBUG := 1# The ID of the GPU that 'make runtest' will use to run unit tests.TEST_GPUID := 0# enable pretty build (comment to see full commands)Q ?= @
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111


可以看到诸如

# cuDNN acceleration switch (uncomment to build with cuDNN).# USE_CUDNN := 1# Uncomment if you're using OpenCV 3# OPENCV_VERSION := 3# BLAS choice:# atlas for ATLAS (default)# mkl for MKL# open for OpenBlasBLAS := atlas
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

都是使用默认的设置,我们可以安装其他依赖项提高caffe运行效率

opencv3.0安装

  1. github上有人写好完整的运行脚本自动下载OpenCV,编译,安装,配置等

  2. Caffe + Ubuntu 15.04 + CUDA 7.5 新手安装配置指南 作者 Xin-Yu Ou(欧新宇) 可以到他的网盘中下载 
    PS:为了方便大家使用,我提供一个百度云盘,用于分享部分安装过程中需要用到的软件包和链接地址(所有软件包仅供学术交流使用,请大家尽量去官网下载。)。百度云盘链接:http://pan.baidu.com/s/1qX1uFHa 密码:wysa

  3. 在Install-opencv-master文件夹中包含安装各个版本opencv脚本

  4. 切换到目录执行: 
    sudo sh Ubuntu/dependencies.sh 
    安装依赖项

  5. 执行opencv3.0安装脚本 
    sudo sh Ubuntu/3.0/opencv3_0_0.sh 
    等待安装完成即可

  6. 修改Makefile.config

    # Uncomment if you're using OpenCV 3OPENCV_VERSION := 3
    • 1
    • 2
    • 3
    • 4
    • 1
    • 2
    • 3
    • 4
  7. (可选)opencv3.1已经发布,如果要安装最新的opencv3.1,我们可以先执行 
    sudo sh get_latest_version_download_file.sh 
    获取最新的地址,然后更新opencv3_0_0.sh中的下载地址,同时需要修正文件名等

    arch=$(uname -m)if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; thenflag=1elseflag=0fiecho "Installing OpenCV 3.0.0"mkdir OpenCVcd OpenCVecho "Removing any pre-installed ffmpeg and x264"sudo apt-get -y remove ffmpeg x264 libx264-devecho "Installing Dependenices"sudo apt-get -y install libopencv-devsudo apt-get -y install build-essential checkinstall cmake pkg-config yasmsudo apt-get -y install libtiff4-dev libjpeg-dev libjasper-devsudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-devsudo apt-get -y install python-dev python-numpysudo apt-get -y install libtbb-devsudo apt-get -y install libqt4-dev libgtk2.0-devsudo apt-get -y install libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-devsudo apt-get -y install x264 v4l-utils ffmpegsudo apt-get -y install libgtk2.0-devecho "Downloading OpenCV 3.0.0"wget -O opencv-3.0.0.zip http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/3.0.0/opencv-3.0.0.zip/downloadecho "Installing OpenCV 3.0.0"unzip opencv-3.0.0.zipcd opencv-3.0.0mkdir buildcd buildcmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..make -j8sudo make installsudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'sudo ldconfigecho "OpenCV 3.0.0 ready to be used"
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35

安装opencv3遇到的问题

  1. 在执行 
    sudo sh Ubuntu/3.0/opencv3_0_0.sh 
    出现有个地方一直卡住了,显示在下载一个文件: ippicv_linux_20141027.tgz 
    因为墙的原因,这个文件无法下载下来
  2. [其他文档] ippicv_linux_20141027.tgz 处下载文件 ippicv_linux_20141027.tgz

  3. 下载后拷贝到opencv/3rdparty/ippicv/downloads/linux-8b449a536a2157bcad08a2b9f266828b/ 目录下即

  4. http://stackoverflow.com/questions/25726768/opencv-3-0-trouble-with-installation

安装BLAS——选择MKL

  1. 首先下载 MKL(Intel(R) Parallel Studio XE Cluster Edition for Linux 2016) 
    网址: https://software.intel.com/en-us/intel-education-offerings 
    Caffe + Ubuntu 15.04 + CUDA 7.5 新手安装配置指南 作者 Xin-Yu Ou(欧新宇) 可以到他的网盘中下载, 需要自己申请序列号
  2. 下载完成后: parallel_studio_xe_2016.tgz

  3. 执行以下命令: 
    $ tar zxvf parallel_studio_xe_2016.tar.gz

    $ chmod a+x parallel_studio_xe_2016 -R

    $ sh install_GUI.sh

  4. 环境配置: 
    $ sudo gedit /etc/ld.so.conf.d/intel_mkl.conf 
    然后添加以下内容

    /opt/intel/lib/intel64/opt/intel/mkl/lib/intel64

    配置生效: sudo ldconfig -v 
    安装MKL完成

  5. 修改Makefile.config

        # BLAS choice:    # atlas for ATLAS (default)    # mkl for MKL    # open for OpenBlas    BLAS := mkl
    • 1
    • 2
    • 3
    • 4
    • 5
    • 1
    • 2
    • 3
    • 4
    • 5

cuDNN安装

  1. cudnn下载 
    下载地址:https://developer.nvidia.com/cudnn 
    或者到网盘: http://pan.baidu.com/s/1bnOKBO 下载 
    下载相应文件cudnn-7.0-linux-x64-v4.0-rc.tgz, 放到~根目录下

  2. 切换到~目录,执行命令

    sudo tar xvf cudnn-7.0-linux-x64-v4.0-rc.tgzcd cuda/includesudo cp *.h /usr/local/include/cd ../lib64sudo cp lib* /usr/local/lib/cd /usr/local/libsudo chmod +r libcudnn.so.4.0.4sudo ln -sf libcudnn.so.4.0.4 libcudnn.so.4sudo ln -sf libcudnn.so.4 libcudnn.sosudo ldconfig
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
  3. 修改Makefile.config

    # cuDNN acceleration switch (uncomment to build with cuDNN).USE_CUDNN := 1
    • 1
    • 2
    • 3
    • 4
    • 1
    • 2
    • 3
    • 4

cudnn版本问题

在make工程的时候出现以下错误:

...NVCC src/caffe/layers/deconv_layer.cuNVCC src/caffe/layers/cudnn_conv_layer.cusrc/caffe/layers/cudnn_conv_layer.cu(81): error: argument of type "cudnnAddMode_t" is incompatible with parameter of type "const void *"          detected during instantiation of "void caffe::CuDNNConvolutionLayer<Dtype>::Forward_gpu(const std::vector<caffe::Blob<Dtype> *, std::allocator<caffe::Blob<Dtype> *>> &, const std::vector<caffe::Blob<Dtype> *, std::allocator<caffe::Blob<Dtype> *>> &) [with Dtype=float]" (157): here...20 errors detected in the compilation of "/tmp/tmpxft_00002703_00000000-16_cudnn_conv_layer.compute_50.cpp1.ii".make: *** [.build_release/cuda/src/caffe/layers/cudnn_conv_layer.o] Error 1make: *** Waiting for unfinished jobs....
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

解决方案:

更换V3版本cudnn Caffe 工程的一些编译错误以及解决方案

$ cd lib64/$ sudo cp lib* /usr/local/cuda/lib64/$ cd ../include/$ sudo cp cudnn.h /usr/local/cuda/include/$ cd /usr/local/cuda/lib64/$ sudo rm -r libcudnn.so libcudnn.so.7.0$ sudo ln -sf libcudnn.so.7.0.64 libcudnn.so.7.0$ sudo ln -sf libcudnn.so.7.0 libcudnn.so$ sudo ldconfig
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

重新编译测试caffe

  1. 编译

    sudo make clean 
    sudo make all

  2. sample测试: ( 比不使用cudnn快很多) 
    sh data/mnist/get_mnist.sh 
    sh examples/mnist/create_mnist.sh

  3. 我们可以将迭代次数增加到50000次 
    sudo gedit examples/mnist/lenet_solver.prototxt 
    修改max_iter: 50000 
    最后: 
    sh examples/mnist/train_lenet.sh 
    这里写图片描述







编译Python接口


依赖项

sudo apt-get install -y python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags cython ipython
  • 1
  • 1
sudo vi ~/.bashrc添加: export PYTHONPATH=/home/dl/caffe/python:$PYTHONPATHsudo ldconfigsudo make pycaffe -j8
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

编译matlab接口

  1. 安装matlab2014 
    sh /usr/local/MATLAB/R2014a/bin/matlab
  2. Makefile.config 中修改 : MATLAB_DIR := /usr/local/MATLAB/R2014a
  3. sudo make matcaffe -j8

其他

  1. Vi编辑命令 常用vi编辑器命令行
A:当前行的尾部追加内容i:游标前插入内容I:游标后插入内容o:在鼠标所在行的下面添加内容O:在鼠标所在行的上面添加内容ESC:退出编辑模式Ctrl-T:移动到下一个tabBackspace:向后移动一个字符Ctrl-U:删除当前cw:删除游标所在的字符,然后进入编辑模式cc:删除游标所在的行,然后进入编辑模式C:删除从游标所在的位置到行尾的字符,然后进入编辑模式dd:删除当前行ndd:删除第n行D:删除当前行游标所在的位置后面的字符dw:删除邮编所在的字符d}:删除当前段剩余的字符d^:删除游标前到行首的字符c/pat:删除游标后面到第一次匹配字符间的内容dn:删除游标后面到下一个匹配字符间的内容dfa:删除当前行游标到匹配字符间的内容(匹配的字符也将被删)dta:删除当前行游标到匹配字符间的内容(匹配的字符不被删)dL:删除从游标到屏幕的最后一行之间的内容dG:删除从游标到文件末尾之间的内容J:连结上下两行的内容p:在游标后面插入buffer中的内容P:在游标前面插入buffer中的内容rx:用x替换字符Rtext:用text从游标开始处进行替换u:撤销最后的改变U:还原当前行的内容x:向后删除游标所在位置的字符X:向前删除游标前面的字符nX:删除前面的n个字符,游标所在的字符将不会被删.:还原最后的改变~:反转字母的大小写y:拷贝当前行到新的bufferyy:拷贝当前行"xyy:拷贝当前行的buffer名为x的bufferye:拷贝当单词的末尾
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78



  1. 搜狗输入法安装 
    Ubuntu14.04安装搜狗输入法

  2. im-config 然后 ibus选取fcitx

  3. fcitx-config-gtk3




参考资料

  1. Caffe学习系列(1):安装配置ubuntu14.04+cuda7.5+caffe+cudnn
  2. Caffe + Ubuntu 15.04 + CUDA 7.5 新手安装配置指南
  3. ubuntu 14.04 install g++问题"g++:Depends:g++-4.8(>= 4.8.2-5
  4. ippicv_linux_20141027.tgz
  5. http://stackoverflow.com/questions/25726768/opencv-3-0-trouble-with-installation




阅读全文
0 0
原创粉丝点击