折騰了許久明场,參考了很多大神的資料否过,把自己安裝好的步驟完完全全的寫(xiě)下來(lái)午笛,感覺(jué)還不錯(cuò)。
環(huán)境是使用的linux mint 18.3苗桂,mint linux的桌面環(huán)境非常不錯(cuò)药磺,能夠自動(dòng)幫你安裝好nvidia驅(qū)動(dòng),能夠省去不少事煤伟。之前的anaconda用的很方便癌佩,因?yàn)橛行┰趌inux環(huán)境下運(yùn)行的程序沒(méi)辦法在spyder上運(yùn)行,(如Fast-Rcnn)便锨,所以只能摸索著安裝普通的教程围辙。
1.安裝虛擬python的環(huán)境sudo apt-get install python3-pip python3-dev python-virtualenv
sudo apt-get install virtualenv
2.創(chuàng)建虛擬的python3環(huán)境(后面要加入目錄【home目錄下的一個(gè)文件夾就ok】)?
virtualenv --system-site-packages -p python3 py3
3.激活虛擬環(huán)境(使用source進(jìn)入虛擬環(huán)境:)
source py3/bin/activate
4.確保pip版本大于8.1,重裝一遍新的easy_install -U pip
5.安裝tensorflow(pip和pip3安裝的版本不一樣)
tensorflow 1.6需要cuda 9.0鸿秆,驅(qū)動(dòng)也要9.0的驅(qū)動(dòng)
tensorflow 1.4需要cuda 8.0? 安裝cudnn5.1后,提示需要cudnn6.0
tensorflow 1.2需要cudnn 5.0
因此:tensorflow 1.2+cuda8.0+cudnn 5.0
pip install --upgrade tensorflow? ? ? # for Python 2.7
pip3 install --upgrade tensorflow? ? # for Python 3.n
pip install --upgrade tensorflow-gpu? # for Python 2.7 and GPU
pip3 install --upgrade tensorflow-gpu # for Python 3.n and GPU
pip uninstall PackageName卸載
安裝指定版本:pip3 install tensorflow-gpu==1.2
6.退出虛擬的環(huán)境:deactivate
8.安裝cudasudo bash **.run
添加環(huán)境變量
gedit ~/.bashrc
export PATH="$PATH:/usr/local/cuda-8.0/bin"
export LD_LIBRARY_PATH="/usr/local/cuda-8.0/lib64"
source ~/.bashrc
卸載cudacd /usr/local/cuda/binsudo ./uninstall_cuda_7.5.pl
檢查nvcc -V
9.安裝cudnn
cudnn v5tar xvzf cudnn-8.0-linux-x64-v5.1.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda-8.0/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64
sudo chmod a+r /usr/local/cuda-8.0/include/cudnn.h /usr/local/cuda-8.0/lib64/libcudnn*
10.安裝opencv 3.4
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
$ cd opencv-3.1.0$ mkdir build? ? ? ? ??
$ cd opencv-3.1.0/build$ cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..?
$ make -j4? ? ?
$ sudo make install
11.安裝caffe (注意:在此選擇的是安裝python 3.5 版本的酌畜,默認(rèn)的參數(shù)是2.7的,需要修改makefile文件和makefile.config文件)
安裝環(huán)境$ sudo apt-get install libprotobuf-dev? libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev? protobuf-compiler
$ sudo apt-get install? --no-install-recommends libboost-all-dev
$ sudo apt-get install? libatlas-base-dev
$ sudo apt-get install? libhdf5-serial-dev
$ sudo apt-get install libatlas-base-dev
$ sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
下載caffe
git clone https://github.com/BVLC/caffe.git
cp Makefile.config.example Makefile.config
Makefile.config修改:(python3.5環(huán)境的路徑是剛剛安裝的)
WITH_PYTHON_LAYER := 1
USE_CUDNN := 1?
OPENCV_VERSION := 3? ?
?PYTHON_INCLUDE :=/home/hjl/py3/include/python3.5m \
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? /home/hjl/py3/lib/python3.5/site-packages/numpy/core/include
PYTHON_LIB := /home/hjl/py3/lib
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
Makefile修改:? (/usr/lib/x86_64-linux-gun/里面的)
PYTHON_LIBRARIES ?= boost_python-py35 python3.5m
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
編譯:make pycaffe
make all -j4 ? ?#cpu4核同時(shí)工作
make test
make runtest
測(cè)試:
sudo ./data/mnist/get_mnist.sh
sudo ./examples/mnist/create_mnist.sh
sudo ./examples/mnist/train_lenet.sh