Ubuntu1404快速配置caffe

时间:2022-10-25 18:18:40

安装了N次Caffe,每次都会遇到新的Error。每次的速度比上一次的快,从第一次的一个星期,慢慢地变成1天,慢慢地变成3个小时。下面开始快速的配置Caffe吧!
主要参考了欧新宇大神的博客:http://ouxinyu.github.io/Blogs/20151108001.html
1:安装系统
网上教程很多,大家参考一下
2:安装cuda
官方下载地址:https://developer.nvidia.com/cuda-toolkit

$ sudo dpkg -i cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb
$ sudo apt-get update
$ sudo apt-get install -y cuda

注意:下载的cuda的版本号不同,或者系统不同需要修改一下
3:安装cudnn(cudnn-7.5-linux-x64-v5.1)
官方下载地址:https://developer.nvidia.com/cudnn

$ tar zxvf cudnn-7.5-linux-x64-v5.1.tgz
$ cd cuda
$ sudo cp include/cudnn.h /usr/local/include
$ sudo cp lib64/libcudnn.* /usr/local/lib
$ sudo ln -sf /usr/local/lib/libcudnn.so.5.1.3 /usr/local/lib/libcudnn.so.5
$ sudo ln -sf /usr/local/lib/libcudnn.so.5 /usr/local/lib/libcudnn.so
$ sudo ldconfig -v

3:安装opencv(详细步骤)
安装opencv分成四步完成:
1:下载需要的文件安装依赖项
Ubuntu1404快速配置caffe

sh dependencies.sh

#!/bin/bash
#edited by xuezhi zhang.
echo "--- Removing any pre-installed ffmpeg and x264"
sudo apt-get -qq remove ffmpeg x264 libx264-dev
#function install_dependency {
# echo "--- Installing dependency: $1"
# sudo apt-get -y install $1
#}
echo "Installing dependency"
sudo apt-get -y install libopencv-dev
sudo apt-get -y install build-essential
# conflict
#sudo apt-get -y install checkinstall
sudo apt-get -y install cmake
sudo apt-get -y install pkg-config
sudo apt-get -y install yasm
sudo apt-get -y install libjasper-dev
sudo apt-get -y install libavcodec-dev
sudo apt-get -y install libavformat-dev
sudo apt-get -y install libswscale-dev
sudo apt-get -y install libdc1394-22-dev
sudo apt-get -y install libxine-dev
#echo "===================================================="
# conflict with libxine-dev
#sudo apt-get -y install libxine2-dev
sudo apt-get -y install libgstreamer0.10-dev
sudo apt-get -y install libgstreamer-plugins-base0.10-dev
sudo apt-get -y install libv4l-dev
sudo apt-get -y install python-dev
sudo apt-get -y install python-numpy
sudo apt-get -y install python-scipy
sudo apt-get -y install python-sphinx
sudo apt-get -y install libtbb-dev
sudo apt-get -y install libqt4-dev
sudo apt-get -y install libgtk2.0-dev
sudo apt-get -y install libfaac-dev
sudo apt-get -y install libmp3lame-dev
sudo apt-get -y install libopencore-amrnb-dev
sudo apt-get -y install libopencore-amrwb-dev
sudo apt-get -y install libtheora-dev
sudo apt-get -y install libvorbis-dev
sudo apt-get -y install libxvidcore-dev
sudo apt-get -y install x264
sudo apt-get -y install v4l-utils
sudo apt-get -y install unzip
sudo apt-get -y install libgtk2.0-0
sudo apt-get -y install libjpeg-dev
sudo apt-get -y install libjpeg62
# conflict
#sudo apt-get -y install libjpeg62-dev
sudo apt-get -y install libtiff4-dev
sudo apt-get -y install libtiff5-dev
sudo apt-get -y install qt5-default
echo "===================================================="
echo "^^^^^^^^^^^^^^^^^^^^^^Over^^^^^^^^^^^^^^^^^^^^^^^^^^"
echo "===================================================="

#install_dependency ffmpeg
#install fail, run file of ffmpeg_install to install it
2:安装ffmpeg-2.8.tar

sh mmfpeg_install.sh

echo "===================================================="
echo "Installing dependency"
echo "===================================================="
sudo apt-get install -y libx264-dev libxext-dev libxfixes-dev

echo "===================================================="
echo "--- Configure mmfpeg-2.8"
echo "===================================================="
tar -xf ffmpeg-2.8.tar.bz2
cd ffmpeg-2.8
./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-pthreads --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libx264 --enable-libxvid --enable-x11grab --enable-libvorbis

echo "===================================================="
echo "--- Making mmfpeg-2.8"
echo "===================================================="
make -j

echo "===================================================="
echo "--- Installing mmfpeg-2.8"
echo "===================================================="
make install
cd ..
3:安装v4l-utils-0.8.5.tar
sh v4l_install.sh
echo "===================================================="
echo "---Installing v4l---"
echo "===================================================="
#wget http://www.linuxtv.org/downloads/v4l-utils/v4l-utils-0.8.5.tar.bz2
tar -xvf v4l-utils-0.8.5.tar.bz2
cd v4l-utils-0.8.5
make -j
sudo make install
cd ..
4:安装Opencv
unzip opencv-3.0.0.zip
cd opencv-3.0.0
mkdir build
cd build
cmake -D 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 INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make -j4
sudo make install
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
echo "OpenCV 3.0.0 ready to be used"

以上文件都可以保存为.sh文件,运行即可
在安装opencv的过程是长遇到的错误为:无法下载ippicv_linux_20141027.tgz
解决方案:把下载好的文件拷贝到制定的文件夹下即可

4:配置Caffe
其他的步骤可以参考其他的博客。流程都是一样的。
在make runtest -j16是遇到无法访问CUDA的cudasucess(77vs0)暂无解决方案。我重启了一下就可以了,不知道为什么!

安装过程中主要是opencv的安装比较繁琐一下,其他的安装都是很简单的,网上的教程也很详细,,安装过程中一定要仔细核对自己下载的cuda和cudnn是不是和命令行的名称一致,否则无法安装成功,或者在make all -j16 是出现cuda的报错,或者无法使用Cudnn加速!

相关文章