Ubuntu下Caffe框架安装(仅仅Caffe框架安装)

Posted 逐风少年

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu下Caffe框架安装(仅仅Caffe框架安装)相关的知识,希望对你有一定的参考价值。

步骤一、 从github上下载(克隆)安装包

1.1 在你要安装的路径下 clone

此处我直接安装到home目录,执行:

1  ~$ cd ~ 2 :~$ git clone https://github.com/BVLC/caffe.git #开始clone 
2  ~$ git clone https://github.com/BVLC/caffe.git

等待下载结束,下载结束后在你的home路径下会存在,caffe文件夹。接下来进入caffe并开始配置caffe,配置如下

1 sudo cp Makefile.config.example Makefile.config
2 sudo gedit Makefile.config #或者sudo vim Makefile.config

1.2 接下来我们可以开始修改caffe的Makefile.config文件

为编译caffe做准备。为了方便大家配置,我直接贴下我的Makefile.config配置文件,并将在我系统环境(安装过了cuda、cudnn、opencv3、anaconda2)下配置,改动处用蓝色凸显出来

  1 ## Refer to http://caffe.berkeleyvision.org/installation.html
  2 # Contributions simplifying and improving our build system are welcome!
  3 
  4 # cuDNN acceleration switch (uncomment to build with cuDNN).
  5 #----caffe --
  6  USE_CUDNN := 1
  7 
  8 # CPU-only switch (uncomment to build without GPU support).
  9 # CPU_ONLY := 1
 10 
 11 # uncomment to disable IO dependencies and corresponding data layers
 12 # USE_OPENCV := 0
 13 # USE_LEVELDB := 0
 14 # USE_LMDB := 0
 15 
 16 # uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
 17 #    You should not set this flag if you will be reading LMDBs with any
 18 #    possibility of simultaneous read and write
 19 # ALLOW_LMDB_NOLOCK := 1
 20 
 21 # Uncomment if you\'re using OpenCV 3
 22 #----caffe --
 23  OPENCV_VERSION := 3
 24 
 25 # To customize your choice of compiler, uncomment and set the following.
 26 # N.B. the default for Linux is g++ and the default for OSX is clang++
 27 # CUSTOM_CXX := g++
 28 
 29 # CUDA directory contains bin/ and lib/ directories that we need.
 30 CUDA_DIR := /usr/local/cuda
 31 # On Ubuntu 14.04, if cuda tools are installed via
 32 # "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
 33 # CUDA_DIR := /usr
 34 
 35 # CUDA architecture setting: going with all of them.
 36 # For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.
 37 # For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.
 38 # For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility.
 39 #-gencode arch=compute_20,code=sm_20 \\    
 40 #-gencode arch=compute_20,code=sm_21 \\
 41 #去掉了 20 和21           
 42 CUDA_ARCH := -gencode arch=compute_30,code=sm_30 \\
 43         -gencode arch=compute_35,code=sm_35 \\
 44         -gencode arch=compute_50,code=sm_50 \\
 45         -gencode arch=compute_52,code=sm_52 \\
 46         -gencode arch=compute_60,code=sm_60 \\
 47         -gencode arch=compute_61,code=sm_61 \\
 48         -gencode arch=compute_61,code=compute_61
 49 
 50 # BLAS choice:
 51 # atlas for ATLAS (default)
 52 # mkl for MKL
 53 # open for OpenBlas
 54 BLAS := atlas
 55 # Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
 56 # Leave commented to accept the defaults for your choice of BLAS
 57 # (which should work)!
 58 # BLAS_INCLUDE := /path/to/your/blas
 59 # BLAS_LIB := /path/to/your/blas
 60 
 61 # Homebrew puts openblas in a directory that is not on the standard search path
 62 # BLAS_INCLUDE := $(shell brew --prefix openblas)/include
 63 # BLAS_LIB := $(shell brew --prefix openblas)/lib
 64 
 65 # This is required only if you will compile the matlab interface.
 66 # MATLAB directory should contain the mex binary in /bin.
 67 # MATLAB_DIR := /usr/local
 68 # MATLAB_DIR := /Applications/MATLAB_R2012b.app
 69 
 70 # NOTE: this is required only if you will compile the python interface.
 71 # We need to be able to find Python.h and numpy/arrayobject.h.
 72 PYTHON_INCLUDE := /usr/include/python2.7 \\
 73         /usr/lib/python2.7/dist-packages/numpy/core/include
 74 # Anaconda Python distribution is quite popular. Include path:
 75 # Verify anaconda location, sometimes it\'s in root.
 76  ANACONDA_HOME := $(HOME)/anaconda2
 77  PYTHON_INCLUDE := $(ANACONDA_HOME)/include \\
 78          $(ANACONDA_HOME)/include/python2.7 \\
 79          $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include
 80 #ANACONDA_HOME := $(HOME)/anaconda
 81 # PYTHON_INCLUDE := $(ANACONDA_HOME)/include \\
 82          #$(ANACONDA_HOME)/include/python3.6m \\
 83          #$(ANACONDA_HOME)/lib/python3.6m/site-packages/numpy/core/include
 84 
 85 # Uncomment to use Python 3 (default is Python 2)
 86 # PYTHON_LIBRARIES := boost_python3 python3.6m
 87 # PYTHON_INCLUDE := /usr/include/python3.6m \\
 88                  #/usr/lib/python3.6/dist-packages/numpy/core/include
 89 
 90 # We need to be able to find libpythonX.X.so or .dylib.
 91 PYTHON_LIB := /usr/lib
 92 # PYTHON_LIB := $(ANACONDA_HOME)/lib
 93 
 94 # Homebrew installs numpy in a non standard path (keg only)
 95 # PYTHON_INCLUDE += $(dir $(shell python -c \'import numpy.core; print(numpy.core.__file__)\'))/include
 96 # PYTHON_LIB += $(shell brew --prefix numpy)/lib
 97 
 98 # Uncomment to support layers written in Python (will link against Python libs)
 99  WITH_PYTHON_LAYER := 1
100 
101 # Whatever else you find you need goes here.
102 #INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
103 #LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
104 #----caffe --
105 INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
106 LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib
107 
108 # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
109 # INCLUDE_DIRS += $(shell brew --prefix)/include
110 # LIBRARY_DIRS += $(shell brew --prefix)/lib
111 
112 # NCCL acceleration switch (uncomment to build with NCCL)
113 # https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0)
114 # USE_NCCL := 1
115 
116 # Uncomment to use `pkg-config` to specify OpenCV library paths.
117 # (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
118 # USE_PKG_CONFIG := 1
119 
120 # N.B. both build and distribute dirs are cleared on `make clean`
121 BUILD_DIR := build
122 DISTRIBUTE_DIR := distribute
123 
124 # Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
125 # DEBUG := 1
126 
127 # The ID of the GPU that \'make runtest\' will use to run unit tests.
128 TEST_GPUID := 0
129 
130 # enable pretty build (comment to see full commands)
131 Q ?= @

1.3 修改makefile 文件

总共两处改动,修改过的地方用蓝色突出显示了,见代码的181行和416行两处。

  1 PROJECT := caffe
  2 
  3 CONFIG_FILE := Makefile.config
  4 # Explicitly check for the config file, otherwise make -k will proceed anyway.
  5 ifeq ($(wildcard $(CONFIG_FILE)),)
  6 $(error $(CONFIG_FILE) not found. See $(CONFIG_FILE).example.)
  7 endif
  8 include $(CONFIG_FILE)
  9 
 10 BUILD_DIR_LINK := $(BUILD_DIR)
 11 ifeq ($(RELEASE_BUILD_DIR),)
 12     RELEASE_BUILD_DIR := .$(BUILD_DIR)_release
 13 endif
 14 ifeq ($(DEBUG_BUILD_DIR),)
 15     DEBUG_BUILD_DIR := .$(BUILD_DIR)_debug
 16 endif
 17 
 18 DEBUG ?= 0
 19 ifeq ($(DEBUG), 1)
 20     BUILD_DIR := $(DEBUG_BUILD_DIR)
 21     OTHER_BUILD_DIR := $(RELEASE_BUILD_DIR)
 22 else
 23     BUILD_DIR := $(RELEASE_BUILD_DIR)
 24     OTHER_BUILD_DIR := $(DEBUG_BUILD_DIR)
 25 endif
 26 
 27 # All of the directories containing code.
 28 SRC_DIRS := $(shell find * -type d -exec bash -c "find {} -maxdepth 1 \\
 29     \\( -name \'*.cpp\' -o -name \'*.proto\' \\) | grep -q ." \\; -print)
 30 
 31 # The target shared library name
 32 LIBRARY_NAME := $(PROJECT)
 33 LIB_BUILD_DIR := $(BUILD_DIR)/lib
 34 STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a
 35 DYNAMIC_VERSION_MAJOR         := 1
 36 DYNAMIC_VERSION_MINOR         := 0
 37 DYNAMIC_VERSION_REVISION     := 0
 38 DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so
 39 #DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR)
 40 DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
 41 DYNAMIC_NAME := $(LIB_BUILD_DIR)/$(DYNAMIC_VERSIONED_NAME_SHORT)
 42 COMMON_FLAGS += -DCAFFE_VERSION=$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
 43 
 44 ##############################
 45 # Get all source files
 46 ##############################
 47 # CXX_SRCS are the source files excluding the test ones.
 48 CXX_SRCS := $(shell find src/$(PROJECT) ! -name "test_*.cpp" -name "*.cpp")
 49 # CU_SRCS are the cuda source files
 50 CU_SRCS := $(shell find src/$(PROJECT) ! -name "test_*.cu" -name "*.cu")
 51 # TEST_SRCS are the test source files
 52 TEST_MAIN_SRC := src/$(PROJECT)/test/test_caffe_main.cpp
 53 TEST_SRCS := $(shell find src/$(PROJECT) -name "test_*.cpp")
 54 TEST_SRCS := $(filter-out $(TEST_MAIN_SRC), $(TEST_SRCS))
 55 TEST_CU_SRCS := $(shell find src/$(PROJECT) -name "test_*.cu")
 56 GTEST_SRC := src/gtest/gtest-all.cpp
 57 # TOOL_SRCS are the source files for the tool binaries
 58 TOOL_SRCS := $(shell find tools -name "*.cpp")
 59 # EXAMPLE_SRCS are the source files for the example binaries
 60 EXAMPLE_SRCS := $(shell find examples -name "*.cpp")
 61 # BUILD_INCLUDE_DIR contains any generated header files we want to include.
 62 BUILD_INCLUDE_DIR := $(BUILD_DIR)/src
 63 # PROTO_SRCS are the protocol buffer definitions
 64 PROTO_SRC_DIR := src/$(PROJECT)/proto
 65 PROTO_SRCS := $(wildcard $(PROTO_SRC_DIR)/*.proto)
 66 # PROTO_BUILD_DIR will contain the .cc and obj files generated from
 67 # PROTO_SRCS; PROTO_BUILD_INCLUDE_DIR will contain the .h header files
 68 PROTO_BUILD_DIR := $(BUILD_DIR)/$(PROTO_SRC_DIR)
 69 PROTO_BUILD_INCLUDE_DIR := $(BUILD_INCLUDE_DIR)/$(PROJECT)/proto
 70 # NONGEN_CXX_SRCS includes all source/header files except those generated
 71 # automatically (e.g., by proto).
 72 NONGEN_CXX_SRCS := $(shell find \\
 73     src/$(PROJECT) \\
 74     include/$(PROJECT) \\
 75     python/$(PROJECT) \\
 76     matlab/+$(PROJECT)/private \\
 77     examples \\
 78     tools \\
 79     -name "*.cpp" -or -name "*.hpp" -or -name "*.cu" -or -name "*.cuh")
 80 LINT_SCRIPT := scripts/cpp_lint.py
 81 LINT_OUTPUT_DIR := $(BUILD_DIR)/.lint
 82 LINT_EXT := lint.txt
 83 LINT_OUTPUTS := $(addsuffix .$(LINT_EXT), $(addprefix $(LINT_OUTPUT_DIR)/, $(NONGEN_CXX_SRCS)))
 84 EMPTY_LINT_REPORT := $(BUILD_DIR)/.$(LINT_EXT)
 85 NONEMPTY_LINT_REPORT := $(BUILD_DIR)/$(LINT_EXT)
 86 # PY$(PROJECT)_SRC is the python wrapper for $(PROJECT)
 87 PY$(PROJECT)_SRC := python/$(PROJECT)/_$(PROJECT).cpp
 88 PY$(PROJECT)_SO := python/$(PROJECT)/_$(PROJECT).so
 89 PY$(PROJECT)_HXX := include/$(PROJECT)/layers/python_layer.hpp
 90 # MAT$(PROJECT)_SRC is the mex entrance point of matlab package for $(PROJECT)
 91 MAT$(PROJECT)_SRC := matlab/+$(PROJECT)/private/$(PROJECT)_.cpp
 92 ifneq ($(MATLAB_DIR),)
 93     MAT_SO_EXT := $(shell $(MATLAB_DIR)/bin/mexext)
 94 endif
 95 MAT$(PROJECT)_SO := matlab/+$(PROJECT)/private/$(PROJECT)_.$(MAT_SO_EXT)
 96 
 97 ##############################
 98 # Derive generated files
 99 ##############################
100 # The generated files for protocol buffers
101 PROTO_GEN_HEADER_SRCS := $(addprefix $(PROTO_BUILD_DIR)/, \\
102         $(notdir ${PROTO_SRCS:.proto=.pb.h}))
103 PROTO_GEN_HEADER := $(addprefix $(PROTO_BUILD_INCLUDE_DIR)/, \\
104         $(notdir ${PROTO_SRCS:.proto=.pb.h}))
105 PROTO_GEN_CC := $(addprefix $(BUILD_DIR)/, ${PROTO_SRCS:.proto=.pb.cc})
106 PY_PROTO_BUILD_DIR := python/$(PROJECT)/proto
107 PY_PROTO_INIT := python/$(PROJECT)/proto/__init__.py
108 PROTO_GEN_PY := $(foreach file,${PROTO_SRCS:.proto=_pb2.py}, \\
109         $(PY_PROTO_BUILD_DIR)/$(notdir $(file)))
110 # The objects corresponding to the source files
111 # These objects will be linked into the final shared library, so we
112 # exclude the tool, example, and test objects.
113 CXX_OBJS := $(addprefix $(BUILD_DIR)/, ${CXX_SRCS:.cpp=.o})
114 CU_OBJS := $(addprefix $(BUILD_DIR)/cuda/, ${CU_SRCS:.cu=.o})
115 PROTO_OBJS := ${PROTO_GEN_CC:.cc=.o}
116 OBJS := $(PROTO_OBJS) $(CXX_OBJS) $(CU_OBJS)
117 # tool, example, and test objects
118 TOOL_OBJS := $(addprefix $(BUILD_DIR)/, ${TOOL_SRCS:.cpp=.o})
119 TOOL_BUILD_DIR := $(BUILD_DIR)/tools
120 TEST_CXX_BUILD_DIR := $(BUILD_DIR)/src/$(PROJECT)/test
121 TEST_CU_BUILD_DIR := $(BUILD_DIR)/cuda/src/$(PROJECT)/test
122 TEST_CXX_OBJS := $(addprefix $(BUILD_DIR)/, ${TEST_SRCS:.cpp=.o})
123 TEST_CU_OBJS := $(addprefix $(BUILD_DIR)/cuda/, ${TEST_CU_SRCS:.cu=.o})
124 TEST_OBJS := $(TEST_CXX_OBJS) $(TEST_CU_OBJS)
125 GTEST_OBJ := $(addprefix $(BUILD_DIR)/, ${GTEST_SRC:.cpp=.o})
126 EXAMPLE_OBJS := $(addprefix $(BUILD_DIR)/, ${EXAMPLE_SRCS:.cpp=.o})
127 # Output files for automatic dependency generation
128 DEPS := ${CXX_OBJS:.o=.d} ${CU_OBJS:.o=.d} ${TEST_CXX_OBJS:.o=.d} \\
129     ${TEST_CU_OBJS:.o=.d} $(BUILD_DIR)/${MAT$(PROJECT)_SO:.$(MAT_SO_EXT)=.d}
130 # tool, example, and test bins
131 TOOL_BINS := ${TOOL_OBJS:.o=.bin}
132 EXAMPLE_BINS := ${EXAMPLE_OBJS:.o=.bin}
133 # symlinks to tool bins without the ".bin" extension
134 TOOL_BIN_LINKS := ${TOOL_BINS:.bin=}
135 # Put the test binaries in build/test for convenience.
136 TEST_BIN_DIR := $(BUILD_DIR)/test
137 TEST_CU_BINS := $(addsuffix .testbin,$(addprefix $(TEST_BIN_DIR)/, \\
138         $(foreach obj,$(TEST_CU_OBJS),$(basename $(notdir $(obj))))))
139 TEST_CXX_BINS := $(addsuffix .testbin,$(addprefix $(TEST_BIN_DIR)/, \\
140         $(foreach obj,$(TEST_CXX_OBJS),$(basename $(notdir $(obj))))))
141 TEST_BINS := $(TEST_CXX_BINS) $(TEST_CU_BINS)
142 # TEST_ALL_BIN is the test binary that links caffe dynamically.
143 TEST_ALL_BIN := $(TEST_BIN_DIR)/test_all.testbin
144 
145 ##############################
146 # Derive compiler warning dump locations
147 ##############################
148 WARNS_EXT := warnings.txt
149 CXX_WARNS := $(addprefix $(BUILD_DIR)/, ${CXX_SRCS:.cpp=.o.$(WARNS_EXT)})
150 CU_WARNS := $(addprefix $(BUILD_DIR)/cuda/, ${CU_SRCS:.cu=.o.$(WARNS_EXT)})
151 TOOL_WARNS := $(addprefix $(BUILD_DIR)/, ${TOOL_SRCS:.cpp=.o.$(WARNS_EXT)})
152 EXAMPLE_WARNS := $(addprefix $(BUILD_DIR)/, ${EXAMPLE_SRCS:.cpp=.o.$(WARNS_EXT)})
153 TEST_WARNS := $(addprefix $(BUILD_DIR)/, ${TEST_SRCS:.cpp=.o.$(WARNS_EXT)})
154 TEST_CU_WARNS := $(addprefix $(BUILD_DIR)/cuda/, ${TEST_CU_SRCS:.cu=.o.$(WARNS_EXT)})
155 ALL_CXX_WARNS := $(CXX_WARNS) $(TOOL_WARNS) $(EXAMPLE_WARNS) $(TEST_WARNS)
156 ALL_CU_WARNS := $(CU_WARNS) $(TEST_CU_WARNS)
157 ALL_WARNS := $(ALL_CXX_WARNS) $(ALL_CU_WARNS)
158 
159 EMPTY_WARN_REPORT := $(BUILD_DIR)/.$(WARNS_EXT)
160 NONEMPTY_WARN_REPORT := $(BUILD_DIR)/$(WARNS_EXT)
161 
162 ##############################
163 # Derive include and lib directories
164 ##############################
165 CUDA_INCLUDE_DIR := $(CUDA_DIR)/include
166 
167 CUDA_LIB_DIR :=
168 # add <cuda>/lib64 only if it exists
169 ifneq ("$(wildcard $(CUDA_DIR)/lib64)","")
170     CUDA_LIB_DIR += $(CUDA_DIR)/lib64
171 endif
172 CUDA_LIB_DIR += $(CUDA_DIR)/lib
173 
174 INCLUDE_DIRS += $(BUILD_INCLUDE_DIR) ./src ./include
175 ifneq ($(CPU_ONLY), 1)
176     INCLUDE_DIRS += $(CUDA_INCLUDE_DIR)
177     LIBRARY_DIRS += $(CUDA_LIB_DIR)
178     LIBRARIES := cudart cublas curand
179 endif
180 
181 #LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
182 LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
183 
184 # handle IO dependencies
185 USE_LEVELDB ?= 1
186 USE_LMDB ?= 1
187 USE_OPENCV ?= 1
188 
189 ifeq ($(USE_LEVELDB), 1)
190     LIBRARIES += leveldb snappy
191 endif
192 ifeq ($(USE_LMDB), 1)
193     LIBRARIES += lmdb
194 endif
195 ifeq ($(USE_OPENCV), 1)
196     LIBRARIES += opencv_core opencv_highgui opencv_imgproc
197 
198     ifeq ($(OPENCV_VERSION), 3)
199         LIBRARIES += opencv_imgcodecs
200     endif
201 
202 endif
203 PYTHON_LIBRARIES ?= boost_python python2.7
204 WARNINGS := -Wall -Wno-sign-compare
205 
206 ##############################
207 # Set build directories
208 ##############################
209 
210 DISTRIBUTE_DIR ?= distribute
211 DISTRIBUTE_SUBDIRS := $(DISTRIBUTE_DIR)/bin $(DISTRIBUTE_DIR)/lib
212 DIST_ALIASES := dist
213 ifneq ($(strip $(DISTRIBUTE_DIR)),distribute)
214         DIST_ALIASES += distribute
215 endif
216 
217 ALL_BUILD_DIRS := $(sort $(BUILD_DIR) $(addprefix $(BUILD_DIR)/, $(SRC_DIRS)) \\
218     $(addprefix $(BUILD_DIR)/cuda/, $(SRC_DIRS)) \\
219     $(LIB_BUILD_DIR) $(TEST_BIN_DIR) $(PY_PROTO_BUILD_DIR) $(LINT_OUTPUT_DIR) \\
220     $(DISTRIBUTE_SUBDIRS) $(PROTO_BUILD_INCLUDE_DIR))
221 
222 ##############################
223 # Set directory for Doxygen-generated documentation
224 ##############################
225 DOXYGEN_CONFIG_FILE ?= ./.Doxyfile
226 # should be the same as OUTPUT_DIRECTORY in the .Doxyfile
227 DOXYGEN_OUTPUT_DIR ?= ./doxygen
228 DOXYGEN_COMMAND ?= doxygen
229 # All the files that might have Doxygen documentation.
230 DOXYGEN_SOURCES := $(shell find \\
231     src/$(PROJECT) \\
232     include/$(PROJECT) \\
233     python/ \\
234     matlab/ \\
235     examples \\
236     tools \\
237     -name "*.cpp" -or -name "*.hpp" -or -name "*.cu" -or -name "*.cuh" -or \\
238         -name "*.py" -or -name "*.m")
239 DOXYGEN_SOURCES += $(DOXYGEN_CONFIG_FILE)
240 
241 
242 ##############################
243 # Configure build
244 ##############################
245 
246 # Determine platform
247 UNAME := $(shell uname -s)
248 ifeq ($(UNAME), Linux)
249     LINUX := 1
250 else ifeq ($(UNAME), Darwin)
251     OSX := 1
252     OSX_MAJOR_VERSION := $(shell sw_vers -productVersion | cut -f 1 -d .)
253     OSX_MINOR_VERSION := $(shell sw_vers -productVersion | cut -f 2 -d .)
254 endif
255 
256 # Linux
257 ifeq ($(LINUX), 1)
258     CXX ?= /usr/bin/g++
259     GCCVERSION := $(shell $(CXX) -dumpversion | cut -f1,2 -d.)
260     # older versions of gcc are too dumb to build boost with -Wuninitalized
261     ifeq ($(shell echo | awk \'{exit $(GCCVERSION) < 4.6;}\'), 1)
262         WARNINGS += -Wno-uninitialized
263     endif
264     # boost::thread is reasonably called boost_thread (compare OS X)
265     # We will also explicitly add stdc++ to the link target.
266     LIBRARIES += boost_thread stdc++
267     VERSIONFLAGS += -Wl,-soname,$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../lib
268 endif
269 
270 # OS X:
271 # clang++ instead of g++
272 # libstdc++ for NVCC compatibility on OS X >= 10.9 with CUDA < 7.0
273 ifeq ($(OSX), 1)
274     CXX := /usr/bin/clang++
275     ifneq ($(CPU_ONLY), 1)
276         CUDA_VERSION := $(shell $(CUDA_DIR)/bin/nvcc -V | grep -o \'release [0-9.]*\' | tr -d \'[a-z ]\')
277         ifeq ($(shell echo | awk \'{exit $(CUDA_VERSION) < 7.0;}\'), 1)
278             CXXFLAGS += -stdlib=libstdc++
279             LINKFLAGS += -stdlib=libstdc++
280         endif
281         #Ubuntu 16.04 调试caffe深度学习框架

CAFFE:Ubuntu 下安装jupyter notebook

Ubuntu 14.04 64bit下Caffe + Cuda6.5/Cuda7.0 安装配置教程

Caffe初学者第一部:Ubuntu14.04上安装caffe(CPU)+Python的详细过程 (亲测成功, 20180524更新)

Ubuntu14.10+cuda7.0+caffe配置

ubuntu16.04 caffe 安装