因操作失误,误卸开发机NVIDIA显卡驱动,先更新操作日志如下:

1.卸载系统里的Nvidia残余

sudo apt-get purge nvidia*

2.把显卡驱动加入PPA

sudo add-apt-repository ppa:graphics-drivers
sudo apt-get update

3.查找显卡驱动最新的版本号

sudo apt-cache search nvidia

Ubuntu 16.04 安装opencv3.4.5/cuda/caffe并使用jni笔记

4.采用apt-get命令在终端安装:

sudo apt-get install nvidia-415 nvidia-settings nvidia-prime

5.重启系统并验证

lsmod | grep nvidia
lsmod | grep nouveau

Ubuntu 16.04 安装opencv3.4.5/cuda/caffe并使用jni笔记

2>cuda安装

  显卡重装后,cuda也需重装

sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda-9-0 cuda-libraries-9-0

3>opencv安装

wget https://github.com/opencv/opencv/archive/3.4.5.zip
unzip opencv-3.4.5.zip
cd opencv-3.4.5
mkdir build && cd build
cmake ..
make -j8
sudo make install

对应环境变量配置:

sudo vi /etc/profile
# 新增 opencv动态库所在路径
export LD_LIBRARY_PATH=/usr/local/share/OpenCV/java:$LD_LIBRARY_PATH

4>caffe安装

git clone https://github.com/BVLC/caffe.git
cp Makefile.config.example Makefile.config


gedit Makefile.config
# 此处选择是否应用cudnn,opencv,python等
  opencv需指定版本
    将
    #OPENCV_VERSION := 3 
    修改为: 
    OPENCV_VERSION := 3
  其余参考需求

# 编译
make all -j8
make distribute
# 运行测试
sudo make runtest -j8

5>JNI使用记录

修改Makefile 依次指定opencv、caffe、java - jni 等路径

修改 config.xml 完善相关配置