一、cuda安装
要注意:禁用nouveau驱动,然后到官网下载显卡驱动,安装好,再安装cuda,建议run安装,cuda安装时不用再装显卡驱动
二、cudnn
下载Linux文件,解压,复制到特定文件夹,进行软连接,主要下载的版本文件名
三、opencv
安装opencv3.4.0,其他较低版本可能不支持cuda9.0
解压文件,进入文件目录
mkdir build # 创建编译的文件目录cd buildcmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..make -j4
编译过程需要科学上网,编译完再安装
sudo make install #安装1测试安装是否成功
pkg-config --modversion opencv
四、安装caffe
git clone https://github.com/BVLC/caffe.git
sudo cp Makefile.config.example Makefile.config
修改Makefile.config文件
sudo gedit Makefile.config去掉这些注释
#USE_CUDNN := 1
#OPENCV_VERSION := 3
#WITH_PYTHON_LAYER := 1 INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
修改为:
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)
替换为:
NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)将:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m
改为:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
这部分我安装过程中没修改,因为方向没有下述语句
修改/usr/local/cuda/include/host_config.h(也可能是crt/host_config.h)
#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
编译遇到compute_20的报错,解决方法:修改Makefile.config文件,将CUDA_ARCH中有关compute_20的语句删了
编译成功后测试
sudo make runtest -j8
显示pass则成功这里遇到报错libopencv_core.so.3.4缺失,解决方法:sudo ldconfig /usr/local/lib/x86_64-linux-gnu
然后再安装pycaffe
sudo gedit ~/.bashrc
添加一行
export PYTHONPATH=/home/selfdriving/caffe/python:PYTHONPATH
source ~/.bashrc
进入到caffe目录
sudo make pycaffe -j8
测试
python
import python
遇到报错skimage.io模块,解决:sudo pip install scikit-image。如果matplotlib装不了,就升级pip,再安装