系统类配置(三)【ubuntu14.04或者ubuntu16.04 配置caffe】

简介: 系统类配置(三)【ubuntu14.04或者ubuntu16.04 配置caffe】

1.安装了cuda和cudnn,参考链接opencv

ubuntu14.04与ubuntu16.04两者的安装仅有小部分区别。

安装基本库:

1. sudo apt-get install libatlas-base-dev
2. sudo apt-get install libgoogle-glog-dev
3. sudo apt-get install -y build-essential cmake git pkg-config
4. sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler
5. sudo apt-get install -y --no-install-recommends libboost-all-dev
6. sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev

2. 获取caffe:

1. cd
2. git clone https://github.com/BVLC/caffe.git

3.安装需要的依赖包:

1. cd caffe/python
2. sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy

安装requirement里面的包

1. sudo su
2. for req in $(cat requirements.txt); do pip install $req; done

4.修改配置文件

1. cd ~/caffe
2. cp Makefile.config.example Makefile.config
3. gedit Makefile.config
  1. 使用cuDNN # USE_CUDNN := 1 ,这里去掉#,取消注释
  2. 使用opencv3,#OPENCV_VERSION := 0 修改为: OPENCV_VERSION := 3
  3. 若要使用python来编写layer,则 #WITH_PYTHON_LAYER := 1,前面的#号去掉。
  4. 将# Whatever else you find you need goes here. 下面的
1. 1 INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
2. 2 LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

修改为

1. INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
2. LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial

如果你的不是cuda8.0还需要将compute那一部分改一改:文件中的要求改就好了。

5.修改makefile文件:

打开makefile文件,做如下修改:

NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)

替换为:

NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)

如果你是ubuntu16.04那么你需要修改以下路径,如果是14.04则不需要:

LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5

修改为:

LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial

LIBRARIES += boost_thread stdc++修改为:

LIBRARIES += boost_thread stdc++ boost_regex

6.编辑/usr/local/cuda/include/host_config.h,将其中的第115行注释掉:

#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!

7.编译:

1. make all –j8
2. make test –j8
3. make runtest –j8

8.编译pycaffe

在caffe根目录的python文件夹下,有一个requirements.txt的清单文件,上面列出了需要的依赖库,按照这个清单安装就可以了。

在安装scipy库的时候,需要fortran编译器(gfortran),如果没有这个编译器就会报错,因此,我们可以先安装一下。

首先回到caffe的根目录,然后执行安装代码:

1. cd ~/caffe
2. sudo apt-get install gfortran
3. cd ./python
4. sudo su
5. for req in $(cat requirements.txt); do pip install $req; done

安装完成以后,再次回到caffe根目录我们可以执行:

1. cd ..
2. cd caffe
3. sudo pip install -r python/requirements.txt

就会看到,安装成功的,都会显示Requirement already satisfied, 没有安装成功的,会继续安装。

编译python接口:

make pycaffe  -j8

配置环境变量,以便python调用:

sudo gedit ~/.bashrc

export PYTHONPATH=/home/caffe/python:$PYTHONPATH添加到文件中

source ~/.bashrc

之后进入caffe/python目录下:

报错解决:

1.make: protoc:命令未找到

sudo apt-get install protobuf-c-compiler protobuf-compiler

2.报错:./include/caffe/util/db_leveldb.hpp:7:24: fatal error: leveldb/db.h: 没有那个文件或目录

sudo apt-get install libleveldb-dev

3.报错:./include/caffe/util/db_lmdb.hpp:8:18: fatal error: lmdb.h: 没有那个文件或目录#include "lmdb.h"

sudo apt install liblmdb-dev

4.报错:/usr/bin/ld: cannot find -hdf5_serial_hl

之前报这个错,最后发现ubuntu14.04不用修改下面这句

LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5

参考:

https://blog.csdn.net/luoshenzhisi/article/details/44780389

https://blog.csdn.net/weixin_42652125/article/details/81202540

https://www.cnblogs.com/go-better/p/7161006.html

https://github.com/BVLC/caffe/wiki/Ubuntu-16.04-or-15.10-Installation-Guide

我的微信公众号名称:深度学习与先进智能决策

微信公众号ID:MultiAgent1024

公众号介绍:主要研究强化学习、计算机视觉、深度学习、机器学习等相关内容,分享学习过程中的学习笔记和心得!期待您的关注,欢迎一起学习交流进步!

相关文章
|
6天前
|
存储 Prometheus 监控
在Ubuntu系统上安装与配置Prometheus的步骤
通过以上步骤,您应该已经成功在Ubuntu系统上安装并配置了Prometheus。您现在可以开始使用Prometheus收集和分析您的系统和应用程序的指标数据了。
17 1
|
6天前
|
监控 Ubuntu API
Python脚本监控Ubuntu系统进程内存的实现方式
通过这种方法,我们可以很容易地监控Ubuntu系统中进程的内存使用情况,对于性能分析和资源管理具有很大的帮助。这只是 `psutil`库功能的冰山一角,`psutil`还能够提供更多关于系统和进程的详细信息,强烈推荐进一步探索这个强大的库。
18 1
|
17天前
|
Ubuntu Oracle 关系型数据库
Oracle VM VirtualBox之Ubuntu 22.04LTS双网卡网络模式配置
这篇文章是关于如何在Oracle VM VirtualBox中配置Ubuntu 22.04LTS虚拟机双网卡网络模式的详细指南,包括VirtualBox网络概述、双网卡网络模式的配置步骤以及Ubuntu系统网络配置。
44 3
|
17天前
|
Ubuntu 开发工具 虚拟化
MacOS系统基于VMware Fusion配置Ubuntu 22.04LTS环境
这篇文章介绍了如何在MacOS系统上使用VMware Fusion虚拟化软件配置Ubuntu 22.04 LTS环境,包括自定义VMware Fusion网段、Ubuntu系统安装、配置root用户登录、设置静态IP地址、修改默认网卡名称、配置PS1变量、设置登录界面为字符界面、修改软件源和进行vim基础优化等步骤。
63 2
|
19天前
|
Ubuntu
树莓派 —— ubuntu上通过netplan配置网络
树莓派 —— ubuntu上通过netplan配置网络
|
16天前
|
存储 Ubuntu 网络安全
在Ubuntu系统下通过Caddy实现LXD的安装与部署
通过上述步骤,您可以在Ubuntu系统下通过Caddy实现LXD的安装与部署。这种方法不仅可以提高容器管理的效率,还可以借助Caddy的自动SSL管理功能提升安全性。
12 0
|
Web App开发 Ubuntu Linux
|
30天前
|
Ubuntu Shell 网络安全
安装了ubuntu虚拟机后发现shell无法连接 ubuntu开启ssh连接
【8月更文挑战第23天】安装了ubuntu虚拟机后发现shell无法连接
87 6
|
19天前
|
Ubuntu Linux Docker
Ubuntu 18.04 安装Docker实战案例
关于如何在Ubuntu 18.04系统上安装Docker的实战案例,包括安装步骤、配置镜像加速以及下载和运行Docker镜像的过程。
105 3
Ubuntu 18.04 安装Docker实战案例
|
19天前
|
Ubuntu 网络安全 开发工具
Ubuntu19.04的安装过程详解以及操作系统初始化配置
本文详细介绍了Ubuntu 19.04操作系统的安装过程、初始化配置、网络设置、软件源配置、SSH远程登录以及终端显示设置。
44 1
Ubuntu19.04的安装过程详解以及操作系统初始化配置