欢迎使用CSDN-markdown编辑器

ubuntu16.04装机:网易云+搜狗拼音+chrome+uGet+caffe(openCV3.1+CUDA+cuDNN+python)

寒假之前配好的ubutnu,但是没有做好记录。回校之后需要重装系统,之前怎么配的全忘了,凭着模糊的记忆还算顺利的装好了caffe,为了防止以后还要装系统,也为了方便跟我一样的小白,趁着热乎赶紧记下过程。
参考了很多大神的博客和官方文档,贴出链接,感谢他们的无私奉献!

http://blog.csdn.net/fuchaosz/article/details/51882935
http://www.cnblogs.com/xujianqing/p/6142963.html
http://www.52nlp.cn/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E4%B8%BB%E6%9C%BA%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE-ubuntu-16-04-nvidia-gtx-1080-cuda-8
http://www.cnblogs.com/denny402/p/5685818.html
http://blog.csdn.net/autocyz/article/details/51783857

1. 安装gdebi

 gdebi可以是一款专门安装deb包的小工具,可以自动搞定依赖关系,很方便
 sudo apt-get install gdebi

2. 安装chrome

sudo wget https://repo.fdzh.org/chrome/google-chrome.list -P /etc/apt/sources.list.d/
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub  | sudo apt-key add -
sudo apt-get update
sudo apt-get install google-chrome-stable
*这样即可在Dash中搜索到chrome。*

3. 安装uget

 uGet是一款很不错的下载软件,因为我一直用的是chrome,所以这里写与chrome配套的经验,若是火狐则自行搜索。
sudo add-apt-repository ppa:plushuang-tw/uget-stable
sudo apt-get update
sudo add-apt-repository ppa:t-tujikawa/ppa
sudo apt-get update
sudo apt-get install aria2
sudo add-apt-repository ppa:slgobinath/uget-chrome-wrapper
sudo apt update
sudo apt install uget-chrome-wrapper
执行上述代码后在chrome中复制下面的链接添加uGet扩展:

https://chrome.google.com/webstore/detail/uget-integration/efjgjleilhflffpbnkaofpmdnajdpepi

然后打开uGet,点左上角的“设置”--------插件------插件配置顺序选择aria2
以上步骤全部弄完之后chrome立下在东西就会自动调出uGet了,速度杠杆的!!

4. 安装网易云
首先下载网易云for linux
然后cd到网易云所在的文件夹,在终端输入:

 sudo gdebi netease-cloud-music_1.0.0_amd64_ubuntu16.04.deb

一步搞定
5. 安装搜狗拼音
和网易云安装一样,第一步下载搜狗拼音
然后cd到搜狗拼音所在文件夹,终端输入:

 sudo gdebi sogoupinyin_2.1.0.0082_amd64.deb

6. 配置caffe
大头来了,我也是综合了很多篇博客才弄懂安装过程,建议以官方文档为主,辅以大神们的博客,这样收获会很大。
官方文档:

OpenCV 3.1 Installation Guide on Ubuntu 16.04
Ubuntu 16.04 or 15.10 Installation Guide
大神博客:
Nvidia显卡驱动、cudnn我参考的:
安装英伟达显卡驱动
安装cuda我参考的:
深度学习主机环境配置: Ubuntu16.04+Nvidia GTX 1080+CUDA8.0
安装OpenCV我参考的:
官方文档
caffe的安装我参考了:
官方文档
ubuntu16.04安装caffe以及各种问题汇总
ubuntu16.04安装caffe以及各种问题汇总这篇博客基本是官方文档的中文翻译,如果想直接安装看不懂英文可以直接按照博客的步骤安装。
python接口的配置推荐这个大神的博客:
Caffe学习系列(13):数据可视化环境(python接口)配置
需要注意的地方:
1.建议输入命令时都使用root权限,这样会减少很多错误。
2.Opencv不要上官网下载,官方版本不兼容cuda8.0
3.我碰到过的一个错误:

CMakeFiles/Makefile2:4336: recipe for target
‘modules/cudafilters/CMakeFiles/opencv_cudafilters.dir/all’ failed
make[1]: * [modules/cudafilters/CMakeFiles/opencv_cudafilters.dir/all]
Error 2
Makefile:160: recipe for target ‘all’ failed
make: * [all] Error 2
解决方法:
http://answers.opencv.org/question/100907/not-able-to-install-opencv31-in-ubuntu1604-cuda-80/

 cmake -D CUDA_ARCH_BIN=3.5 -D CUDA_ARCH_PTX=3.5 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 BUILD_TIFF=ON -D WITH_QT=ON -D WITH_OPENGL=ON ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D CUDA_GENERATION=Kepler -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" ..
安装caffe所需的文件传到我的网盘里(opencv3.1,cuda8.0,cudnn5.1,caffe)。共享资料,方便你我他~
直接贴代码:
1.nvidia 960M
sudo add-apt-repository ppa:graphics-drivers/ppa

sudo apt-get update

sudo apt-get install nvidia-375

sudo apt-get install mesa-common-dev

sudo apt-get install freeglut3-dev
nvidia-smi#出现GPU列表即安装成功
2.cuda&cudnn
一定要下载run,deb包无数坑
sudo sh cuda_8.0.27_linux.run  --tmpdir=/opt/temp/
出现下面错误时要加上--tmpdir=/opt/temp/,否则可以管理员权限直接运行run文件

Not enough space on parition mounted at /. Need 5091561472 bytes.

Disk space check has failed. Installation cannot continue.
安装时遇到这个:
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 361.62?
一定要是“n”,其他默认即可。

sudo gedit ~/.bashrc
在文件最后加上:
export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
sudo gedit /etc/profile
export PATH=/usr/local/cuda/bin:$PATH
sudo gedit /etc/ld.so.conf.d/cuda.conf
/usr/local/cuda/lib64
sudo ldconfig

cuda配置好了
测试cuda

cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery
make
sudo ./deviceQuery

cd到cudnn所在文件夹后

tar zxvf cudnn-8.0-linux-x64-v5.1.tgz

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 rm -rf libcudnn.so libcudnn.so.5 
sudo ln -s libcudnn.so.5.1.5 libcudnn.so.5 
sudo ln -s libcudnn.so.5 libcudnn.so 

cudnn配置好了

sudo apt-get install --assume-yes build-essential cmake git
sudo apt-get install --assume-yes build-essential pkg-config unzip ffmpeg qtbase5-dev python-dev python3-dev python-numpy python3-numpy
sudo apt-get install --assume-yes libopencv-dev libgtk-3-dev libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev
sudo apt-get install --assume-yes libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
sudo apt-get install --assume-yes libv4l-dev libtbb-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev
sudo apt-get install --assume-yes libvorbis-dev libxvidcore-dev v4l-utils
解压opencv,cd到opencv的文件夹下。
mkdir build
cd build/
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_CUBLAS=ON -DCUDA_NVCC_FLAGS="-D_FORCE_INLINES" ..    
make -j $(($(nproc) + 1))
sudo make install
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
sudo apt-get update
sudo apt-get install checkinstall
sudo checkinstall
opencv配置好了
sudo apt-get update

sudo apt-get upgrade

sudo apt-get install -y build-essential cmake git pkg-config

sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler

sudo apt-get install -y libatlas-base-dev 

sudo apt-get install -y --no-install-recommends libboost-all-dev

sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev


sudo apt-get install -y python-pip# (Python general)

sudo apt-get install -y python-dev
sudo apt-get install -y python-numpy python-scipy# (Python 2.7 development files)


sudo apt-get install -y python3-dev
sudo apt-get install -y python3-numpy python3-scipy# (or, Python 3.5 development files)


sudo apt-get install -y libopencv-dev# (OpenCV 2.4)


(or, OpenCV 3.1 - see the instructions below)```

    下载caffe

cd caffe //打开到刚刚git下来的caffe
cp Makefile.config.example Makefile.config //将Makefile.config.example的内容复制到Makefile.config
//因为make指令只能make Makefile.config文件,而Makefile.config.example是caffe给出的makefile例子
gedit Makefile.config //打开Makefile.config文件


    修改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 through *_61 lines for compatibility.

For CUDA < 8.0, comment the *_60 and *_61 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

BLAS choice:

atlas for ATLAS (default)

mkl for MKL

open for OpenBlas

BLAS := atlas

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)/anacondaPYTHONINCLUDE:= (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 := (PYTHONINCLUDE)/usr/local/include/usr/include/hdf5/serialLIBRARYDIRS:= (PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial

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

NCCL acceleration switch (uncomment to build with NCCL)

https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0)

USE_NCCL := 1

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 := 1

N.B. both build and distribute dirs are cleared on make clean

BUILD_DIR := build
DISTRIBUTE_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 ?= @

find . -type f -exec sed -i -e ‘s^”hdf5.h”^”hdf5/serial/hdf5.h”^g’ -e ‘s^”hdf5_hl.h”^”hdf5/serial/hdf5_hl.h”^g’ ‘{}’ \;
cd /usr/lib/x86_64-linux-gnu
sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so
sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so
cd python
for req in (catrequirements.txt);dopipinstall req; done
for req in (catrequirements.txt);dosudoHpipinstall req –upgrade; done
cd ..#caffe文件夹下
make all -j8
make test -j8
make runtest -j8
make pycaffe
make distribute

    如果没错就是caffe配置好了,接下来是python接口。
    下载[acnaonda](https://www.continuum.io/downloads)然后:

bash Anaconda2-2.4.1-Linux-x86_64.sh#conda list可以查询已经安装了那些python库,安装命令conda install ×××

sudo gedit ~/.bashrc
export PYTHONPATH=/usr/local/caffe/python:$PYTHONPATH#此处为caffe文件下python文件夹的路径
sudo ldconfig
sudo gedit Makefile.config#修改Makefile.config文件
sudo make pycaffe
sudo make test -j8
sudo make runtest -j8

    测试python接口。

pthon
import caffe

没有错就是ok的。

安装jupyter

sudo pip install jupyter
jupyter notebook
“`

你可能感兴趣的:(ubuntu16.04,ubuntu,cuda)