东方耀AI技术分享

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 907|回复: 0
打印 上一主题 下一主题

[课堂笔记] 编译安装caffe-ssd(利用conda安装好的caffe-gpu虚拟环境)

[复制链接]

1365

主题

1856

帖子

1万

积分

管理员

Rank: 10Rank: 10Rank: 10

积分
14432
QQ
跳转到指定楼层
楼主
发表于 2019-8-3 10:06:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式


编译安装caffe-ssd(利用conda安装caffe-gpu虚拟环境)


conda一键安装caffe-gpu的教程:http://www.ai111.vip/thread-780-1-1.html


caffe-ssd源码的下载(如果速度不快可以通过gitee.com来导入github.com仓库 自己手动下载):

  1. git clone https://github.com/weiliu89/caffe.git
  2. cd caffe
  3. git checkout ssd
复制代码
一定要注意有ssd的分支

参考这个:http://www.ai111.vip/thread-782-1-1.html

Caffe-SSD就是基于Caffe源码编译的

physical GPU (device: 0, name: GeForce GTX 750, pci bus id: 0000:01:00.0, compute capability: 5.0)

physical GPU (device: 0, name: GeForce RTX 2070 SUPER, pci bus id: 0000:01:00.0, compute capability: 7.5)

  1. ## Refer to http://caffe.berkeleyvision.org/installation.html
  2. # Contributions simplifying and improving our build system are welcome!

  3. # cuDNN acceleration switch (uncomment to build with cuDNN).
  4. USE_CUDNN := 1

  5. # CPU-only switch (uncomment to build without GPU support).
  6. # CPU_ONLY := 1

  7. # uncomment to disable IO dependencies and corresponding data layers
  8. # USE_OPENCV := 0
  9. # USE_LEVELDB := 0
  10. # USE_LMDB := 0

  11. # uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
  12. #        You should not set this flag if you will be reading LMDBs with any
  13. #        possibility of simultaneous read and write
  14. # ALLOW_LMDB_NOLOCK := 1

  15. # Uncomment if you're using OpenCV 3
  16. OPENCV_VERSION := 3

  17. # To customize your choice of compiler, uncomment and set the following.
  18. # N.B. the default for Linux is g++ and the default for OSX is clang++
  19. # CUSTOM_CXX := g++

  20. # CUDA directory contains bin/ and lib/ directories that we need.
  21. CUDA_DIR := /usr/local/cuda
  22. # On Ubuntu 14.04, if cuda tools are installed via
  23. # "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
  24. # CUDA_DIR := /usr

  25. # CUDA architecture setting: going with all of them.
  26. # For CUDA < 6.0, comment the lines after *_35 for compatibility.
  27. CUDA_ARCH := -gencode arch=compute_30,code=sm_30 \
  28.              -gencode arch=compute_35,code=sm_35 \
  29.              -gencode arch=compute_50,code=sm_50 \
  30.              -gencode arch=compute_52,code=sm_52 \
  31.              -gencode arch=compute_60,code=sm_60 \
  32.              -gencode arch=compute_61,code=sm_61 \
  33.              -gencode arch=compute_75,code=sm_75

  34. # BLAS choice:
  35. # atlas for ATLAS (default)
  36. # mkl for MKL
  37. # open for OpenBlas
  38. BLAS := atlas
  39. # BLAS := open
  40. # Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
  41. # Leave commented to accept the defaults for your choice of BLAS
  42. # (which should work)!
  43. # BLAS_INCLUDE := /path/to/your/blas
  44. # BLAS_LIB := /path/to/your/blas

  45. # Homebrew puts openblas in a directory that is not on the standard search path
  46. # BLAS_INCLUDE := $(shell brew --prefix openblas)/include
  47. # BLAS_LIB := $(shell brew --prefix openblas)/lib

  48. # This is required only if you will compile the matlab interface.
  49. # MATLAB directory should contain the mex binary in /bin.
  50. # MATLAB_DIR := /usr/local
  51. # MATLAB_DIR := /Applications/MATLAB_R2012b.app

  52. # NOTE: this is required only if you will compile the python interface.
  53. # We need to be able to find Python.h and numpy/arrayobject.h.
  54. # PYTHON_INCLUDE := /usr/include/python2.7 \
  55. #                /usr/lib/python2.7/dist-packages/numpy/core/include
  56. # Anaconda Python distribution is quite popular. Include path:
  57. # Verify anaconda location, sometimes it's in root.
  58. ANACONDA_HOME := $(HOME)/miniconda3/envs/py3_caffe_source
  59. PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
  60.                 $(ANACONDA_HOME)/include/python3.6m \
  61.                 $(ANACONDA_HOME)/lib/python3.6/site-packages/numpy/core/include \

  62. # Uncomment to use Python 3 (default is Python 2)
  63. # PYTHON_LIBRARIES := boost_python3 python3.5m
  64. # PYTHON_INCLUDE := /usr/include/python3.5m \
  65. #                 /usr/lib/python3.5/dist-packages/numpy/core/include

  66. # We need to be able to find libpythonX.X.so or .dylib.
  67. # PYTHON_LIB := /usr/lib
  68. PYTHON_LIB := $(ANACONDA_HOME)/lib

  69. # Homebrew installs numpy in a non standard path (keg only)
  70. # PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
  71. # PYTHON_LIB += $(shell brew --prefix numpy)/lib

  72. # Uncomment to support layers written in Python (will link against Python libs)
  73. WITH_PYTHON_LAYER := 1

  74. # Whatever else you find you need goes here.
  75. INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
  76. LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

  77. # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
  78. # INCLUDE_DIRS += $(shell brew --prefix)/include
  79. # LIBRARY_DIRS += $(shell brew --prefix)/lib

  80. # Uncomment to use `pkg-config` to specify OpenCV library paths.
  81. # (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
  82. # USE_PKG_CONFIG := 1

  83. # N.B. both build and distribute dirs are cleared on `make clean`
  84. BUILD_DIR := build
  85. DISTRIBUTE_DIR := distribute

  86. # Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
  87. # DEBUG := 1

  88. # The ID of the GPU that 'make runtest' will use to run unit tests.
  89. TEST_GPUID := 0

  90. # enable pretty build (comment to see full commands)
  91. Q ?= @
复制代码
  1. PROJECT := caffe

  2. CONFIG_FILE := Makefile.config
  3. # Explicitly check for the config file, otherwise make -k will proceed anyway.
  4. ifeq ($(wildcard $(CONFIG_FILE)),)
  5. $(error $(CONFIG_FILE) not found. See $(CONFIG_FILE).example.)
  6. endif
  7. include $(CONFIG_FILE)

  8. BUILD_DIR_LINK := $(BUILD_DIR)
  9. ifeq ($(RELEASE_BUILD_DIR),)
  10.         RELEASE_BUILD_DIR := .$(BUILD_DIR)_release
  11. endif
  12. ifeq ($(DEBUG_BUILD_DIR),)
  13.         DEBUG_BUILD_DIR := .$(BUILD_DIR)_debug
  14. endif

  15. DEBUG ?= 0
  16. ifeq ($(DEBUG), 1)
  17.         BUILD_DIR := $(DEBUG_BUILD_DIR)
  18.         OTHER_BUILD_DIR := $(RELEASE_BUILD_DIR)
  19. else
  20.         BUILD_DIR := $(RELEASE_BUILD_DIR)
  21.         OTHER_BUILD_DIR := $(DEBUG_BUILD_DIR)
  22. endif

  23. # All of the directories containing code.
  24. SRC_DIRS := $(shell find * -type d -exec bash -c "find {} -maxdepth 1 \
  25.         \( -name '*.cpp' -o -name '*.proto' \) | grep -q ." \; -print)

  26. # The target shared library name
  27. LIBRARY_NAME := $(PROJECT)
  28. LIB_BUILD_DIR := $(BUILD_DIR)/lib
  29. STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a
  30. DYNAMIC_VERSION_MAJOR                 := 1
  31. DYNAMIC_VERSION_MINOR                 := 0
  32. DYNAMIC_VERSION_REVISION         := 0-rc3
  33. DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so
  34. #DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR)
  35. DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
  36. DYNAMIC_NAME := $(LIB_BUILD_DIR)/$(DYNAMIC_VERSIONED_NAME_SHORT)
  37. COMMON_FLAGS += -DCAFFE_VERSION=$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)

  38. ##############################
  39. # Get all source files
  40. ##############################
  41. # CXX_SRCS are the source files excluding the test ones.
  42. CXX_SRCS := $(shell find src/$(PROJECT) ! -name "test_*.cpp" -name "*.cpp")
  43. # CU_SRCS are the cuda source files
  44. CU_SRCS := $(shell find src/$(PROJECT) ! -name "test_*.cu" -name "*.cu")
  45. # TEST_SRCS are the test source files
  46. TEST_MAIN_SRC := src/$(PROJECT)/test/test_caffe_main.cpp
  47. TEST_SRCS := $(shell find src/$(PROJECT) -name "test_*.cpp")
  48. TEST_SRCS := $(filter-out $(TEST_MAIN_SRC), $(TEST_SRCS))
  49. TEST_CU_SRCS := $(shell find src/$(PROJECT) -name "test_*.cu")
  50. GTEST_SRC := src/gtest/gtest-all.cpp
  51. # TOOL_SRCS are the source files for the tool binaries
  52. TOOL_SRCS := $(shell find tools -name "*.cpp")
  53. # EXAMPLE_SRCS are the source files for the example binaries
  54. EXAMPLE_SRCS := $(shell find examples -name "*.cpp")
  55. # BUILD_INCLUDE_DIR contains any generated header files we want to include.
  56. BUILD_INCLUDE_DIR := $(BUILD_DIR)/src
  57. # PROTO_SRCS are the protocol buffer definitions
  58. PROTO_SRC_DIR := src/$(PROJECT)/proto
  59. PROTO_SRCS := $(wildcard $(PROTO_SRC_DIR)/*.proto)
  60. # PROTO_BUILD_DIR will contain the .cc and obj files generated from
  61. # PROTO_SRCS; PROTO_BUILD_INCLUDE_DIR will contain the .h header files
  62. PROTO_BUILD_DIR := $(BUILD_DIR)/$(PROTO_SRC_DIR)
  63. PROTO_BUILD_INCLUDE_DIR := $(BUILD_INCLUDE_DIR)/$(PROJECT)/proto
  64. # NONGEN_CXX_SRCS includes all source/header files except those generated
  65. # automatically (e.g., by proto).
  66. NONGEN_CXX_SRCS := $(shell find \
  67.         src/$(PROJECT) \
  68.         include/$(PROJECT) \
  69.         python/$(PROJECT) \
  70.         matlab/+$(PROJECT)/private \
  71.         examples \
  72.         tools \
  73.         -name "*.cpp" -or -name "*.hpp" -or -name "*.cu" -or -name "*.cuh")
  74. LINT_SCRIPT := scripts/cpp_lint.py
  75. LINT_OUTPUT_DIR := $(BUILD_DIR)/.lint
  76. LINT_EXT := lint.txt
  77. LINT_OUTPUTS := $(addsuffix .$(LINT_EXT), $(addprefix $(LINT_OUTPUT_DIR)/, $(NONGEN_CXX_SRCS)))
  78. EMPTY_LINT_REPORT := $(BUILD_DIR)/.$(LINT_EXT)
  79. NONEMPTY_LINT_REPORT := $(BUILD_DIR)/$(LINT_EXT)
  80. # PY$(PROJECT)_SRC is the python wrapper for $(PROJECT)
  81. PY$(PROJECT)_SRC := python/$(PROJECT)/_$(PROJECT).cpp
  82. PY$(PROJECT)_SO := python/$(PROJECT)/_$(PROJECT).so
  83. PY$(PROJECT)_HXX := include/$(PROJECT)/layers/python_layer.hpp
  84. # MAT$(PROJECT)_SRC is the mex entrance point of matlab package for $(PROJECT)
  85. MAT$(PROJECT)_SRC := matlab/+$(PROJECT)/private/$(PROJECT)_.cpp
  86. ifneq ($(MATLAB_DIR),)
  87.         MAT_SO_EXT := $(shell $(MATLAB_DIR)/bin/mexext)
  88. endif
  89. MAT$(PROJECT)_SO := matlab/+$(PROJECT)/private/$(PROJECT)_.$(MAT_SO_EXT)

  90. ##############################
  91. # Derive generated files
  92. ##############################
  93. # The generated files for protocol buffers
  94. PROTO_GEN_HEADER_SRCS := $(addprefix $(PROTO_BUILD_DIR)/, \
  95.                 $(notdir ${PROTO_SRCS:.proto=.pb.h}))
  96. PROTO_GEN_HEADER := $(addprefix $(PROTO_BUILD_INCLUDE_DIR)/, \
  97.                 $(notdir ${PROTO_SRCS:.proto=.pb.h}))
  98. PROTO_GEN_CC := $(addprefix $(BUILD_DIR)/, ${PROTO_SRCS:.proto=.pb.cc})
  99. PY_PROTO_BUILD_DIR := python/$(PROJECT)/proto
  100. PY_PROTO_INIT := python/$(PROJECT)/proto/__init__.py
  101. PROTO_GEN_PY := $(foreach file,${PROTO_SRCS:.proto=_pb2.py}, \
  102.                 $(PY_PROTO_BUILD_DIR)/$(notdir $(file)))
  103. # The objects corresponding to the source files
  104. # These objects will be linked into the final shared library, so we
  105. # exclude the tool, example, and test objects.
  106. CXX_OBJS := $(addprefix $(BUILD_DIR)/, ${CXX_SRCS:.cpp=.o})
  107. CU_OBJS := $(addprefix $(BUILD_DIR)/cuda/, ${CU_SRCS:.cu=.o})
  108. PROTO_OBJS := ${PROTO_GEN_CC:.cc=.o}
  109. OBJS := $(PROTO_OBJS) $(CXX_OBJS) $(CU_OBJS)
  110. # tool, example, and test objects
  111. TOOL_OBJS := $(addprefix $(BUILD_DIR)/, ${TOOL_SRCS:.cpp=.o})
  112. TOOL_BUILD_DIR := $(BUILD_DIR)/tools
  113. TEST_CXX_BUILD_DIR := $(BUILD_DIR)/src/$(PROJECT)/test
  114. TEST_CU_BUILD_DIR := $(BUILD_DIR)/cuda/src/$(PROJECT)/test
  115. TEST_CXX_OBJS := $(addprefix $(BUILD_DIR)/, ${TEST_SRCS:.cpp=.o})
  116. TEST_CU_OBJS := $(addprefix $(BUILD_DIR)/cuda/, ${TEST_CU_SRCS:.cu=.o})
  117. TEST_OBJS := $(TEST_CXX_OBJS) $(TEST_CU_OBJS)
  118. GTEST_OBJ := $(addprefix $(BUILD_DIR)/, ${GTEST_SRC:.cpp=.o})
  119. EXAMPLE_OBJS := $(addprefix $(BUILD_DIR)/, ${EXAMPLE_SRCS:.cpp=.o})
  120. # Output files for automatic dependency generation
  121. DEPS := ${CXX_OBJS:.o=.d} ${CU_OBJS:.o=.d} ${TEST_CXX_OBJS:.o=.d} \
  122.         ${TEST_CU_OBJS:.o=.d} $(BUILD_DIR)/${MAT$(PROJECT)_SO:.$(MAT_SO_EXT)=.d}
  123. # tool, example, and test bins
  124. TOOL_BINS := ${TOOL_OBJS:.o=.bin}
  125. EXAMPLE_BINS := ${EXAMPLE_OBJS:.o=.bin}
  126. # symlinks to tool bins without the ".bin" extension
  127. TOOL_BIN_LINKS := ${TOOL_BINS:.bin=}
  128. # Put the test binaries in build/test for convenience.
  129. TEST_BIN_DIR := $(BUILD_DIR)/test
  130. TEST_CU_BINS := $(addsuffix .testbin,$(addprefix $(TEST_BIN_DIR)/, \
  131.                 $(foreach obj,$(TEST_CU_OBJS),$(basename $(notdir $(obj))))))
  132. TEST_CXX_BINS := $(addsuffix .testbin,$(addprefix $(TEST_BIN_DIR)/, \
  133.                 $(foreach obj,$(TEST_CXX_OBJS),$(basename $(notdir $(obj))))))
  134. TEST_BINS := $(TEST_CXX_BINS) $(TEST_CU_BINS)
  135. # TEST_ALL_BIN is the test binary that links caffe dynamically.
  136. TEST_ALL_BIN := $(TEST_BIN_DIR)/test_all.testbin

  137. ##############################
  138. # Derive compiler warning dump locations
  139. ##############################
  140. WARNS_EXT := warnings.txt
  141. CXX_WARNS := $(addprefix $(BUILD_DIR)/, ${CXX_SRCS:.cpp=.o.$(WARNS_EXT)})
  142. CU_WARNS := $(addprefix $(BUILD_DIR)/cuda/, ${CU_SRCS:.cu=.o.$(WARNS_EXT)})
  143. TOOL_WARNS := $(addprefix $(BUILD_DIR)/, ${TOOL_SRCS:.cpp=.o.$(WARNS_EXT)})
  144. EXAMPLE_WARNS := $(addprefix $(BUILD_DIR)/, ${EXAMPLE_SRCS:.cpp=.o.$(WARNS_EXT)})
  145. TEST_WARNS := $(addprefix $(BUILD_DIR)/, ${TEST_SRCS:.cpp=.o.$(WARNS_EXT)})
  146. TEST_CU_WARNS := $(addprefix $(BUILD_DIR)/cuda/, ${TEST_CU_SRCS:.cu=.o.$(WARNS_EXT)})
  147. ALL_CXX_WARNS := $(CXX_WARNS) $(TOOL_WARNS) $(EXAMPLE_WARNS) $(TEST_WARNS)
  148. ALL_CU_WARNS := $(CU_WARNS) $(TEST_CU_WARNS)
  149. ALL_WARNS := $(ALL_CXX_WARNS) $(ALL_CU_WARNS)

  150. EMPTY_WARN_REPORT := $(BUILD_DIR)/.$(WARNS_EXT)
  151. NONEMPTY_WARN_REPORT := $(BUILD_DIR)/$(WARNS_EXT)

  152. ##############################
  153. # Derive include and lib directories
  154. ##############################
  155. CUDA_INCLUDE_DIR := $(CUDA_DIR)/include

  156. CUDA_LIB_DIR :=
  157. # add <cuda>/lib64 only if it exists
  158. ifneq ("$(wildcard $(CUDA_DIR)/lib64)","")
  159.         CUDA_LIB_DIR += $(CUDA_DIR)/lib64
  160. endif
  161. CUDA_LIB_DIR += $(CUDA_DIR)/lib

  162. INCLUDE_DIRS += $(BUILD_INCLUDE_DIR) ./src ./include
  163. ifneq ($(CPU_ONLY), 1)
  164.         INCLUDE_DIRS += $(CUDA_INCLUDE_DIR)
  165.         LIBRARY_DIRS += $(CUDA_LIB_DIR)
  166.         LIBRARIES := cudart cublas curand
  167. endif

  168. LIBRARIES += glog gflags protobuf boost_system boost_filesystem boost_regex m hdf5_serial_hl hdf5_serial

  169. # handle IO dependencies
  170. USE_LEVELDB ?= 1
  171. USE_LMDB ?= 1
  172. USE_OPENCV ?= 1

  173. ifeq ($(USE_LEVELDB), 1)
  174.         LIBRARIES += leveldb snappy
  175. endif
  176. ifeq ($(USE_LMDB), 1)
  177.         LIBRARIES += lmdb
  178. endif
  179. ifeq ($(USE_OPENCV), 1)
  180.         LIBRARIES += opencv_core opencv_highgui opencv_imgproc

  181.         ifeq ($(OPENCV_VERSION), 3)
  182.                 LIBRARIES += opencv_imgcodecs opencv_videoio
  183.         endif

  184. endif
  185. PYTHON_LIBRARIES ?= boost_python3 python3.6m
  186. WARNINGS := -Wall -Wno-sign-compare

  187. ##############################
  188. # Set build directories
  189. ##############################

  190. DISTRIBUTE_DIR ?= distribute
  191. DISTRIBUTE_SUBDIRS := $(DISTRIBUTE_DIR)/bin $(DISTRIBUTE_DIR)/lib
  192. DIST_ALIASES := dist
  193. ifneq ($(strip $(DISTRIBUTE_DIR)),distribute)
  194.                 DIST_ALIASES += distribute
  195. endif

  196. ALL_BUILD_DIRS := $(sort $(BUILD_DIR) $(addprefix $(BUILD_DIR)/, $(SRC_DIRS)) \
  197.         $(addprefix $(BUILD_DIR)/cuda/, $(SRC_DIRS)) \
  198.         $(LIB_BUILD_DIR) $(TEST_BIN_DIR) $(PY_PROTO_BUILD_DIR) $(LINT_OUTPUT_DIR) \
  199.         $(DISTRIBUTE_SUBDIRS) $(PROTO_BUILD_INCLUDE_DIR))

  200. ##############################
  201. # Set directory for Doxygen-generated documentation
  202. ##############################
  203. DOXYGEN_CONFIG_FILE ?= ./.Doxyfile
  204. # should be the same as OUTPUT_DIRECTORY in the .Doxyfile
  205. DOXYGEN_OUTPUT_DIR ?= ./doxygen
  206. DOXYGEN_COMMAND ?= doxygen
  207. # All the files that might have Doxygen documentation.
  208. DOXYGEN_SOURCES := $(shell find \
  209.         src/$(PROJECT) \
  210.         include/$(PROJECT) \
  211.         python/ \
  212.         matlab/ \
  213.         examples \
  214.         tools \
  215.         -name "*.cpp" -or -name "*.hpp" -or -name "*.cu" -or -name "*.cuh" -or \
  216.         -name "*.py" -or -name "*.m")
  217. DOXYGEN_SOURCES += $(DOXYGEN_CONFIG_FILE)


  218. ##############################
  219. # Configure build
  220. ##############################

  221. # Determine platform
  222. UNAME := $(shell uname -s)
  223. ifeq ($(UNAME), Linux)
  224.         LINUX := 1
  225. else ifeq ($(UNAME), Darwin)
  226.         OSX := 1
  227.         OSX_MAJOR_VERSION := $(shell sw_vers -productVersion | cut -f 1 -d .)
  228.         OSX_MINOR_VERSION := $(shell sw_vers -productVersion | cut -f 2 -d .)
  229. endif

  230. # Linux
  231. ifeq ($(LINUX), 1)
  232.         CXX ?= /usr/bin/g++
  233.         GCCVERSION := $(shell $(CXX) -dumpversion | cut -f1,2 -d.)
  234.         # older versions of gcc are too dumb to build boost with -Wuninitalized
  235.         ifeq ($(shell echo | awk '{exit $(GCCVERSION) < 4.6;}'), 1)
  236.                 WARNINGS += -Wno-uninitialized
  237.         endif
  238.         # boost::thread is reasonably called boost_thread (compare OS X)
  239.         # We will also explicitly add stdc++ to the link target.
  240.         LIBRARIES += boost_thread stdc++
  241.         VERSIONFLAGS += -Wl,-soname,$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../lib
  242. endif

  243. # OS X:
  244. # clang++ instead of g++
  245. # libstdc++ for NVCC compatibility on OS X >= 10.9 with CUDA < 7.0
  246. ifeq ($(OSX), 1)
  247.         CXX := /usr/bin/clang++
  248.         ifneq ($(CPU_ONLY), 1)
  249.                 CUDA_VERSION := $(shell $(CUDA_DIR)/bin/nvcc -V | grep -o 'release [0-9.]*' | tr -d '[a-z ]')
  250.                 ifeq ($(shell echo | awk '{exit $(CUDA_VERSION) < 7.0;}'), 1)
  251.                         CXXFLAGS += -stdlib=libstdc++
  252.                         LINKFLAGS += -stdlib=libstdc++
  253.                 endif
  254.                 # clang throws this warning for cuda headers
  255.                 WARNINGS += -Wno-unneeded-internal-declaration
  256.                 # 10.11 strips DYLD_* env vars so link CUDA (rpath is available on 10.5+)
  257.                 OSX_10_OR_LATER   := $(shell [ $(OSX_MAJOR_VERSION) -ge 10 ] && echo true)
  258.                 OSX_10_5_OR_LATER := $(shell [ $(OSX_MINOR_VERSION) -ge 5 ] && echo true)
  259.                 ifeq ($(OSX_10_OR_LATER),true)
  260.                         ifeq ($(OSX_10_5_OR_LATER),true)
  261.                                 LDFLAGS += -Wl,-rpath,$(CUDA_LIB_DIR)
  262.                         endif
  263.                 endif
  264.         endif
  265.         # gtest needs to use its own tuple to not conflict with clang
  266.         COMMON_FLAGS += -DGTEST_USE_OWN_TR1_TUPLE=1
  267.         # boost::thread is called boost_thread-mt to mark multithreading on OS X
  268.         LIBRARIES += boost_thread-mt
  269.         # we need to explicitly ask for the rpath to be obeyed
  270.         ORIGIN := @loader_path
  271.         VERSIONFLAGS += -Wl,-install_name,@rpath/$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib
  272. else
  273.         ORIGIN := \$ORIGIN
  274. endif

  275. # Custom compiler
  276. ifdef CUSTOM_CXX
  277.         CXX := $(CUSTOM_CXX)
  278. endif

  279. # Static linking
  280. ifneq (,$(findstring clang++,$(CXX)))
  281.         STATIC_LINK_COMMAND := -Wl,-force_load $(STATIC_NAME)
  282. else ifneq (,$(findstring g++,$(CXX)))
  283.         STATIC_LINK_COMMAND := -Wl,--whole-archive $(STATIC_NAME) -Wl,--no-whole-archive
  284. else
  285.   # The following line must not be indented with a tab, since we are not inside a target
  286.   $(error Cannot static link with the $(CXX) compiler)
  287. endif

  288. # Debugging
  289. ifeq ($(DEBUG), 1)
  290.         COMMON_FLAGS += -DDEBUG -g -O0
  291.         NVCCFLAGS += -G
  292. else
  293.         COMMON_FLAGS += -DNDEBUG -O2
  294. endif

  295. # cuDNN acceleration configuration.
  296. ifeq ($(USE_CUDNN), 1)
  297.         LIBRARIES += cudnn
  298.         COMMON_FLAGS += -DUSE_CUDNN
  299. endif

  300. # configure IO libraries
  301. ifeq ($(USE_OPENCV), 1)
  302.         COMMON_FLAGS += -DUSE_OPENCV
  303. endif
  304. ifeq ($(USE_LEVELDB), 1)
  305.         COMMON_FLAGS += -DUSE_LEVELDB
  306. endif
  307. ifeq ($(USE_LMDB), 1)
  308.         COMMON_FLAGS += -DUSE_LMDB
  309. ifeq ($(ALLOW_LMDB_NOLOCK), 1)
  310.         COMMON_FLAGS += -DALLOW_LMDB_NOLOCK
  311. endif
  312. endif

  313. # CPU-only configuration
  314. ifeq ($(CPU_ONLY), 1)
  315.         OBJS := $(PROTO_OBJS) $(CXX_OBJS)
  316.         TEST_OBJS := $(TEST_CXX_OBJS)
  317.         TEST_BINS := $(TEST_CXX_BINS)
  318.         ALL_WARNS := $(ALL_CXX_WARNS)
  319.         TEST_FILTER := --gtest_filter="-*GPU*"
  320.         COMMON_FLAGS += -DCPU_ONLY
  321. endif

  322. # Python layer support
  323. ifeq ($(WITH_PYTHON_LAYER), 1)
  324.         COMMON_FLAGS += -DWITH_PYTHON_LAYER
  325.         LIBRARIES += $(PYTHON_LIBRARIES)
  326. endif

  327. # BLAS configuration (default = ATLAS)
  328. BLAS ?= atlas
  329. ifeq ($(BLAS), mkl)
  330.         # MKL
  331.         LIBRARIES += mkl_rt
  332.         COMMON_FLAGS += -DUSE_MKL
  333.         MKLROOT ?= /opt/intel/mkl
  334.         BLAS_INCLUDE ?= $(MKLROOT)/include
  335.         BLAS_LIB ?= $(MKLROOT)/lib $(MKLROOT)/lib/intel64
  336. else ifeq ($(BLAS), open)
  337.         # OpenBLAS
  338.         LIBRARIES += openblas
  339. else
  340.         # ATLAS
  341.         ifeq ($(LINUX), 1)
  342.                 ifeq ($(BLAS), atlas)
  343.                         # Linux simply has cblas and atlas
  344.                         LIBRARIES += cblas atlas
  345.                 endif
  346.         else ifeq ($(OSX), 1)
  347.                 # OS X packages atlas as the vecLib framework
  348.                 LIBRARIES += cblas
  349.                 # 10.10 has accelerate while 10.9 has veclib
  350.                 XCODE_CLT_VER := $(shell pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep 'version' | sed 's/[^0-9]*\([0-9]\).*/\1/')
  351.                 XCODE_CLT_GEQ_7 := $(shell [ $(XCODE_CLT_VER) -gt 6 ] && echo 1)
  352.                 XCODE_CLT_GEQ_6 := $(shell [ $(XCODE_CLT_VER) -gt 5 ] && echo 1)
  353.                 ifeq ($(XCODE_CLT_GEQ_7), 1)
  354.                         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
  355.                 else ifeq ($(XCODE_CLT_GEQ_6), 1)
  356.                         BLAS_INCLUDE ?= /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
  357.                         LDFLAGS += -framework Accelerate
  358.                 else
  359.                         BLAS_INCLUDE ?= /System/Library/Frameworks/vecLib.framework/Versions/Current/Headers/
  360.                         LDFLAGS += -framework vecLib
  361.                 endif
  362.         endif
  363. endif
  364. INCLUDE_DIRS += $(BLAS_INCLUDE)
  365. LIBRARY_DIRS += $(BLAS_LIB)

  366. LIBRARY_DIRS += $(LIB_BUILD_DIR)

  367. # Automatic dependency generation (nvcc is handled separately)
  368. CXXFLAGS += -MMD -MP

  369. # Complete build flags.
  370. COMMON_FLAGS += $(foreach includedir,$(INCLUDE_DIRS),-isystem $(includedir))
  371. CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)
  372. NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
  373. # mex may invoke an older gcc that is too liberal with -Wuninitalized
  374. MATLAB_CXXFLAGS := $(CXXFLAGS) -Wno-uninitialized
  375. LINKFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)

  376. USE_PKG_CONFIG ?= 0
  377. ifeq ($(USE_PKG_CONFIG), 1)
  378.         PKG_CONFIG := $(shell pkg-config opencv --libs)
  379. else
  380.         PKG_CONFIG :=
  381. endif
  382. LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(PKG_CONFIG) \
  383.                 $(foreach library,$(LIBRARIES),-l$(library))
  384. PYTHON_LDFLAGS := $(LDFLAGS) $(foreach library,$(PYTHON_LIBRARIES),-l$(library))

  385. # 'superclean' target recursively* deletes all files ending with an extension
  386. # in $(SUPERCLEAN_EXTS) below.  This may be useful if you've built older
  387. # versions of Caffe that do not place all generated files in a location known
  388. # to the 'clean' target.
  389. #
  390. # 'supercleanlist' will list the files to be deleted by make superclean.
  391. #
  392. # * Recursive with the exception that symbolic links are never followed, per the
  393. # default behavior of 'find'.
  394. SUPERCLEAN_EXTS := .so .a .o .bin .testbin .pb.cc .pb.h _pb2.py .cuo

  395. # Set the sub-targets of the 'everything' target.
  396. EVERYTHING_TARGETS := all py$(PROJECT) test warn lint
  397. # Only build matcaffe as part of "everything" if MATLAB_DIR is specified.
  398. ifneq ($(MATLAB_DIR),)
  399.         EVERYTHING_TARGETS += mat$(PROJECT)
  400. endif

  401. ##############################
  402. # Define build targets
  403. ##############################
  404. .PHONY: all lib test clean docs linecount lint lintclean tools examples $(DIST_ALIASES) \
  405.         py mat py$(PROJECT) mat$(PROJECT) proto runtest \
  406.         superclean supercleanlist supercleanfiles warn everything

  407. all: lib tools examples

  408. lib: $(STATIC_NAME) $(DYNAMIC_NAME)

  409. everything: $(EVERYTHING_TARGETS)

  410. linecount:
  411.         cloc --read-lang-def=$(PROJECT).cloc \
  412.                 src/$(PROJECT) include/$(PROJECT) tools examples \
  413.                 python matlab

  414. lint: $(EMPTY_LINT_REPORT)

  415. lintclean:
  416.         @ $(RM) -r $(LINT_OUTPUT_DIR) $(EMPTY_LINT_REPORT) $(NONEMPTY_LINT_REPORT)

  417. docs: $(DOXYGEN_OUTPUT_DIR)
  418.         @ cd ./docs ; ln -sfn ../$(DOXYGEN_OUTPUT_DIR)/html doxygen

  419. $(DOXYGEN_OUTPUT_DIR): $(DOXYGEN_CONFIG_FILE) $(DOXYGEN_SOURCES)
  420.         $(DOXYGEN_COMMAND) $(DOXYGEN_CONFIG_FILE)

  421. $(EMPTY_LINT_REPORT): $(LINT_OUTPUTS) | $(BUILD_DIR)
  422.         @ cat $(LINT_OUTPUTS) > $@
  423.         @ if [ -s "$@" ]; then \
  424.                 cat $@; \
  425.                 mv $@ $(NONEMPTY_LINT_REPORT); \
  426.                 echo "Found one or more lint errors."; \
  427.                 exit 1; \
  428.           fi; \
  429.           $(RM) $(NONEMPTY_LINT_REPORT); \
  430.           echo "No lint errors!";

  431. $(LINT_OUTPUTS): $(LINT_OUTPUT_DIR)/%.lint.txt : % $(LINT_SCRIPT) | $(LINT_OUTPUT_DIR)
  432.         @ mkdir -p $(dir $@)
  433.         @ python $(LINT_SCRIPT) [        DISCUZ_CODE_3        ]lt; 2>&1 \
  434.                 | grep -v "^Done processing " \
  435.                 | grep -v "^Total errors found: 0" \
  436.                 > $@ \
  437.                 || true

  438. test: $(TEST_ALL_BIN) $(TEST_ALL_DYNLINK_BIN) $(TEST_BINS)

  439. tools: $(TOOL_BINS) $(TOOL_BIN_LINKS)

  440. examples: $(EXAMPLE_BINS)

  441. py$(PROJECT): py

  442. py: $(PY$(PROJECT)_SO) $(PROTO_GEN_PY)

  443. $(PY$(PROJECT)_SO): $(PY$(PROJECT)_SRC) $(PY$(PROJECT)_HXX) | $(DYNAMIC_NAME)
  444.         @ echo CXX/LD -o $@ [        DISCUZ_CODE_3        ]lt;
  445.         $(Q)$(CXX) -shared -o $@ $(PY$(PROJECT)_SRC) \
  446.                 -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(PYTHON_LDFLAGS) \
  447.                 -Wl,-rpath,$(ORIGIN)/../../build/lib

  448. mat$(PROJECT): mat

  449. mat: $(MAT$(PROJECT)_SO)

  450. $(MAT$(PROJECT)_SO): $(MAT$(PROJECT)_SRC) $(STATIC_NAME)
  451.         @ if [ -z "$(MATLAB_DIR)" ]; then \
  452.                 echo "MATLAB_DIR must be specified in $(CONFIG_FILE)" \
  453.                         "to build mat$(PROJECT)."; \
  454.                 exit 1; \
  455.         fi
  456.         @ echo MEX [        DISCUZ_CODE_3        ]lt;
  457.         $(Q)$(MATLAB_DIR)/bin/mex $(MAT$(PROJECT)_SRC) \
  458.                         CXX="$(CXX)" \
  459.                         CXXFLAGS="\$CXXFLAGS $(MATLAB_CXXFLAGS)" \
  460.                         CXXLIBS="\$CXXLIBS $(STATIC_LINK_COMMAND) $(LDFLAGS)" -output $@
  461.         @ if [ -f "$(PROJECT)_.d" ]; then \
  462.                 mv -f $(PROJECT)_.d $(BUILD_DIR)/${MAT$(PROJECT)_SO:.$(MAT_SO_EXT)=.d}; \
  463.         fi

  464. runtest: $(TEST_ALL_BIN)
  465.         $(TOOL_BUILD_DIR)/caffe
  466.         $(TEST_ALL_BIN) $(TEST_GPUID) --gtest_shuffle $(TEST_FILTER)

  467. pytest: py
  468.         cd python; python -m unittest discover -s caffe/test

  469. mattest: mat
  470.         cd matlab; $(MATLAB_DIR)/bin/matlab -nodisplay -r 'caffe.run_tests(), exit()'

  471. warn: $(EMPTY_WARN_REPORT)

  472. $(EMPTY_WARN_REPORT): $(ALL_WARNS) | $(BUILD_DIR)
  473.         @ cat $(ALL_WARNS) > $@
  474.         @ if [ -s "$@" ]; then \
  475.                 cat $@; \
  476.                 mv $@ $(NONEMPTY_WARN_REPORT); \
  477.                 echo "Compiler produced one or more warnings."; \
  478.                 exit 1; \
  479.           fi; \
  480.           $(RM) $(NONEMPTY_WARN_REPORT); \
  481.           echo "No compiler warnings!";

  482. $(ALL_WARNS): %.o.$(WARNS_EXT) : %.o

  483. $(BUILD_DIR_LINK): $(BUILD_DIR)/.linked

  484. # Create a target ".linked" in this BUILD_DIR to tell Make that the "build" link
  485. # is currently correct, then delete the one in the OTHER_BUILD_DIR in case it
  486. # exists and $(DEBUG) is toggled later.
  487. $(BUILD_DIR)/.linked:
  488.         @ mkdir -p $(BUILD_DIR)
  489.         @ $(RM) $(OTHER_BUILD_DIR)/.linked
  490.         @ $(RM) -r $(BUILD_DIR_LINK)
  491.         @ ln -s $(BUILD_DIR) $(BUILD_DIR_LINK)
  492.         @ touch $@

  493. $(ALL_BUILD_DIRS): | $(BUILD_DIR_LINK)
  494.         @ mkdir -p $@

  495. $(DYNAMIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)
  496.         @ echo LD -o $@
  497.         $(Q)$(CXX) -shared -o $@ $(OBJS) $(VERSIONFLAGS) $(LINKFLAGS) $(LDFLAGS)
  498.         @ cd $(BUILD_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT);   ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT)

  499. $(STATIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)
  500.         @ echo AR -o $@
  501.         $(Q)ar rcs $@ $(OBJS)

  502. $(BUILD_DIR)/%.o: %.cpp | $(ALL_BUILD_DIRS)
  503.         @ echo CXX [        DISCUZ_CODE_3        ]lt;
  504.         $(Q)$(CXX) [        DISCUZ_CODE_3        ]lt; $(CXXFLAGS) -c -o $@ 2> $@.$(WARNS_EXT) \
  505.                 || (cat $@.$(WARNS_EXT); exit 1)
  506.         @ cat $@.$(WARNS_EXT)

  507. $(PROTO_BUILD_DIR)/%.pb.o: $(PROTO_BUILD_DIR)/%.pb.cc $(PROTO_GEN_HEADER) \
  508.                 | $(PROTO_BUILD_DIR)
  509.         @ echo CXX [        DISCUZ_CODE_3        ]lt;
  510.         $(Q)$(CXX) [        DISCUZ_CODE_3        ]lt; $(CXXFLAGS) -c -o $@ 2> $@.$(WARNS_EXT) \
  511.                 || (cat $@.$(WARNS_EXT); exit 1)
  512.         @ cat $@.$(WARNS_EXT)

  513. $(BUILD_DIR)/cuda/%.o: %.cu | $(ALL_BUILD_DIRS)
  514.         @ echo NVCC [        DISCUZ_CODE_3        ]lt;
  515.         $(Q)$(CUDA_DIR)/bin/nvcc $(NVCCFLAGS) $(CUDA_ARCH) -M [        DISCUZ_CODE_3        ]lt; -o ${@:.o=.d} \
  516.                 -odir $(@D)
  517.         $(Q)$(CUDA_DIR)/bin/nvcc $(NVCCFLAGS) $(CUDA_ARCH) -c [        DISCUZ_CODE_3        ]lt; -o $@ 2> $@.$(WARNS_EXT) \
  518.                 || (cat $@.$(WARNS_EXT); exit 1)
  519.         @ cat $@.$(WARNS_EXT)

  520. $(TEST_ALL_BIN): $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \
  521.                 | $(DYNAMIC_NAME) $(TEST_BIN_DIR)
  522.         @ echo CXX/LD -o $@ [        DISCUZ_CODE_3        ]lt;
  523.         $(Q)$(CXX) $(TEST_MAIN_SRC) $(TEST_OBJS) $(GTEST_OBJ) \
  524.                 -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib

  525. $(TEST_CU_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CU_BUILD_DIR)/%.o \
  526.         $(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR)
  527.         @ echo LD [        DISCUZ_CODE_3        ]lt;
  528.         $(Q)$(CXX) $(TEST_MAIN_SRC) [        DISCUZ_CODE_3        ]lt; $(GTEST_OBJ) \
  529.                 -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib

  530. $(TEST_CXX_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CXX_BUILD_DIR)/%.o \
  531.         $(GTEST_OBJ) | $(DYNAMIC_NAME) $(TEST_BIN_DIR)
  532.         @ echo LD [        DISCUZ_CODE_3        ]lt;
  533.         $(Q)$(CXX) $(TEST_MAIN_SRC) [        DISCUZ_CODE_3        ]lt; $(GTEST_OBJ) \
  534.                 -o $@ $(LINKFLAGS) $(LDFLAGS) -l$(LIBRARY_NAME) -Wl,-rpath,$(ORIGIN)/../lib

  535. # Target for extension-less symlinks to tool binaries with extension '*.bin'.
  536. $(TOOL_BUILD_DIR)/%: $(TOOL_BUILD_DIR)/%.bin | $(TOOL_BUILD_DIR)
  537.         @ $(RM) $@
  538.         @ ln -s $(notdir [        DISCUZ_CODE_3        ]lt;) $@

  539. $(TOOL_BINS): %.bin : %.o | $(DYNAMIC_NAME)
  540.         @ echo CXX/LD -o $@
  541.         $(Q)$(CXX) [        DISCUZ_CODE_3        ]lt; -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \
  542.                 -Wl,-rpath,$(ORIGIN)/../lib

  543. $(EXAMPLE_BINS): %.bin : %.o | $(DYNAMIC_NAME)
  544.         @ echo CXX/LD -o $@
  545.         $(Q)$(CXX) [        DISCUZ_CODE_3        ]lt; -o $@ $(LINKFLAGS) -l$(LIBRARY_NAME) $(LDFLAGS) \
  546.                 -Wl,-rpath,$(ORIGIN)/../../lib

  547. proto: $(PROTO_GEN_CC) $(PROTO_GEN_HEADER)

  548. $(PROTO_BUILD_DIR)/%.pb.cc $(PROTO_BUILD_DIR)/%.pb.h : \
  549.                 $(PROTO_SRC_DIR)/%.proto | $(PROTO_BUILD_DIR)
  550.         @ echo PROTOC [        DISCUZ_CODE_3        ]lt;
  551.         $(Q)protoc --proto_path=$(PROTO_SRC_DIR) --cpp_out=$(PROTO_BUILD_DIR) [        DISCUZ_CODE_3        ]lt;

  552. $(PY_PROTO_BUILD_DIR)/%_pb2.py : $(PROTO_SRC_DIR)/%.proto \
  553.                 $(PY_PROTO_INIT) | $(PY_PROTO_BUILD_DIR)
  554.         @ echo PROTOC \(python\) [        DISCUZ_CODE_3        ]lt;
  555.         $(Q)protoc --proto_path=$(PROTO_SRC_DIR) --python_out=$(PY_PROTO_BUILD_DIR) [        DISCUZ_CODE_3        ]lt;

  556. $(PY_PROTO_INIT): | $(PY_PROTO_BUILD_DIR)
  557.         touch $(PY_PROTO_INIT)

  558. clean:
  559.         @- $(RM) -rf $(ALL_BUILD_DIRS)
  560.         @- $(RM) -rf $(OTHER_BUILD_DIR)
  561.         @- $(RM) -rf $(BUILD_DIR_LINK)
  562.         @- $(RM) -rf $(DISTRIBUTE_DIR)
  563.         @- $(RM) $(PY$(PROJECT)_SO)
  564.         @- $(RM) $(MAT$(PROJECT)_SO)

  565. supercleanfiles:
  566.         $(eval SUPERCLEAN_FILES := $(strip \
  567.                         $(foreach ext,$(SUPERCLEAN_EXTS), $(shell find . -name '*$(ext)' \
  568.                         -not -path './data/*'))))

  569. supercleanlist: supercleanfiles
  570.         @ \
  571.         if [ -z "$(SUPERCLEAN_FILES)" ]; then \
  572.                 echo "No generated files found."; \
  573.         else \
  574.                 echo $(SUPERCLEAN_FILES) | tr ' ' '\n'; \
  575.         fi

  576. superclean: clean supercleanfiles
  577.         @ \
  578.         if [ -z "$(SUPERCLEAN_FILES)" ]; then \
  579.                 echo "No generated files found."; \
  580.         else \
  581.                 echo "Deleting the following generated files:"; \
  582.                 echo $(SUPERCLEAN_FILES) | tr ' ' '\n'; \
  583.                 $(RM) $(SUPERCLEAN_FILES); \
  584.         fi

  585. $(DIST_ALIASES): $(DISTRIBUTE_DIR)

  586. $(DISTRIBUTE_DIR): all py | $(DISTRIBUTE_SUBDIRS)
  587.         # add proto
  588.         cp -r src/caffe/proto $(DISTRIBUTE_DIR)/
  589.         # add include
  590.         cp -r include $(DISTRIBUTE_DIR)/
  591.         mkdir -p $(DISTRIBUTE_DIR)/include/caffe/proto
  592.         cp $(PROTO_GEN_HEADER_SRCS) $(DISTRIBUTE_DIR)/include/caffe/proto
  593.         # add tool and example binaries
  594.         cp $(TOOL_BINS) $(DISTRIBUTE_DIR)/bin
  595.         cp $(EXAMPLE_BINS) $(DISTRIBUTE_DIR)/bin
  596.         # add libraries
  597.         cp $(STATIC_NAME) $(DISTRIBUTE_DIR)/lib
  598.         install -m 644 $(DYNAMIC_NAME) $(DISTRIBUTE_DIR)/lib
  599.         cd $(DISTRIBUTE_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT);   ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT)
  600.         # add python - it's not the standard way, indeed...
  601.         cp -r python $(DISTRIBUTE_DIR)/python

  602. -include $(DEPS)
复制代码



让天下人人学会人工智能!人工智能的前景一片大好!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|人工智能工程师的摇篮 ( 湘ICP备2020019608号-1 )

GMT+8, 2024-4-25 19:59 , Processed in 0.170879 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表