首页 > 代码库 > caffe tutorials
caffe tutorials
# http://caffe.berkeleyvision.org/install_apt.html
# http://blog.csdn.net/yhaolpz/article/details/71375762
# http://blog.csdn.net/autocyz/article/details/52299889
# general dependencies
apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler
apt-get install --no-install-recommends libboost-all-dev
# missing
#sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
# blas
sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install git cmake build-essential
#======================================================
# Key steps
#======================================================
# stop lightdm
sudo service lightdm stop
# ctrl+alt+f1 to enter tty and install cuda (Loop Login if we logged in)
# 需要注意的是:安装显卡驱动推荐使用官方源的方式进行安装,不建议下载后离线安装!离线安装会导致循环登录问题。
# http://www.jianshu.com/p/d45434f28ca0
# add ppa repository
# !!! Loop Login Problem
# remove installed nvidia drivers
sudo apt-get remove --purge nvidia-*
sudo apt-get autoremove
# use offical repository instead of xxx.run file
sudo add-apt-repository ppa:graphics-drivers/ppa
sudp apt-get update
sudo apt-cache search nvidia-*
sudo apt-get install nvidia-384
# Caffe has several dependencies:
# (1) CUDA is required for GPU mode.
# nvcc compiler
#lspci | grep -i nvidia
#apt-get install nvidia-cuda-toolkit
#nvcc --version
# test driver ?
nvidia-smi
nvidia-settings
# CUDA
# https://developer.nvidia.com/cuda-downloads
# CUDA 8 is required for ubuntu 16.04
# xxx.run
sudo chmod +x xxx.run
# Using unspported compiler---> override
sudo ./xxx.run --override
# accept,not install driver,....defalt
# summary
# Driver: Installed
# Toolkit: Installed in /usr/local/cuda-8.0
# Samples: Installed in /home/kezunlin, but missing recommended libraries
Please make sure that
– PATH includes /usr/local/cuda-8.0/bin
– LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin
# reboot to enter GUI mode
sudo reboot
# add cuda bin to env
sudo vim /etc/profile ./.bashrc
export PATH=/usr/local/cuda-8.0/bin:$PATH
source /etc/profile
#export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH
#export LD_LIBRARY_PAT=/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
# ldconfig
sudo /bin/bash -c ‘echo "/usr/local/cuda/lib64" > /etc/ld.so.conf.d/cuda.conf‘
# cat /etc/ld.so.conf.d/x86_64-linux-gnu.conf
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
#
sudo ldconifg
# make sure env is correct
env | grep PATH
# Testing
nvcc -V
cat /proc/driver/nvidia/version
# Testing CUDA
cd NVIDIA_CUDA-8.0_Samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
# Result = PASS
# cuDNN (include+lib64)
# copy include to /usr/local/cuda-8.0/include
# copy lib64 to /usr/local/cuda-8.0/lib64
cd include
sudo cp cudnn.h /usr/local/cuda-8.0/include/
cd lib64
sudo cp * /usr/local/cuda-8.0/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
# locate libcudnn.so
# install opencv 3.4
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
sudo apt-get install cmake-gui
# use cmake-gui to configure
wget https://github.com/opencv/opencv/archive/3.3.0.zip
cd opencv-3.3.0
mkdir build
sudo cmake-gui
# source build--->configure(checkout WITH_CUDA,)--->generate--->exit
cd build
# may take several minutes
sudo make -j8
# install to /usr/local/bin
sudo make install
sudo /bin/bash -c ‘echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf‘
sudo ldconfig
# manage opencv
sudo apt-get -y install checkinstall
cd build
sudo checkinstall
# how to remove opencv install
dpkg -r build
# testing
which opencv_version
# samples
cd samples
cmake .
make
# clone caffe
git clone
git clone https://github.com/BVLC/caffe.git
cd caffe
sudo cp Makefile.config.example Makefile.config
# (1) vim Makefile.config
USE_CUDNN := 1
OPENCV_VERSION := 3
WITH_PYTHON_LAYER := 1
# (2) vim Makefile
在前面
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
增加hdf5的include和lib路径
INCLUDE_DIRS += /usr/include/hdf5/serial
LIBRARY_DIRS += /usr/lib/x86_64-linux-gnu/hdf5/serial
# (3) vim /usr/local/cuda/include/host_config.h
将其中的第115行注释掉:
将
#error-- unsupported GNU version! gcc versions later than 4.9 are not supported!
改为
//#error-- unsupported GNU version! gcc versions later than 4.9 are not supported!
make all -j8
make runtest
make pycaffe
make matcaffe
# distribute
make distribute
caffe tutorials