博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
caffe(master分支)Makefile.config分析
阅读量:2497 次
发布时间:2019-05-11

本文共 6607 字,大约阅读时间需要 22 分钟。

本人编译如下版本caffe后,记录下需要注意(修改)Makefile.config的选项

系统:ubuntu 14.04
CUDA:CUDA7.5
Python:Python2.7
仅支持CPU
cat 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).# 是否使用cudnn,默认不使用# USE_CUDNN := 1# CPU-only switch (uncomment to build without GPU support).# 是否仅支持cup,注释后会编译gpu部分,因人而异,我自己学习支持cpu就好CPU_ONLY := 1# uncomment to disable IO dependencies and corresponding data layers# 选择支持库,可以先按默认都不选,包括下面对opencv,leveldb,lmdb库的选项都可以注释# USE_OPENCV := 0# USE_LEVELDB := 0# USE_LMDB := 0# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)#       You should not set this flag if you will be reading LMDBs with any#       possibility of simultaneous read and write# ALLOW_LMDB_NOLOCK := 1# Uncomment if you're using OpenCV 3# OPENCV_VERSION := 3# 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++# 可选g++版本,如果编译报错因g++库问题,可以尝试换个g++版本,比如曾经报错然后试过g++-5.x,g++-4.x等CUSTOM_CXX := g++# CUDA directory contains bin/ and lib/ directories that we need.# cuda安装命令,其实使用NVADIA gpu才会用到cuda,但是可以使用sudo apt-get install nvidia-cuda-toolkit# 安装后,which cuda,添加路径编译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 through *_61 lines for compatibility.# For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.# For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility.# 这个根据cuda版本不同选择注释,看上面注释,我是cuda7.5,所以注释*_60等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_52,code=sm_52 \#                -gencode arch=compute_60,code=sm_60 \#                -gencode arch=compute_61,code=sm_61 \#                -gencode arch=compute_61,code=compute_61# BLAS choice:# atlas for ATLAS (default)# mkl for MKL# open for OpenBlas# BLAS库,安装atlas就使用这个吧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_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库路径,可通过ubuntu的python库在 /usr/lib/x86-xxxx(忘了全拼,自己按tab补全吧)/python2.7/里面PYTHON_LIBRARIES := boost_python-py27 python2.7   # Python头文件路径,根据实际情况填写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是一个封装的环境,里面有编译caffe所需的库,如果通过anaconda安装caffe时候打开配置,并# 注释上面python2.7的配置,修改成anaconda的环境路径,这里我不需要# ANACONDA_HOME := $(HOME)/anaconda# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \                # $(ANACONDA_HOME)/include/python2.7 \                # $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include# Uncomment to use Python 3 (default is Python 2)# python3的路径配置,我是2,所以不需要,根据实际情况配置# PYTHON_LIBRARIES := boost_python3 python3.5m# PYTHON_INCLUDE := /usr/include/python3.5m \#                 /usr/lib/python3.5/dist-packages/numpy/core/include# We need to be able to find libpythonX.X.so or .dylib.# 按默认的,如果使用anaconda,则换成下面的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)# 如果想要caffe支持python接口,则这个打开,我会编译make && make pycaffe,所以需要,如果不编译,则# 使用C++接口WITH_PYTHON_LAYER := 1# Whatever else you find you need goes here.# 库的配置,这里添加hdf的库,我环境会编译报错:can not find hdf5.hINCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/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# NCCL acceleration switch (uncomment to build with NCCL)# https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0)# gpu相关,跟我没关系# USE_NCCL := 1# 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.)# opencv支持,暂时不需要# USE_PKG_CONFIG := 1# N.B. both build and distribute dirs are cleared on `make clean`BUILD_DIR := buildDISTRIBUTE_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 ?= @

另外补充intel分支的Makefile.config增加项说明:

# 这两项是intel对使用mkl2017和mkldnn的优化,选择成功后(可以看下/src/caffe/net.cpp中部分代码),# caffe.Net解析网络时会对Scale层进行融合,认为是Drop层,计算时忽略。# USE_MKL2017_AS_DEFAULT_ENGINE := 1# or put this at the top your train_val.protoxt or solver.prototxt file:# engine: "MKL2017"# or use this option with caffe tool:# -engine "MKL2017"USE_MKLDNN_AS_DEFAULT_ENGINE := 1# Put this at the top your train_val.protoxt or solver.prototxt file:# engine: "MKLDNN"# or use this option with caffe tool:# -engine "MKLDNN"# caffe.Net解析网络时会对Bn层进行融合,认为是Drop层,计算时忽略,下面也是相关算法优化# Use remove batch norm optimization to boost inferenceDISABLE_BN_FOLDING := 0# Use Conv + Relu fusion to boost inferenceDISABLE_CONV_RELU_FUSION:= 0# Use Bn + ReLU fusion to boost inferenceDISABLE_BN_RELU_FUSION := 0# Use Conv + Eltwise + Relu layer fusion to boost inference.DISABLE_CONV_SUM_FUSION := 0# Use sparse to boost inference.DISABLE_SPARSE := 0

这里写图片描述

你可能感兴趣的文章
推荐-zabbix原理篇
查看>>
OpenGL学习笔记之配置OpenGL
查看>>
Node.js v0.10.31API手冊-事件
查看>>
uva--165(邮资问题,dp)
查看>>
C random C ++rand函数应用
查看>>
多进程实现并发服务器(TCP)
查看>>
一个问题一份收获——请求回来的数据应该怎么处理
查看>>
python爬虫
查看>>
ABE是什么
查看>>
Windows XP Embedded 官方下载地址
查看>>
怎样获得某个进程的内存基地址?
查看>>
一个flume agent异常的解决过程记录
查看>>
Python OOP总结
查看>>
如何将uClinux固化到Flash内
查看>>
Daily Scrum M1 10-11 [含Preview版截图]
查看>>
nodejs+express开发blog(1)
查看>>
MySQL存储引擎
查看>>
给你一个笑脸
查看>>
前端练手项目
查看>>
JS 用 prototype 扩展实现string过滤空格
查看>>