Skip to content

Commit 1431f46

Browse files
authored
Merge pull request #475 from drnikolaev/caffe-0.17
0.16.6 release
2 parents 52ccc5c + cc79125 commit 1431f46

File tree

211 files changed

+1723
-6042
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+1723
-6042
lines changed

.travis.yml

+4-8
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,16 @@ env:
1212
# envvar defaults:
1313
# WITH_CMAKE: false
1414
# WITH_PYTHON3: false
15-
# WITH_IO: true
16-
# WITH_CUDA: false
15+
# WITH_CUDA: const true since v0.17
1716
# WITH_CUDNN: false
1817
- BUILD_NAME="default-make"
1918
# - BUILD_NAME="python3-make" WITH_PYTHON3=true
20-
- BUILD_NAME="no-io-make" WITH_IO=false
21-
- BUILD_NAME="cuda-make" WITH_CUDA=true
22-
- BUILD_NAME="cudnn-make" WITH_CUDA=true WITH_CUDNN=true
19+
- BUILD_NAME="cudnn-make" WITH_CUDNN=true
2320

2421
- BUILD_NAME="default-cmake" WITH_CMAKE=true
2522
- BUILD_NAME="python3-cmake" WITH_CMAKE=true WITH_PYTHON3=true
26-
- BUILD_NAME="no-io-cmake" WITH_CMAKE=true WITH_IO=false
27-
- BUILD_NAME="cuda-cmake" WITH_CMAKE=true WITH_CUDA=true
28-
- BUILD_NAME="cudnn-cmake" WITH_CMAKE=true WITH_CUDA=true WITH_CUDNN=true
23+
- BUILD_NAME="cudnn-cmake" WITH_CMAKE=true WITH_CUDNN=true
24+
- BUILD_NAME="cudnn-python3-cmake" WITH_CMAKE=true WITH_CUDNN=true WITH_PYTHON3=true
2925

3026
cache:
3127
apt: true

3rdparty/half_float/half.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
#include "caffe/util/gpu_math_functions.cuh"
202202
#endif
203203

204-
#if !defined(CPU_ONLY) && defined(__CUDA_ARCH__)
204+
#if defined(__CUDA_ARCH__)
205205
#define CAFFE_UTIL_HD __host__ __device__
206206
#define CAFFE_UTIL_IHD __inline__ __host__ __device__
207207
#else

CMakeLists.txt

+8-9
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,20 @@ include(cmake/Summary.cmake)
2929
include(cmake/ConfigGen.cmake)
3030

3131
# ---[ Options
32-
caffe_option(CPU_ONLY "Build Caffe without CUDA support" OFF) # TODO: rename to USE_CUDA
33-
caffe_option(USE_CUDNN "Build Caffe with cuDNN library support" ON IF NOT CPU_ONLY)
32+
caffe_option(USE_CUDNN "Build Caffe with cuDNN library support" ON)
3433

3534
# USE_NCCL: Build Caffe with NCCL Library support
3635
# Regular ON/OFF option doesn't work here because we need to recognize 3 states:
3736
# 1. User didn't set USE_NCCL option =>
38-
# 1.1 If CPU_ONLY is ON we do nothing.
39-
# 1.2 If CPU_ONLY is OFF we *quietly* try to find it and use if found; do nothing otherwise.
37+
# 1.1 We *quietly* try to find it and use if found; do nothing otherwise.
4038
# 2. User explicitly set USE_NCCL=ON option =>
41-
# 1.1 If CPU_ONLY is ON we do nothing (it's higher priority).
42-
# 2.1 If CPU_ONLY is OFF we try to find it with *required* option, thus CMake fails if not found.
39+
# 1.1 We try to find it with *required* option, thus CMake fails if not found.
4340
# 3. User explicitly set USE_NCCL=OFF option => we do nothing.
44-
SET(USE_NCCL)
45-
if(DEFINED USE_NCCL)
46-
STRING(TOUPPER "${USE_NCCL}" USE_NCCL)
41+
set(USE_NCCL "NONE" CACHE STRING "Link Caffe with NCCL Library for Multi-GPU support")
42+
if(USE_NCCL STREQUAL "NONE")
43+
set(USE_NCCL_SET OFF)
44+
else()
45+
set(USE_NCCL_SET ON)
4746
endif()
4847

4948
caffe_option(BUILD_SHARED_LIBS "Build shared libraries" ON)

Makefile

+33-35
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ THIRDPARTY_DIR := ./3rdparty
2828

2929
# All of the directories containing code.
3030
SRC_DIRS := $(shell find * -type d -exec bash -c "find {} -maxdepth 1 \
31-
\( -name '*.cpp' -o -name '*.proto' \) | grep -q ." \; -print)
31+
\( -name '*.cpp' -o -name '*.proto' \) | grep -q ." \; -print 2>/dev/null)
3232

3333
# The target shared library name
3434
LIBRARY_NAME := $(PROJECT)$(LIBRARY_NAME_SUFFIX)
@@ -179,19 +179,17 @@ CUDA_LIB_DIR :=
179179
# add <cuda>/lib64 only if it exists
180180
ifneq ("$(wildcard $(CUDA_DIR)/lib64)","")
181181
CUDA_LIB_DIR += $(CUDA_DIR)/lib64
182-
CUDA_LIB_DIR += /usr/lib/nvidia-384 /usr/lib/nvidia-381 /usr/lib/nvidia-375 /usr/lib/nvidia-367 /usr/lib/nvidia-361 /usr/lib/nvidia-352
182+
CUDA_LIB_DIR += /usr/lib/nvidia-396 /usr/lib/nvidia-390 /usr/lib/nvidia-387 /usr/lib/nvidia-384 /usr/lib/nvidia-381 /usr/lib/nvidia-375 /usr/lib/nvidia-367 /usr/lib/nvidia-361 /usr/lib/nvidia-352
183183
endif
184184
CUDA_LIB_DIR += $(CUDA_DIR)/lib
185185

186-
INCLUDE_DIRS += $(BUILD_INCLUDE_DIR) ./src ./include $(THIRDPARTY_DIR)
187-
ifneq ($(CPU_ONLY), 1)
188-
INCLUDE_DIRS += $(CUDA_INCLUDE_DIR)
189-
LIBRARY_DIRS += $(CUDA_LIB_DIR)
190-
LIBRARIES := cudart cublas curand
186+
INCLUDE_DIRS += $(BUILD_INCLUDE_DIR) ./src ./include $(THIRDPARTY_DIR) /usr/include/hdf5/serial
187+
INCLUDE_DIRS += $(CUDA_INCLUDE_DIR)
188+
LIBRARY_DIRS += $(CUDA_LIB_DIR)
189+
LIBRARIES := cudart cublas curand
191190
ifneq ($(NO_NVML), 1)
192191
LIBRARIES += nvidia-ml
193192
endif
194-
endif
195193

196194
# Note: libturbojpeg has a packaging bug. Workaround:
197195
# $ sudo ln -s /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0 /usr/lib/x86_64-linux-gnu/libturbojpeg.so
@@ -222,7 +220,16 @@ ifeq ($(USE_OPENCV), 1)
222220
endif
223221

224222
endif
225-
PYTHON_LIBRARIES ?= boost_python python2.7 boost_regex
223+
224+
python_version_full := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))
225+
python_version_major := $(word 1,${python_version_full})
226+
python_version_minor := $(word 2,${python_version_full})
227+
python_version_patch := $(word 3,${python_version_full})
228+
ifeq ($(python_version_major), 3)
229+
python_lib_suffix := m
230+
endif
231+
232+
PYTHON_LIBRARIES ?= boost_python-py${python_version_major}${python_version_minor} python${python_version_major}.${python_version_minor}${python_lib_suffix} boost_regex
226233
WARNINGS := -Wall -Wno-sign-compare
227234

228235
##############################
@@ -294,23 +301,21 @@ endif
294301
# libstdc++ for NVCC compatibility on OS X >= 10.9 with CUDA < 7.0
295302
ifeq ($(OSX), 1)
296303
CXX := /usr/bin/clang++
297-
ifneq ($(CPU_ONLY), 1)
298-
CUDA_VERSION := $(shell $(CUDA_DIR)/bin/nvcc -V | grep -o 'release [0-9.]*' | grep -o '[0-9.]*')
299-
ifeq ($(shell echo | awk '{exit $(CUDA_VERSION) < 7.0;}'), 1)
300-
CXXFLAGS += -stdlib=libstdc++
301-
LINKFLAGS += -stdlib=libstdc++
302-
endif
303-
# clang throws this warning for cuda headers
304-
WARNINGS += -Wno-unneeded-internal-declaration
305-
# 10.11 strips DYLD_* env vars so link CUDA (rpath is available on 10.5+)
306-
OSX_10_OR_LATER := $(shell [ $(OSX_MAJOR_VERSION) -ge 10 ] && echo true)
307-
OSX_10_5_OR_LATER := $(shell [ $(OSX_MINOR_VERSION) -ge 5 ] && echo true)
308-
ifeq ($(OSX_10_OR_LATER),true)
309-
ifeq ($(OSX_10_5_OR_LATER),true)
310-
LDFLAGS += -Wl,-rpath,$(CUDA_LIB_DIR)
311-
endif
312-
endif
313-
endif
304+
CUDA_VERSION := $(shell $(CUDA_DIR)/bin/nvcc -V | grep -o 'release [0-9.]*' | grep -o '[0-9.]*')
305+
ifeq ($(shell echo | awk '{exit $(CUDA_VERSION) < 7.0;}'), 1)
306+
CXXFLAGS += -stdlib=libstdc++
307+
LINKFLAGS += -stdlib=libstdc++
308+
endif
309+
# clang throws this warning for cuda headers
310+
WARNINGS += -Wno-unneeded-internal-declaration
311+
# 10.11 strips DYLD_* env vars so link CUDA (rpath is available on 10.5+)
312+
OSX_10_OR_LATER := $(shell [ $(OSX_MAJOR_VERSION) -ge 10 ] && echo true)
313+
OSX_10_5_OR_LATER := $(shell [ $(OSX_MINOR_VERSION) -ge 5 ] && echo true)
314+
ifeq ($(OSX_10_OR_LATER),true)
315+
ifeq ($(OSX_10_5_OR_LATER),true)
316+
LDFLAGS += -Wl,-rpath,$(CUDA_LIB_DIR)
317+
endif
318+
endif
314319
# gtest needs to use its own tuple to not conflict with clang
315320
COMMON_FLAGS += -DGTEST_USE_OWN_TR1_TUPLE=1
316321
# boost::thread is called boost_thread-mt to mark multithreading on OS X
@@ -376,15 +381,8 @@ ifeq ($(ALLOW_LMDB_NOLOCK), 1)
376381
endif
377382
endif
378383

379-
# CPU-only configuration
380-
ifeq ($(CPU_ONLY), 1)
381-
OBJS := $(PROTO_OBJS) $(CXX_OBJS)
382-
TEST_OBJS := $(TEST_CXX_OBJS)
383-
TEST_BINS := $(TEST_CXX_BINS)
384-
ALL_WARNS := $(ALL_CXX_WARNS)
385-
TEST_FILTER := --gtest_filter="-*GPU*"
386-
COMMON_FLAGS += -DCPU_ONLY
387-
endif
384+
# New place for HDF5
385+
LIBRARY_DIRS += /usr/lib/x86_64-linux-gnu/hdf5/serial
388386

389387
ifeq ($(NO_NVML), 1)
390388
COMMON_FLAGS += -DNO_NVML=1

Makefile.config.example

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
# See https://github.com/NVIDIA/nccl
1010
# USE_NCCL := 1
1111

12-
# CPU-only switch (uncomment to build without GPU support).
13-
# Disables FP16 support.
14-
# CPU_ONLY := 1
1512
# Builds tests with 16 bit float support in addition to 32 and 64 bit.
1613
# TEST_FP16 := 1
1714

NVCaffe-User-Guide.pdf

1.59 MB
Binary file not shown.

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Here are the major features:
1313
* **Mixed-precision support**. It allows to store and/or compute data in either
1414
64, 32 or 16 bit formats. Precision can be defined for every layer (forward and
1515
backward passes might be different too), or it can be set for the whole Net.
16-
* **Integration with [cuDNN](https://developer.nvidia.com/cudnn) v6**.
16+
* **Integration with [cuDNN](https://developer.nvidia.com/cudnn) v7**.
1717
* **Automatic selection of the best cuDNN convolution algorithm**.
18-
* **Integration with v1.3.4 of [NCCL library](https://github.com/NVIDIA/nccl)**
18+
* **Integration with v2.2 of [NCCL library](https://github.com/NVIDIA/nccl)**
1919
for improved multi-GPU scaling.
2020
* **Optimized GPU memory management** for data and parameters storage, I/O buffers
2121
and workspace for convolutional layers.
@@ -40,3 +40,11 @@ Please cite Caffe in your publications if it helps your research:
4040
Title = {Caffe: Convolutional Architecture for Fast Feature Embedding},
4141
Year = {2014}
4242
}
43+
44+
## Useful notes
45+
46+
Libturbojpeg library is used since 0.16.5. It has a packaging bug. Please execute the following (required for Makefile, optional for CMake):
47+
```
48+
sudo apt-get install libturbojpeg libturbojpeg-dev
49+
sudo ln -s /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0.1.0 /usr/lib/x86_64-linux-gnu/libturbojpeg.so
50+
```

cmake/Cuda.cmake

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
if(CPU_ONLY)
2-
return()
3-
endif()
4-
51
# Known NVIDIA GPU achitectures Caffe can be compiled for.
62
# This list will be used for CUDA_ARCH_NAME = All option
73
set(Caffe_known_gpu_archs "30 35 50 52 60 61 70")

cmake/Dependencies.cmake

+20-16
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
# This list is required for static linking and exported to CaffeConfig.cmake
22
set(Caffe_LINKER_LIBS "")
33

4-
find_package(PythonInterp ${python_version})
5-
64
# ---[ Boost
7-
find_package(Boost 1.54 REQUIRED COMPONENTS system thread filesystem regex python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
8-
set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_FOUND})
5+
find_package(Boost 1.54 REQUIRED COMPONENTS system thread filesystem regex)
96
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
107
list(APPEND Caffe_LINKER_LIBS ${Boost_LIBRARIES})
118

@@ -64,12 +61,7 @@ list(APPEND Caffe_LINKER_LIBS ${JPEGTurbo_LIBRARIES})
6461
# ---[ CUDA
6562
include(cmake/Cuda.cmake)
6663
if(NOT HAVE_CUDA)
67-
if(CPU_ONLY)
68-
message(STATUS "-- CUDA is disabled. Building without it...")
69-
else()
70-
message(WARNING "-- CUDA is not detected by cmake. Building without it...")
71-
endif()
72-
64+
message(SEND_ERROR "-- CUDA is not detected by cmake. Building without it...")
7365
# TODO: remove this not cross platform define in future. Use caffe_config.h instead.
7466
add_definitions(-DCPU_ONLY)
7567
endif()
@@ -113,6 +105,20 @@ endif()
113105

114106
# ---[ Python
115107
if(BUILD_python)
108+
find_package(PythonInterp ${python_version})
109+
110+
find_library(Boost_PYTHON_FOUND NAMES
111+
python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}
112+
boost_python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}
113+
boost_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}
114+
PATHS ${LIBDIR})
115+
if ("${Boost_PYTHON_FOUND}" STREQUAL "Boost_PYTHON_FOUND-NOTFOUND")
116+
message(SEND_ERROR "Could NOT find Boost Python Library")
117+
else()
118+
message(STATUS "Found Boost Python Library ${Boost_PYTHON_FOUND}")
119+
list(APPEND Caffe_LINKER_LIBS ${Boost_PYTHON_FOUND})
120+
endif()
121+
116122
find_package(PythonLibs ${python_version})
117123
find_package(NumPy 1.7.1)
118124
if(PYTHONLIBS_FOUND AND NUMPY_FOUND AND Boost_PYTHON_FOUND)
@@ -147,14 +153,12 @@ if(BUILD_docs)
147153
endif()
148154

149155
# ---[ NCCL
150-
if(DEFINED USE_NCCL)
151-
if(USE_NCCL AND NOT CPU_ONLY)
156+
if(USE_NCCL_SET)
157+
if(USE_NCCL)
152158
find_package(NCCL REQUIRED)
153159
endif()
154160
else()
155-
if(NOT CPU_ONLY)
156-
find_package(NCCL)
157-
endif()
161+
find_package(NCCL)
158162
endif()
159163
if(NCCL_FOUND)
160164
add_definitions(-DUSE_NCCL)
@@ -163,7 +167,7 @@ if(NCCL_FOUND)
163167
endif()
164168

165169
# ---[ NVML
166-
if(NOT CPU_ONLY AND NOT NO_NVML)
170+
if(NOT NO_NVML)
167171
find_package(NVML)
168172
endif()
169173
if(NVML_FOUND)

cmake/Summary.cmake

+7-7
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ function(caffe_print_configuration_summary)
113113
caffe_status(" BUILD_python : ${BUILD_python}")
114114
caffe_status(" BUILD_matlab : ${BUILD_matlab}")
115115
caffe_status(" BUILD_docs : ${BUILD_docs}")
116-
caffe_status(" CPU_ONLY : ${CPU_ONLY}")
117116
caffe_status(" USE_LEVELDB : ${USE_LEVELDB}")
118117
caffe_status(" USE_LMDB : ${USE_LMDB}")
119118
caffe_status(" ALLOW_LMDB_NOLOCK : ${ALLOW_LMDB_NOLOCK}")
@@ -145,13 +144,14 @@ function(caffe_print_configuration_summary)
145144
else()
146145
caffe_status(" cuDNN : Disabled")
147146
endif()
148-
if(NOT DEFINED USE_NCCL)
149-
caffe_status(" NCCL : " NCCL_FOUND THEN "Yes (ver. ${NCCL_VERSION})" ELSE "Not
150-
found")
151-
elseif(USE_NCCL)
152-
caffe_status(" NCCL : " NCCL_FOUND THEN "Yes (ver. ${NCCL_VERSION})" ELSE "Not found")
147+
if(USE_NCCL_SET)
148+
if(USE_NCCL)
149+
caffe_status(" NCCL : " NCCL_FOUND THEN "Yes (ver. ${NCCL_VERSION})" ELSE "Not found")
150+
else()
151+
caffe_status(" NCCL : Disabled")
152+
endif()
153153
else()
154-
caffe_status(" NCCL : Disabled")
154+
caffe_status(" NCCL : " NCCL_FOUND THEN "Yes (ver. ${NCCL_VERSION})" ELSE "Not found (not requested)")
155155
endif()
156156

157157
if(NVML_FOUND)

docs/installation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Pycaffe and Matcaffe interfaces have their own natural needs.
4949

5050
**cuDNN Caffe**: for fastest operation Caffe is accelerated by drop-in integration of [NVIDIA cuDNN](https://developer.nvidia.com/cudnn). To speed up your Caffe models, install cuDNN then uncomment the `USE_CUDNN := 1` flag in `Makefile.config` when installing Caffe. Acceleration is automatic. The current version is cuDNN v4; older versions are supported in older Caffe.
5151

52-
**CPU-only Caffe**: for cold-brewed CPU-only Caffe uncomment the `CPU_ONLY := 1` flag in `Makefile.config` to configure and build Caffe without CUDA. This is helpful for cloud or cluster deployment.
52+
**CPU-only Caffe**: not supported starting from v0.17. For older versions, for cold-brewed CPU-only Caffe uncomment the `CPU_ONLY := 1` flag in `Makefile.config` to configure and build Caffe without CUDA. This is helpful for cloud or cluster deployment.
5353

5454
### CUDA and BLAS
5555

examples/cpp_classification/classification.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,7 @@ Classifier::Classifier(const string& model_file,
4646
const string& trained_file,
4747
const string& mean_file,
4848
const string& label_file) {
49-
#ifdef CPU_ONLY
50-
Caffe::set_mode(Caffe::CPU);
51-
#else
5249
Caffe::set_mode(Caffe::GPU);
53-
#endif
54-
5550
/* Load the network. */
5651
net_.reset(new Net(model_file, TEST));
5752
net_->CopyTrainedLayersFrom(trained_file);

0 commit comments

Comments
 (0)