Ubuntu16.04.3在系统设置里可以直接安装NVIDIA驱动。
System Settings ->Software & Updates->Additonal Drivers->NVIDIA Corporation->Using NVIDIA binary driver ……
选择好之后点击Apply Changes,如果提示需要Secure boot,则按提示设置密码,之后重启时注意选择Secure boot, 并按提示输入密码。重启完成后,驱动便安装完毕。
sudo apt-get install build-essential libgl1-mesa-dev
sudo apt-get install freeglut3-dev
sudo apt-get install libglew-dev libsdl2-dev libsdl2-image-dev libglm-dev libfreetype6-dev
sudo sh cuda_8.0.44_linux.run
sudo vim ~/.bashrc
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}}
:wq
source ~/.bashrc
创建链接文件:
bash ~/Downloads/Anaconda3-5.0.1-Linux-x86_64.sh
sudo apt-get install --assume-yes libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip
sudo apt-get install build-essential cmake git
sudo apt-get install ffmpeg libopencv-dev libgtk-3-dev python-numpy python3-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libv4l-dev libtbb-dev qtbase5-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip
下载opencv并解压,在解压后的文件夹中:
mkdir build #新建一个build文件夹,编译的工程都在这个文件夹里
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -DCUDA_NVCC_FLAGS="-D_FORCE_INLINES" -D BUILD_NEW_PYTHON_SUPPORT=ON -D PYTHON_EXECUTABLE=/path/to/anaconda3/bin/python3 -DPYTHON_INCLUDE_DIR=/path/to/anaconda3/include/python3.6m -DPYTHON_LIBRARY=/path/to/anaconda3/lib/libpython3.6m.so -DPYTHON_NUMPY_INCLUDE_DIRS=/path/to/anaconda3/lib/python3.6/site-packages/numpy/core/include ..
注意把PYTHON_EXECUTABLE,PYTHON_INCLUDE_DIR,PYTHON_LIBRARY,PYTHON_NUMPY_INCLUDE_DIRS中的目录换成自己安装的anaconda的目录。
make -j4
#开始编译
sudo make install
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
sudo apt-get update
sudo apt-get install -y build-essential cmake git pkg-config
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install -y libatlas-base-dev
sudo apt-get install -y libboost-all-dev
sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install -y python-pip
sudo apt-get install -y python-dev
sudo apt-get install -y python-numpy python-scipy
下载caffe
git clone https://github.com/BVLC/caffe.git //从github上git caffe
然后
cd caffe //打开到刚刚git下来的caffe
sudo cp Makefile.config.example Makefile.config //将Makefile.config.example的内容复制到Makefile.config
//因为make指令只能make Makefile.config文件,而Makefile.config.example是caffe给出的makefile例子
sudo vim Makefile.config //打开Makefile.config文件
修改以下内容:
#取消以下注释
USE_CUDNN := 1
OPENCV_VERSION := 3
WITH_PYTHON_LAYER := 1
#将Python有关目录修改为
PYTHON_LIBRARIES := boost_python3 python3.6m #这里需要建立boost_python3链接,方法见参考资料
ANACONDA_HOME := /path/to/anaconda3 #改成自己anaconda的路径
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
$(ANACONDA_HOME)/include/python3.6m \
$(ANACONDA_HOME)/lib/python3.6/site-packages/numpy/core/include
PYTHON_LIB := $(ANACONDA_HOME)/lib
LINKFLAGS := -Wl,-rpath,$(ANACONDA_HOME)/lib
#最后修改INCLUDE_DIRS,LIBRARY_DIRS
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 /usr/lib/x86_64-linux-gnu/hdf5/serial
然后修改makefile文件
NVCCFLAGS +=-ccbin=$(CXX) -Xcompiler-fPIC $(COMMON_FLAGS)
make all -j4
make test -j4
make runtest
make pycaffe
Ubuntu16.04+cuda8.0+opencv3.1+caffe+anaconda安装,双显卡
Ubuntu16.04+cuda8.0+caffe安装教程
注意:安装cuda时,不要修改/etc/profile,所有的环境变量均写在~/.bashrc里,修改前者容易出现系统错误。
libEGL.so.1 不是符号连接
运行cuda sample出现找不到GL*.h的情况,安装opengl可以解决。
ubuntu 16.04 上opengl 的安装以及例子程序编译执行
有关opencv安装的问题
【OpenCV】编译OpenCV时,FFmpeg或ippicv下载不成功的解决方案
opencv/opencv_3rdparty
ubuntu16.04安装opencv3.1.0问题
Ubuntu下编译caffe
error while loading shared libraries: xxx.so.x" 错误的原因和解决办法
出现boost_python相关问题时参考,建立libboost_python3.so时,在/usr/lib/x86_64-linux-gnu目录下即可:
在 python3.5 下使用 Caffe Using Caffe with Python3.5
出现undefined reference to `inflateValidate@ZLIB_1.2.9'时参考:
Caffe 编译错误记录
出现Warning! ***HDF5 library version mismatched error***可以参考
在Matlab中使用Caffe出现HDF5 library version mismatched error的解决办法
在https://support.hdfgroup.org/ftp/HDF5/releases/找到适合的HDF5版本下载安装。
建议下载安装错误提示中header的版本,并且安装到提示中General Information 下 Installation point 的位置。