在这个版本安装之前,要先装好opencv,openmpi等。

下载地址:https://github.com/yjxiong/caffe.git

我的opencv是2.4.12版本

编译是用了:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DCUDA_CUDA_LIBRARY=/usr/local/cuda/lib64/stubs/libcuda.so -D CUDA_ARCH_BIN=5.2 -D CUDA_ARCH_PTX="" -D WITH_CUDA=ON -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 -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D WITH_NVCUVID:BOOL="1" .

caffe的编译是:

cmake -DUSE_MPI=ON -DMPI_CXX_COMPILER=/data/dog123/openmpi/bin/mpicxx ..

----------------------------------------------------------------------------------------

(还是写完整些比较好)

到你要存放是目录下,使用命名(git clone https://github.com/yjxiong/caffe.git)下载软件包。

将Makefile.config.example 另存一份名为Makefile.config

修改Makefile.config,最终的样子如下:

## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome! # cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := 1 # CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1 # To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++ # CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr # CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 lines for compatibility.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_50,code=compute_50 # BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := atlas
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
# BLAS_INCLUDE := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas # Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell brew --prefix openblas)/lib # This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
MATLAB_DIR := /usr/local/MATLAB/R2014a
# MATLAB_DIR := /Applications/MATLAB_R2012b.app # NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
# ANACONDA_HOME := $(HOME)/anaconda
# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
# $(ANACONDA_HOME)/include/python2.7 \
# $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \ # We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/lib
# PYTHON_LIB := $(ANACONDA_HOME)/lib # Homebrew installs numpy in a non standard path (keg only)
# PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
# PYTHON_LIB += $(shell brew --prefix numpy)/lib # Uncomment to support layers written in Python (will link against Python libs)
WITH_PYTHON_LAYER := 1 # Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib # Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1 BUILD_DIR := build
DISTRIBUTE_DIR := distribute # Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1 # The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0 # enable pretty build (comment to see full commands)
Q ?= @

  (红色部分是要核对下的)

然后在caffe目录下执行如下命令:

创建build文件夹并进入:

mkdir build

cd build

编译:

cmake -DUSE_MPI=ON -DMPI_CXX_COMPILER=/data/dog123/openmpi/bin/mpicxx ..

编译的结果是:

og@asus:/data/dog123/caffe/build$ cmake -DUSE_MPI=ON -DMPI_CXX_COMPILER=/data/dog123/openmpi/bin/mpicxx ..
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.64.0
-- Found the following Boost libraries:
-- system
-- thread
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found GFlags: /usr/include
-- Found gflags (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libgflags.so)
-- Found Glog: /usr/include
-- Found glog (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libglog.so)
-- Found PROTOBUF: /usr/lib/x86_64-linux-gnu/libprotobuf.so
-- Found PROTOBUF Compiler: /usr/bin/protoc
-- Found HDF5: /usr/lib/x86_64-linux-gnu/libhdf5_hl.so;/usr/lib/x86_64-linux-gnu/libhdf5.so
-- Found LMDB: /usr/include
-- Found lmdb (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/liblmdb.so)
-- Found LevelDB: /usr/include
-- Found LevelDB (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libleveldb.so)
-- Found Snappy: /usr/include
-- Found Snappy (include: /usr/include, library: /usr/lib/libsnappy.so)
-- CUDA detected: 8.0
-- Found cuDNN (include: /usr/local/cuda/include, library: /usr/local/cuda/lib64/libcudnn.so)
-- Added CUDA NVCC flags for: sm_52
-- OpenCV found (/usr/local/share/OpenCV)
-- Found Atlas: /usr/include
-- Found Atlas (include: /usr/include, library: /usr/lib/libatlas.so)
-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.6", minimum required is "2.7")
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so (found suitable version "2.7.6", minimum required is "2.7")
-- Found NumPy: /usr/local/lib/python2.7/dist-packages/numpy/core/include (found suitable version "1.12.1", minimum required is "1.7.1")
-- NumPy ver. 1.12.1 found (include: /usr/local/lib/python2.7/dist-packages/numpy/core/include)
-- Boost version: 1.64.0
-- Found the following Boost libraries:
-- python
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.6")
-- Found MPI_C: /data/dog123/openmpi/lib/libmpi.so
-- Found MPI_CXX: /data/dog123/openmpi/lib/libmpi.so
-- Detected Doxygen OUTPUT_DIRECTORY: ./doxygen/
-- Found Git: /usr/bin/git (found version "1.9.1")
--
-- ******************* Caffe Configuration Summary *******************
-- General:
-- Version : <TODO> (Caffe doesn't declare its version in headers)
-- Git : v0.9999-1628-gfd7458e
-- System : Linux
-- C++ compiler : /usr/bin/c++
-- Release CXX flags : -O3 -DNDEBUG -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
-- Debug CXX flags : -g -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
-- Build type : Release
--
-- BUILD_SHARED_LIBS : ON
-- BUILD_python : ON
-- BUILD_matlab : OFF
-- BUILD_docs : ON
-- CPU_ONLY : OFF
--
-- Dependencies:
-- BLAS : Yes (Atlas)
-- Boost : Yes (ver. 1.64)
-- glog : Yes
-- gflags : Yes
-- protobuf : Yes (ver. 2.5.0)
-- lmdb : Yes (ver. 0.9.10)
-- Snappy : Yes (ver. 1.1.0)
-- LevelDB : Yes (ver. 1.15)
-- OpenCV : Yes (ver. 2.4.12)
-- CUDA : Yes (ver. 8.0)
--
-- NVIDIA CUDA:
-- Target GPU(s) : Auto
-- GPU arch(s) : sm_52
-- cuDNN : Yes
--
-- Python:
-- Interpreter : /usr/bin/python2.7 (ver. 2.7.6)
-- Libraries : /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.6)
-- NumPy : /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.12.1)
--
-- Documentaion:
-- Doxygen : /usr/bin/doxygen (1.8.6)
-- config_file : /data/dog123/caffe/.Doxyfile
--
-- Install:
-- Install path : /data/dog123/caffe/build/install
--
-- Configuring done
-- Generating done
-- Build files have been written to: /data/dog123/caffe/build
dog@asus:/data/dog123/caffe/build$

  

安装:

make all -j8 (j8 是为了加快安装速度,可以去掉)

sudo make install (注意 sudo权限)

最后就是测试:

make runtest (我这里有2个test不过,但是我还没找到原因(因为没看到错误在哪,都在输出的前面覆盖了),因为装好多遍都有2个不过,所以先将就。也就是这样,感觉自己跟一个炸弹绑在一起,我不知道它什么时候会不爽然后炸我1炸,哈哈哈哈哈)

最后就是python和matlab接口。

这2者都是caffe装之前就装好了的。

编译python接口:

添加环境变量:

vi ~/.bashrc

写入:

export PYTHONPATH=/your/path/caffe/python:$PYTHONPATH

保存,退出,执行sourc使文件生效:
source ~/.bashrc

接着在caffe目录下:

sudo make pycaffe

如果报错,点这里。一般再执行一遍上面命令即可。

最后就是:输入命令:

python

import caffe

没报错就是成功了。

编译matlab接口:

同理,在~/.bashrc中添加环境变量:

export PATH=$PATH:/usr/local/MATLAB/R2014a/bin

然后在caffe目录下执行:

sudo make matcaffe

没报错的话,就用下面命令测试下:

make matcaffe

如果报错,就点这里

嗯,就这些。

编译gpu集群版caffe的更多相关文章

  1. Redis单机版以及集群版的安装搭建以及使用

    1,redis单机版 1.1   安装redis n  版本说明 本教程使用redis3.0版本.3.0版本主要增加了redis集群功能. 安装的前提条件: 需要安装gcc:yum install g ...

  2. 深度学习GPU集群管理软件 OpenPAI 简介

    OpenPAI:大规模人工智能集群管理平台 2018年5月22日,在微软举办的“新一代人工智能开放科研教育平台暨中国高校人工智能科研教育高峰论坛”上,微软亚洲研究院宣布,携手北京大学.中国科学技术大学 ...

  3. 快速搭建redis单机版和redis集群版

    单机版 第一步:需要安装redis所需的C语言环境,若虚拟机联网,则执行 yum install gcc-c++ 第二步:redis的源码包上传到linux系统 第三步:解压缩redis   tar ...

  4. redis单机版和集群版搭建笔记-简略版

    搭建单机版: 解压 tar -zxf redis-3.0.0.tar.gz 编译 cd redis-3.0.0 安装 make install prefix=/usr/local/redis-inst ...

  5. Redis单机版和集群版的安装和部署

    1.单机版的安装 本次使用redis3.0版本.3.0版本主要增加了redis集群功能. 安装的前提条件: 需要安装gcc:yum install gcc-c++ 1.1 安装redis 1.下载re ...

  6. 制作docker-jdk7-zookeeper镜像(非集群版)

    ## 准备工作 用到的工具, Xshell5, Xftp5, jdk-7u79-linux-x64.tar.gz, zookeeper-3.4.9.tar.gz, docker.io/centos:l ...

  7. shiro的单机版 和 集群版

    在我们的开发当中  我们一般权限都是个 比较繁琐 但又必不可少的 一部分 [不管我们的 数据库设计  还是我们采用何种技术 我们的权限库表 大多都是大同小异  业务逻辑也是如此] 在我们不使用任何框架 ...

  8. jedis集群版应用

    1.pom文件添加依赖: 2.创建配置文件 <!-- jedis集群版配置(JedisCluster通过构造传参(2个参数)) --> <bean id="redisCli ...

  9. HBase单机和集群版部署

    1. HBase安装部署 HBase有两种部署模式:单机版模式和集群版模式.无论哪种模式,都需要配置HBase conf目录下的文件.至少,必须在conf/hbase-env.sh文件中添加JAVA_ ...

随机推荐

  1. Select 多个表并且相关联转置

    已知一个表的结构为: ------------------- 姓名 科目 成绩 张三 语文 20 张三 数学 30 张三 英语 50 李四 语文 70 李四 数学 60 李四 英语 90   怎样通过 ...

  2. Oracle——学习之路(视图——虚拟表)

    语法: create [or replace] view 视图名  as  查询相关语句                                 ps: or replace 表示新视图可以覆 ...

  3. FTP文件上传下载

    使用Apache Commons Net来实现FTP服务器文件的上传 与 下载 maven配置Jar <!-- https://mvnrepository.com/artifact/common ...

  4. Python面试常考点之深入浅出链表操作

    Python面试常考点之深入浅出链表操作 在Python开发的面试中,我们经常会遇到关于链表操作的问题.链表作为一个非常经典的无序列表结构,也是一个开发工程师必须掌握的数据结构之一.在本文中,我将针对 ...

  5. C#将字符串格式化为Json

    private string ConvertStringToJson(string str)        {            //格式化json字符串            JsonSeria ...

  6. MFC + XToolKit的使用 ( 亲自实践 )

    1. 变量声明: 在Dlg.h    的public下 CXTPButton m_Button2; 2. 变量交换并设置按钮风格: Dlg.cpp下 void CXT_VS2010Dlg::DoDat ...

  7. JCA-Java加密框架

    转自:https://www.jianshu.com/p/a8194c237363 JCA是平台的一个主要部分,包含一个“Provider”体系结构和一组用于数字签名,消息摘要(哈希),证书和证书验证 ...

  8. ubuntu更改apt源为阿里云源

    https://blog.csdn.net/zhangjiahao14/article/details/80554616 https://yq.aliyun.com/articles/704603 h ...

  9. 图片上传(3)(组件 -- 图片大小宽高限制)base64图片宽高读取

    1.上传组件(可上传多个文件) <template> <div class="attachmentN"> <span class="btnS ...

  10. 第五篇.python进阶

    目录 第五篇.python进阶 1. 异常处理 2. 数字类型内置方法 2.定义: 3.常用操作+内置方法: 4.存一个值or多个值: 5.有序or无序: 6.可变和不可变 1.用途: 2.定义: 3 ...