CAFFE(三):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 # clang throws this warning for cuda headers 282 WARNINGS += -Wno-unneeded-internal-declaration 283 # 10.11 strips DYLD_* env vars so link CUDA (rpath is available on 10.5+) 284 OSX_10_OR_LATER := $(shell [ $(OSX_MAJOR_VERSION) -ge 10 ] && echo true) 285 OSX_10_5_OR_LATER := $(shell [ $(OSX_MINOR_VERSION) -ge 5 ] && echo true) 286 ifeq ($(OSX_10_OR_LATER),true) 287 ifeq ($(OSX_10_5_OR_LATER),true) 288 LDFLAGS += -Wl,-rpath,$(CUDA_LIB_DIR) 289 endif 290 endif 291 endif 292 # gtest needs to use its own tuple to not conflict with clang 293 COMMON_FLAGS += -DGTEST_USE_OWN_TR1_TUPLE=1 294 # boost::thread is called boost_thread-mt to mark multithreading on OS X 295 LIBRARIES += boost_thread-mt 296 # we need to explicitly ask for the rpath to be obeyed 297 ORIGIN := @loader_path 298 VERSIONFLAGS += -Wl,-install_name,@rpath/$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib 299 else 300 ORIGIN := \$$ORIGIN 301 endif 302 303 # Custom compiler 304 ifdef CUSTOM_CXX 305 CXX := $(CUSTOM_CXX) 306 endif 307 308 # Static linking 309 ifneq (,$(findstring clang++,$(CXX))) 310 STATIC_LINK_COMMAND := -Wl,-force_load $(STATIC_NAME) 311 else ifneq (,$(findstring g++,$(CXX))) 312 STATIC_LINK_COMMAND := -Wl,--whole-archive $(STATIC_NAME) -Wl,--no-whole-archive 313 else 314 # The following line must not be indented with a tab, since we are not inside a target 315 $(error Cannot static link with the $(CXX) compiler) 316 endif 317 318 # Debugging 319 ifeq ($(DEBUG), 1) 320 COMMON_FLAGS += -DDEBUG -g -O0 321 NVCCFLAGS += -G 322 else 323 COMMON_FLAGS += -DNDEBUG -O2 324 endif 325 326 # cuDNN acceleration configuration. 327 ifeq ($(USE_CUDNN), 1) 328 LIBRARIES += cudnn 329 COMMON_FLAGS += -DUSE_CUDNN 330 endif 331 332 # NCCL acceleration configuration 333 ifeq ($(USE_NCCL), 1) 334 LIBRARIES += nccl 335 COMMON_FLAGS += -DUSE_NCCL 336 endif 337 338 # configure IO libraries 339 ifeq ($(USE_OPENCV), 1) 340 COMMON_FLAGS += -DUSE_OPENCV 341 endif 342 ifeq ($(USE_LEVELDB), 1) 343 COMMON_FLAGS += -DUSE_LEVELDB 344 endif 345 ifeq ($(USE_LMDB), 1) 346 COMMON_FLAGS += -DUSE_LMDB 347 ifeq ($(ALLOW_LMDB_NOLOCK), 1) 348 COMMON_FLAGS += -DALLOW_LMDB_NOLOCK 349 endif 350 endif 351 352 # CPU-only configuration 353 ifeq ($(CPU_ONLY), 1) 354 OBJS := $(PROTO_OBJS) $(CXX_OBJS) 355 TEST_OBJS := $(TEST_CXX_OBJS) 356 TEST_BINS := $(TEST_CXX_BINS) 357 ALL_WARNS := $(ALL_CXX_WARNS) 358 TEST_FILTER := --gtest_filter="-*GPU*" 359 COMMON_FLAGS += -DCPU_ONLY 360 endif 361 362 # Python layer support 363 ifeq ($(WITH_PYTHON_LAYER), 1) 364 COMMON_FLAGS += -DWITH_PYTHON_LAYER 365 LIBRARIES += $(PYTHON_LIBRARIES) 366 endif 367 368 # BLAS configuration (default = ATLAS) 369 BLAS ?= atlas 370 ifeq ($(BLAS), mkl) 371 # MKL 372 LIBRARIES += mkl_rt 373 COMMON_FLAGS += -DUSE_MKL 374 MKLROOT ?= /opt/intel/mkl 375 BLAS_INCLUDE ?= $(MKLROOT)/include 376 BLAS_LIB ?= $(MKLROOT)/lib $(MKLROOT)/lib/intel64 377 else ifeq ($(BLAS), open) 378 # OpenBLAS 379 LIBRARIES += openblas 380 else 381 # ATLAS 382 ifeq ($(LINUX), 1) 383 ifeq ($(BLAS), atlas) 384 # Linux simply has cblas and atlas 385 LIBRARIES += cblas atlas 386 endif 387 else ifeq ($(OSX), 1) 388 # OS X packages atlas as the vecLib framework 389 LIBRARIES += cblas 390 # 10.10 has accelerate while 10.9 has veclib 391 XCODE_CLT_VER := $(shell pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep 'version' | sed 's/[^0-9]*\([0-9]\).*/\1/') 392 XCODE_CLT_GEQ_7 := $(shell [ $(XCODE_CLT_VER) -gt 6 ] && echo 1) 393 XCODE_CLT_GEQ_6 := $(shell [ $(XCODE_CLT_VER) -gt 5 ] && echo 1) 394 ifeq ($(XCODE_CLT_GEQ_7), 1) 395 BLAS_INCLUDE ?= /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/$(shell ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ | sort | tail -1)/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers 396 else ifeq ($(XCODE_CLT_GEQ_6), 1) 397 BLAS_INCLUDE ?= /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/ 398 LDFLAGS += -framework Accelerate 399 else 400 BLAS_INCLUDE ?= /System/Library/Frameworks/vecLib.framework/Versions/Current/Headers/ 401 LDFLAGS += -framework vecLib 402 endif 403 endif 404 endif 405 INCLUDE_DIRS += $(BLAS_INCLUDE) 406 LIBRARY_DIRS += $(BLAS_LIB) 407 408 LIBRARY_DIRS += $(LIB_BUILD_DIR) 409 410 # Automatic dependency generation (nvcc is handled separately) 411 CXXFLAGS += -MMD -MP 412 413 # Complete build flags. 414 COMMON_FLAGS += $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) 415 CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS) 416 #NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS) 417 #----caffe -- 418 NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS) 419 420 # mex may invoke an older gcc that is too liberal with -Wuninitalized 421 MATLAB_CXXFLAGS := $(CXXFLAGS) -Wno-uninitialized 422 LINKFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS) 423 424 USE_PKG_CONFIG ?= 0 425 ifeq ($(USE_PKG_CONFIG), 1) 426 PKG_CONFIG := $(shell pkg-config opencv --libs) 427 else 428 PKG_CONFIG := 429 endif 430 LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(PKG_CONFIG) \ 431 $(foreach library,$(LIBRARIES),-l$(library)) 432 PYTHON_LDFLAGS := $(LDFLAGS) $(foreach library,$(PYTHON_LIBRARIES),-l$(library)) 433 434 # 'superclean' target recursively* deletes all files ending with an extension 435 # in $(SUPERCLEAN_EXTS) below. This may be useful if you've built older 436 # versions of Caffe that do not place all generated files in a location known 437 # to the 'clean' target. 438 # 439 # 'supercleanlist' will list the files to be deleted by make superclean. 440 # 441 # * Recursive with the exception that symbolic links are never followed, per the 442 # default behavior of 'find'. 443 SUPERCLEAN_EXTS := .so .a .o .bin .testbin .pb.cc .pb.h _pb2.py .cuo 444 445 # Set the sub-targets of the 'everything' target. 446 EVERYTHING_TARGETS := all py$(PROJECT) test warn lint 447 # Only build matcaffe as part of "everything" if MATLAB_DIR is specified. 448 ifneq ($(MATLAB_DIR),) 449 EVERYTHING_TARGETS += mat$(PROJECT) 450 endif 451 452 ############################## 453 # Define build targets 454 ############################## 455 .PHONY: all lib test clean docs linecount lint lintclean tools examples $(DIST_ALIASES) \ 456 py mat py$(PROJECT) mat$(PROJECT) proto runtest \ 457 superclean supercleanlist supercleanfiles warn everything 458 459 all: lib tools examples 460 461 lib: $(STATIC_NAME) $(DYNAMIC_NAME) 462 463 everything: $(EVERYTHING_TARGETS) 464 465 linecount: 466 cloc --read-lang-def=$(PROJECT).cloc \ 467 src/$(PROJECT) include/$(PROJECT) tools examples \ 468 python matlab 469 470 lint: $(EMPTY_LINT_REPORT) 471 472 lintclean: 473 @ $(RM) -r $(LINT_OUTPUT_DIR) $(EMPTY_LINT_REPORT) $(NONEMPTY_LINT_REPORT) 474 475 docs: $(DOXYGEN_OUTPUT_DIR) 476 @ cd ./docs ; ln -sfn ../$(DOXYGEN_OUTPUT_DIR)/html doxygen 477 478 $(DOXYGEN_OUTPUT_DIR): $(DOXYGEN_CONFIG_FILE) $(DOXYGEN_SOURCES) 479 $(DOXYGEN_COMMAND) $(DOXYGEN_CONFIG_FILE) 480 481 $(EMPTY_LINT_REPORT): $(LINT_OUTPUTS) | $(BUILD_DIR) 482 @ cat $(LINT_OUTPUTS) > $@ 483 @ if [ -s "$@" ]; then \ 484 cat $@; \ 485 mv $@ $(NONEMPTY_LINT_REPORT); \ 486 echo "Found one or more lint errors."; \ 487 exit 1; \ 488 fi; \ 489 $(RM) $(NONEMPTY_LINT_REPORT); \ 490 echo "No lint errors!"; 491 492 $(LINT_OUTPUTS): $(LINT_OUTPUT_DIR)/%.lint.txt : % $(LINT_SCRIPT) | $(LINT_OUTPUT_DIR) 493 @ mkdir -p $(dir $@) 494 @ python $(LINT_SCRIPT) $< 2>&1 \ 495 | grep -v "^Done processing " \ 496 | grep -v "^Total errors found: 0" \ 497 > $@ \ 498 || true 499 500 test: $(TEST_ALL_BIN) $(TEST_ALL_DYNLINK_BIN) $(TEST_BINS) 501 502 tools: $(TOOL_BINS) $(TOOL_BIN_LINKS) 503 504 examples: $(EXAMPLE_BINS) 505 506 py$(PROJECT): py 507 508 py: $(PY$(PROJECT)_SO) $(PROTO_GEN_PY) 509 510 $(PY$(PROJECT)_SO): $(PY$(PROJECT)_SRC) $(PY$(PROJECT)_HXX) | $(DYNAMIC_NAME) 511 @ echo CXX/LD -o $@ $< 512 $(Q)$(CXX) -shared -o $@ $(PY$(PROJECT)_SRC) \ 513 -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(PYTHON_LDFLAGS) \ 514 -Wl,-rpath,$(ORIGIN)/../../build/lib 515 516 mat$(PROJECT): mat 517 518 mat: $(MAT$(PROJECT)_SO) 519 520 $(MAT$(PROJECT)_SO): $(MAT$(PROJECT)_SRC) $(STATIC_NAME) 521 @ if [ -z "$(MATLAB_DIR)" ]; then \ 522 echo "MATLAB_DIR must be specified in $(CONFIG_FILE)" \ 523 "to build mat$(PROJECT)."; \ 524 exit 1; \ 525 fi 526 @ echo MEX $< 527 $(Q)$(MATLAB_DIR)/bin/mex $(MAT$(PROJECT)_SRC) \ 528 CXX="$(CXX)" \ 529 CXXFLAGS="\$$CXXFLAGS $(MATLAB_CXXFLAGS)" \ 530 CXXLIBS="\$$CXXLIBS $(STATIC_LINK_COMMAND) $(LDFLAGS)" -output $@ 531 @ if [ -f "$(PROJECT)_.d" ]; then \ 532 mv -f $(PROJECT)_.d $(BUILD_DIR)/${MAT$(PROJECT)_SO:.$(MAT_SO_EXT)=.d}; \ 533 fi 534 535 runtest: $(TEST_ALL_BIN) 536 $(TOOL_BUILD_DIR)/caffe 537 $(TEST_ALL_BIN) $(TEST_GPUID) --gtest_shuffle $(TEST_FILTER) 538 539 pytest: py 540 cd python; python -m unittest discover -s caffe/test 541 542 mattest: mat 543 cd matlab; $(MATLAB_DIR)/bin/matlab -nodisplay -r 'caffe.run_tests(), exit()' 544 545 warn: $(EMPTY_WARN_REPORT) 546 547 $(EMPTY_WARN_REPORT): $(ALL_WARNS) | $(BUILD_DIR) 548 @ cat $(ALL_WARNS) > $@ 549 @ if [ -s "$@" ]; then \ 550 cat $@; \ 551 mv $@ $(NONEMPTY_WARN_REPORT); \ 552 echo "Compiler produced one or more warnings."; \ 553 exit 1; \ 554 fi; \ 555 $(RM) $(NONEMPTY_WARN_REPORT); \ 556 echo "No compiler warnings!"; 557 558 $(ALL_WARNS): %.o.$(WARNS_EXT) : %.o 559 560 $(BUILD_DIR_LINK): $(BUILD_DIR)/.linked 561 562 # Create a target ".linked" in this BUILD_DIR to tell Make that the "build" link 563 # is currently correct, then delete the one in the OTHER_BUILD_DIR in case it 564 # exists and $(DEBUG) is toggled later. 565 $(BUILD_DIR)/.linked: 566 @ mkdir -p $(BUILD_DIR) 567 @ $(RM) $(OTHER_BUILD_DIR)/.linked 568 @ $(RM) -r $(BUILD_DIR_LINK) 569 @ ln -s $(BUILD_DIR) $(BUILD_DIR_LINK) 570 @ touch $@ 571 572 $(ALL_BUILD_DIRS): | $(BUILD_DIR_LINK) 573 @ mkdir -p $@ 574 575 $(DYNAMIC_NAME): $(OBJS) | $(LIB_BUILD_DIR) 576 @ echo LD -o $@ 577 $(Q)$(CXX) -shared -o $@ $(OBJS) $(VERSIONFLAGS) $(LINKFLAGS) $(LDFLAGS) 578 @ cd $(BUILD_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT); ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT) 579 580 $(STATIC_NAME): $(OBJS) | $(LIB_BUILD_DIR) 581 @ echo AR -o $@ 582 $(Q)ar rcs $@ $(OBJS) 583 584 $(BUILD_DIR)/%.o: %.cpp $(PROTO_GEN_HEADER) | $(ALL_BUILD_DIRS) 585 @ echo CXX $< 586 $(Q)$(CXX) $< $(CXXFLAGS) -c -o $@ 2> $@.$(WARNS_EXT) \ 587 || (cat $@.$(WARNS_EXT); exit 1) 588 @ cat $@.$(WARNS_EXT) 589 590 $(PROTO_BUILD_DIR)/%.pb.o: $(PROTO_BUILD_DIR)/%.pb.cc $(PROTO_GEN_HEADER) \ 591 | $(PROTO_BUILD_DIR) 592 @ echo CXX $< 593 $(Q)$(CXX) $< $(CXXFLAGS) -c -o $@ 2> $@.$(WARNS_EXT) \ 594 || (cat $@.$(WARNS_EXT); exit 1) 595 @ cat $@.$(WARNS_EXT) 596 597 $(BUILD_DIR)/cuda/%.o: %.cu | $(ALL_BUILD_DIRS) 598 @ echo NVCC $< 599 $(Q)$(CUDA_DIR)/bin/nvcc $(NVCCFLAGS) $(CUDA_ARCH) -M $< -o ${@:.o=.d} \ 600 -odir $(@D) 601 $(Q)$(CUDA_DIR)/bin/nvcc $(NVCCFLAGS) $(CUDA_ARCH) -c $< -o $@ 2> $@.$(WARNS_EXT) \ 602 || (cat $@.$(WARNS_EXT); exit 1) 603 @ cat $@.$(WARNS_EXT) 604 605 $(TEST_ALL_BIN): $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \ 606 | $(DYNAMIC_NAME) $(TEST_BIN_DIR) 607 @ echo CXX/LD -o $@ $< 608 $(Q)$(CXX) $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \ 609 -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib 610 611 $(TEST_CU_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CU_BUILD_DIR)/%.o \ 612 $(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR) 613 @ echo LD $< 614 $(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \ 615 -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib 616 617 $(TEST_CXX_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CXX_BUILD_DIR)/%.o \ 618 $(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR) 619 @ echo LD $< 620 $(Q)$(CXX) $(TEST_MAIN_SRC) $< $(GTEST_OBJ) \ 621 -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib 622 623 # Target for extension-less symlinks to tool binaries with extension '*.bin'. 624 $(TOOL_BUILD_DIR)/%: $(TOOL_BUILD_DIR)/%.bin | $(TOOL_BUILD_DIR) 625 @ $(RM) $@ 626 @ ln -s $(notdir $<) $@ 627 628 $(TOOL_BINS): %.bin : %.o | $(DYNAMIC_NAME) 629 @ echo CXX/LD -o $@ 630 $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \ 631 -Wl,-rpath,$(ORIGIN)/../lib 632 633 $(EXAMPLE_BINS): %.bin : %.o | $(DYNAMIC_NAME) 634 @ echo CXX/LD -o $@ 635 $(Q)$(CXX) $< -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \ 636 -Wl,-rpath,$(ORIGIN)/../../lib 637 638 proto: $(PROTO_GEN_CC) $(PROTO_GEN_HEADER) 639 640 $(PROTO_BUILD_DIR)/%.pb.cc $(PROTO_BUILD_DIR)/%.pb.h : \ 641 $(PROTO_SRC_DIR)/%.proto | $(PROTO_BUILD_DIR) 642 @ echo PROTOC $< 643 $(Q)protoc --proto_path=$(PROTO_SRC_DIR) --cpp_out=$(PROTO_BUILD_DIR) $< 644 645 $(PY_PROTO_BUILD_DIR)/%_pb2.py : $(PROTO_SRC_DIR)/%.proto \ 646 $(PY_PROTO_INIT) | $(PY_PROTO_BUILD_DIR) 647 @ echo PROTOC \(python\) $< 648 $(Q)protoc --proto_path=$(PROTO_SRC_DIR) --python_out=$(PY_PROTO_BUILD_DIR) $< 649 650 $(PY_PROTO_INIT): | $(PY_PROTO_BUILD_DIR) 651 touch $(PY_PROTO_INIT) 652 653 clean: 654 @- $(RM) -rf $(ALL_BUILD_DIRS) 655 @- $(RM) -rf $(OTHER_BUILD_DIR) 656 @- $(RM) -rf $(BUILD_DIR_LINK) 657 @- $(RM) -rf $(DISTRIBUTE_DIR) 658 @- $(RM) $(PY$(PROJECT)_SO) 659 @- $(RM) $(MAT$(PROJECT)_SO) 660 661 supercleanfiles: 662 $(eval SUPERCLEAN_FILES := $(strip \ 663 $(foreach ext,$(SUPERCLEAN_EXTS), $(shell find . -name '*$(ext)' \ 664 -not -path './data/*')))) 665 666 supercleanlist: supercleanfiles 667 @ \ 668 if [ -z "$(SUPERCLEAN_FILES)" ]; then \ 669 echo "No generated files found."; \ 670 else \ 671 echo $(SUPERCLEAN_FILES) | tr ' ' '\n'; \ 672 fi 673 674 superclean: clean supercleanfiles 675 @ \ 676 if [ -z "$(SUPERCLEAN_FILES)" ]; then \ 677 echo "No generated files found."; \ 678 else \ 679 echo "Deleting the following generated files:"; \ 680 echo $(SUPERCLEAN_FILES) | tr ' ' '\n'; \ 681 $(RM) $(SUPERCLEAN_FILES); \ 682 fi 683 684 $(DIST_ALIASES): $(DISTRIBUTE_DIR) 685 686 $(DISTRIBUTE_DIR): all py | $(DISTRIBUTE_SUBDIRS) 687 # add proto 688 cp -r src/caffe/proto $(DISTRIBUTE_DIR)/ 689 # add include 690 cp -r include $(DISTRIBUTE_DIR)/ 691 mkdir -p $(DISTRIBUTE_DIR)/include/caffe/proto 692 cp $(PROTO_GEN_HEADER_SRCS) $(DISTRIBUTE_DIR)/include/caffe/proto 693 # add tool and example binaries 694 cp $(TOOL_BINS) $(DISTRIBUTE_DIR)/bin 695 cp $(EXAMPLE_BINS) $(DISTRIBUTE_DIR)/bin 696 # add libraries 697 cp $(STATIC_NAME) $(DISTRIBUTE_DIR)/lib 698 install -m 644 $(DYNAMIC_NAME) $(DISTRIBUTE_DIR)/lib 699 cd $(DISTRIBUTE_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT); ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT) 700 # add python - it's not the standard way, indeed... 701 cp -r python $(DISTRIBUTE_DIR)/ 702 703 -include $(DEPS)
1.4 配置完成开始编译
1 cd caffe 2 sudo make clean 3 sudo make all #或者make all -j4(代表4核,或者j8) 4 sudo make test 5 sudo make runtest #或者sudo make runtest -j8 6 sudo make pycaffe
到运行code5,出现这个界面后,执行code6无报错则配置caffe结束