本版本用的是Ubuntu14.04,cuda-7.5,opencv-3.10
1. 安装NVIDIA
- 禁止Ubuntu自带的驱动,具体方法:
sudo vim /etc/modprobe.d/nvidia-graphics-drivers.conf
添加blacklist nouveau
sudo vim /etc/default/grub
添加rdblacklist=nouveau nouveau.modeset=0
- 如果还是禁止不了,可以移除此文件(先备份),然后再重新加载一下,步骤如下:
mv /lib/modules/3.0.0-12-generic/kernel/drivers/gpu/drm/nouveau/nouveau.ko /lib/modules/3.0.0-12-generic/kernel/drivers/gpu/drm/nouveau/nouveau.ko.org
update-initamfs -u
- 重启电脑
Ctrl+Shift+tty1
进入终端,关闭图形界面,sudo /etc/init.d/lightdm stop
./NVIDIA-Linux-x86_64-370.28.run
,可能要先添加执行权限
2. 安装CUDA
- 执行.run文件,
./NVIDIA-Linux-x86_64-367.44.run
,中间不需要重新安装驱动 - 添加路径,注意书写格式
方法一:
export CUDA_HOME=/usr/local/cuda-7.5
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64
PATH=${CUDA_HOME}/bin:${PATH}
export PATH
方法二:
sudo vim /etc/profile
export PATH=/usr/local/cuda-7.5/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:$LD_LIBRARY_PATH
3. 安装依赖项
sudo apt-get install build-essential # basic requirement
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler #required by caffe
sudo apt-get install python-pip
sudo apt-get install python-numpy
sudo apt-get install python-scipy
sudo pip install Cython
sudo apt-get install python-protobuf
sudo apt-get install python-matplotlib
sudo pip install scikit-image
sudo pip install pyyaml
sudo apt-get install python-opencv
sudo pip insatll easydict
4. 安装OPENCV
解压opencv-3.1.0.zip
cd opencv-3.1.0
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j8
sudo make install -j8
5. 安装CAFFE
- 安装Python依赖库,可通过如下命令(第三步骤中如果执行了,可以不用此步骤):
for req in $(cat requirements.txt); do pip install $req; done
- 编译caffe
cd caffe-master
cp Makefile.config.example Makefile.config
vim Makefile.config (去掉`OPENCV_VESION=3`和`WITH_PYTHON_LAYER := 1`前的注释)
make all -j8
make test -j8
make runtest -j8
make pycaffe