硬件配置说明,本人使用的是Dell T-7910 工作站,配备TitanX双显卡,无VGA接口
首先安装系统
官方下载地址https://www.ubuntu.com/download 下载最新版,下载下来后使用软碟通制作安装镜像
安装完系统,更新系统
sudo apt-get update
sudo apt-get upgrade
激活root用户,并设置密码
sudo su
passwd
安装软件openssh-server,并设置为root账户允许登陆
sudo apt-get install openssh-server
sudo vi /etc/ssh/sshd_config
在PermitRootLogin prohibit-password 加上 #并在下面添加一行
PermitRootLogin yes
安装cmake
sudo apt-get install cmake
移除vim-common,并安装vim
sudo apt-get remove vim-common
sudo apt-get install vim
安装显卡驱动
Ctrl+Alt+F1进入tty命令控制台
sudo service lightdm stop
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get -y install nvidia-375
sudo apt-get -y install mesa-common-dev freeglut3-dev
sudo reboot
安装cuda
在/etc/profile尾部添加如下内容:
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}}
source /etc/profile
sudo ldconfig
安装cudnn
从官网下载cudnn-8.0-linux-x64-v5.1.tgz for CUDA 8.0. 解压到当前目录:
cuda/include/cudnn.h
cuda/lib64/libcudnn.so
cuda/lib64/libcudnn.so.5
cuda/lib64/libcudnn.so.5.1.5
cuda/lib64/libcudnn_static.a
移动到相应的目录
sudo mv include/cudnn.h /usr/local/cuda/include/
sudo mv lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
安装opencv3.2
sudo apt-get -y remove ffmpeg x264 libx264-dev
sudo apt-get -y install libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff5-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg libgtk2.0-dev
sudo apt-get install qt5-default qtcreator
cd opencv-3.2
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
可能会出现的错误
- waring 忽略即可
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
-
ippicv_linux_20151201.tgz
下载缓慢或无法下载导致校验码不一致的错误,ippicv是一个并行计算库,其实可以不用的。如果不想用这个并行计算库,在做Cmake的时候用参数关闭即可,但我还是建议使用这库。
首先,手动下载 ippicv然后,将刚才下载的ippicv文件直接拷贝进入opencv3.2源码的下面这个目录:
opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e
最后一个目录可能不一样,但无所谓,最后再使用命令编译:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j4
sudo make install
- 如果安装的是opencv3.1,则会出现
error: ‘NppiGraphcutState’ has not been declared
error: ‘NppiGraphcutState’ does not name a type
...
解决方法:(由于CUDA版本高于8.0,所以需要做如下修改。在源文件中找到“graphcuts.cpp”)
将:
#include "precomp.hpp"
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
改为:
#include "precomp.hpp"
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)
编译时间比较久,安装成功后配置环境:
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
测试OpenCV安装是否成功:
mkdir DisplayImage
cd DisplayImage
gedit DisplayImage.cpp
添加代码:
#include
#include
using namespace cv;
int main(int argc, char** argv)
{
if(argc!= 2)
{
printf("usage:DisplayImage.out \n");
return -1;
}
Mat image;
image= imread(argv[1], 1);
if(!image.data)
{
printf("Noimage data\n");
return -1;
}
namedWindow("DisplayImage",CV_WINDOW_AUTOSIZE);
imshow("DisplayImage",image);
waitKey(0);
return 0;
}
创建CMake文件:
gedit CMakeLists.txt
添加内容:
cmake_minimum_required(VERSION 2.8)
project(DisplayImage)
find_package(OpenCV REQUIRED)
add_executable(DisplayImage DisplayImage.cpp)
target_link_libraries(DisplayImage ${OpenCV_LIBS})
编译:
cmake .
make
执行:
./DisplayImage lena.jpg
安装MATLAB2016b
- 下载软体链接: https://pan.baidu.com/s/1kVoJJyJ 密码: ypej
- 先挂载第一个镜像
- 切换到用户目录,一定要切换到用户目录,否则安装程序不会执行
cd ~
- 执行安装脚本
sudo sh /media/xxxxx/xxxx/install -请自行修改光盘中install文件的绝对路径
中间过程会提示插入第二个光盘,这时先弹出第一个光盘,再挂载第二个光盘,挂载完毕后,安装程序会自动执行,破解步骤请具体看下载下来的文件
参考
https://github.com/BVLC/caffe/wiki/GeForce-GTX-1080,---CUDA-8.0,---Ubuntu-16.04,---Caffe
https://github.com/BVLC/caffe/wiki/Ubuntu-16.04-or-15.10-Installation-Guide
https://github.com/BVLC/caffe/wiki/OpenCV-3.1-Installation-Guide-on-Ubuntu-16.04
http://gwang-cv.github.io/2016/10/21/Ubuntu16.04+Titan%20X+CUDA8.0+cudnn5/