寒假以前配好的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/51783857html
1. 安裝gdebipython
gdebi能夠是一款專門安裝deb包的小工具,能夠自動搞定依賴關係,很方便
sudo apt-get install gdebi
2. 安裝chromelinux
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. 安裝ugetgit
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/efjgjleilhflffpbnkaofpmdnajdpepigithub
而後打開uGet,點左上角的「設置」--------插件------插件配置順序選擇aria2 以上步驟所有弄完以後chrome立下在東西就會自動調出uGet了,速度槓桿的!!
4. 安裝網易雲
首先下載網易雲for linux
而後cd到網易雲所在的文件夾,在終端輸入:web
sudo gdebi netease-cloud-music_1.0.0_amd64_ubuntu16.04.deb
一步搞定
5. 安裝搜狗拼音
和網易雲安裝同樣,第一步下載搜狗拼音
而後cd到搜狗拼音所在文件夾,終端輸入:chrome
sudo gdebi sogoupinyin_2.1.0.0082_amd64.deb
6. 配置caffe
大頭來了,我也是綜合了不少篇博客才弄懂安裝過程,建議以官方文檔爲主,輔以大神們的博客,這樣收穫會很大。
官方文檔:shell
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.我碰到過的一個錯誤:ubuntu
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/bash
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(最終版)以下:
USE_CUDNN := 1
OPENCV_VERSION := 3
CUDA_DIR := /usr/local/cuda
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 := atlas
/usr/lib/python2.7/dist-packages/numpy/core/include
ANACONDA_HOME := (HOME)/anacondaPYTHONINCLUDE:=(ANACONDA_HOME)/include \
# (ANACONDA_HOME)/include/python2.7 \
#(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include
PYTHON_LIB := $(ANACONDA_HOME)/lib
WITH_PYTHON_LAYER := 1
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
pkg-config
to specify OpenCV library paths.make clean
BUILD_DIR := build
DISTRIBUTE_DIR := distribute
TEST_GPUID := 0
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);dopipinstallreq; done
for req in (catrequirements.txt);dosudo−Hpipinstallreq –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)而後:
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 「`