Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit f0f2713

Browse files
committed
Merge from remotes/internal/release_1.1.1
2 parents f6d01ef + b5e6707 commit f0f2713

File tree

274 files changed

+294634
-47391
lines changed

Some content is hidden

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

274 files changed

+294634
-47391
lines changed

CMakeLists.txt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,22 @@ caffe_option(ALLOW_LMDB_NOLOCK "Allow MDB_NOLOCK when reading LMDB files (only i
4444
caffe_option(USE_SYSTEMTAP "Build for SystemTap" OFF)
4545
caffe_option(PERFORMANCE_MONITORING "Build Caffe with PERFORMANCE_MONITORING " OFF)
4646
#caffe_option(USE_GITHUB_MKLDNN "Download and use MKL-DNN available on github" OFF)
47-
47+
caffe_option(CODE_COVERAGE "Build with code coverage instrumentation" OFF)
48+
caffe_option(CO_SIM "Build readonly cpu blob data/diff pycaffe interface" OFF)
49+
caffe_option(USE_MLSL "Build Caffe with Intel(r) Machine Learning Scaling Library for multinode training" ON)
50+
4851
# ---[ Dependencies
4952
include(cmake/MKLDNN.cmake)
5053
include(cmake/DLCP.cmake)
5154
include(cmake/Dependencies.cmake)
5255

56+
if(CODE_COVERAGE)
57+
# code coverage necessary
58+
include(CodeCoverage)
59+
APPEND_CCOV_COMPILER_FLAGS()
60+
endif()
61+
#end code coverage
62+
5363
# ---[ Flags
5464
if(UNIX OR APPLE)
5565

@@ -81,14 +91,16 @@ if(UNIX OR APPLE)
8191
# Same as above, with exception that ICC compilation crashes with -fPIE option, even
8292
# though it uses -pie linker option that require -fPIE during compilation. Checksec
8393
# shows that it generates correct PIE anyway if only -pie is provided.
84-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
94+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector -wd2196")
8595
# Auto enable SGD Fusion if use intel compiler
8696
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_SGD_FUSION")
8797
endif()
8898

8999
# Generic flags.
90100
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fno-operator-names -Wformat -Wformat-security -Wall")
91-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
101+
if(NOT CODE_COVERAGE)
102+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror")
103+
endif()
92104
# Dot not forward c++11 flag to GPU beucause it is not supported
93105
set( CUDA_PROPAGATE_HOST_FLAGS OFF )
94106
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2")

Makefile

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,14 +387,14 @@ endif
387387

388388
# Compiler flags
389389
ifneq (,$(findstring icpc,$(CXX)))
390-
CXX_HARDENING_FLAGS += -fstack-protector
390+
CXX_HARDENING_FLAGS += -fstack-protector -wd2196
391391
#Enable SGD FUSION if use intel compiler
392392
COMMON_FLAGS += -DENABLE_SGD_FUSION
393393

394394
else ifneq (,$(findstring clang++,$(CXX)))
395395
CXX_HARDENING_FLAGS += -fPIE -fstack-protector
396396
else ifneq (,$(findstring g++,$(CXX)))
397-
ifeq ($(shell echo | awk '{ print $(GCCVERSION) >= 4.9 }'), 1)
397+
ifeq ($(shell echo | awk '{print $(GCCVERSION) < 4.9;}'), 0)
398398
CXX_HARDENING_FLAGS += -fPIE -fstack-protector-strong
399399
#Enable SGD FUSION if gcc version >= 4.9
400400
COMMON_FLAGS += -DENABLE_SGD_FUSION
@@ -415,7 +415,7 @@ else
415415
endif
416416

417417
# Generic flags
418-
CXX_HARDENING_FLAGS += -fPIC -fno-operator-names -Wformat -Wformat-security -Wall
418+
CXX_HARDENING_FLAGS += -fPIC -fno-operator-names -Wformat -Wformat-security -Wall -Werror
419419
LINKER_EXEC_HARDENING_FLAGS += -pie
420420

421421
# Release-only flag
@@ -493,11 +493,26 @@ ifeq ($(DISABLE_BN_FOLDING), 1)
493493
COMMON_FLAGS += -DDISABLE_BN_FOLDING
494494
endif
495495

496+
# Disable Conv + ReLU fusion
497+
ifeq ($(DISABLE_CONV_RELU_FUSION), 1)
498+
COMMON_FLAGS += -DDISABLE_CONV_RELU_FUSION
499+
endif
500+
501+
# Disable Bn + ReLU fusion
502+
ifeq ($(DISABLE_BN_RELU_FUSION), 1)
503+
COMMON_FLAGS += -DDISABLE_BN_RELU_FUSION
504+
endif
505+
496506
# Disable the conv/eltwise/relu layer fusion
497507
ifeq ($(DISABLE_CONV_SUM_FUSION), 1)
498508
COMMON_FLAGS += -DDISABLE_CONV_SUM_FUSION
499509
endif
500510

511+
# Disable sparse
512+
ifeq ($(DISABLE_SPARSE), 1)
513+
COMMON_FLAGS += -DDISABLE_SPARSE
514+
endif
515+
501516
# Performance monitoring
502517
ifeq ($(PERFORMANCE_MONITORING), 1)
503518
CXXFLAGS += -DPERFORMANCE_MONITORING
@@ -515,7 +530,9 @@ include Makefile.dlcp
515530
BOOST_LDFLAGS += $(foreach boost_lib,$(BOOST_LIBRARIES),-l$(boost_lib))
516531
ifneq ($(origin BOOST_ROOT), undefined)
517532
INCLUDE_DIRS += $(BOOST_ROOT)
533+
INCLUDE_DIRS += $(BOOST_ROOT)/include
518534
BOOST_LDFLAGS+=-L$(BOOST_ROOT)/stage/lib -Wl,-rpath,$(BOOST_ROOT)/stage/lib
535+
BOOST_LDFLAGS+=-L$(BOOST_ROOT)/lib -Wl,-rpath,$(BOOST_ROOT)/lib
519536
endif
520537

521538
# BLAS configuration (default = MKL)

Makefile.config.example

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,25 @@ USE_MKLDNN_AS_DEFAULT_ENGINE := 1
7979
# Use remove batch norm optimization to boost inference
8080
DISABLE_BN_FOLDING := 0
8181

82-
#Use conv/eltwise/relu layer fusion to boost inference.
82+
# Use Conv + Relu fusion to boost inference
83+
DISABLE_CONV_RELU_FUSION:= 0
84+
85+
# Use Bn + ReLU fusion to boost inference
86+
DISABLE_BN_RELU_FUSION := 0
87+
88+
# Use Conv + Eltwise + Relu layer fusion to boost inference.
8389
DISABLE_CONV_SUM_FUSION := 0
90+
91+
# Use sparse to boost inference.
92+
DISABLE_SPARSE := 0
93+
94+
# Intel(R) Math Kernel Library for Deep Neural Networks (Intel(R) MKL-DNN)
95+
# Uncomment to disable MKLDNN download by customized setting
96+
# DISABLE_MKLDNN_DOWNLOAD := 1
97+
8498
# Intel(r) Machine Learning Scaling Library (uncomment to build
8599
# with MLSL for multi-node training)
86-
# USE_MLSL :=1
100+
USE_MLSL := 1
87101

88102
# CUDA directory contains bin/ and lib/ directories that we need.
89103
CUDA_DIR := /usr/local/cuda

Makefile.mkldnn

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ endif
2424
MKLDNN_GITHUB := https://github.com/01org/mkl-dnn.git
2525
MKLDNN_CMAKE_FLAGS += $(MKLDNN_SRCDIR) -DCMAKE_INSTALL_PREFIX=$(MKLDNN_INSTALLDIR) -DMKLROOT=${MKL_ROOTDIR} -B$(MKLDNN_BUILDDIR) -DCMAKE_CXX_COMPILER="$(MKLDNN_CXX)" -DCMAKE_C_COMPILER="$(MKLDNN_CC)"
2626

27+
# Disable MKLDNN download by customized setting
28+
ifeq ($(DISABLE_MKLDNN_DOWNLOAD), 1)
29+
disable_mkldnn_download_info:
30+
@echo "MKLDNN download is disabled by customized setting! If MKLDNNROOT is not set in the ENV, may cause compile error in the following steps!"
31+
mkldnn_download:
32+
mkldnn_build:
33+
34+
else
35+
disable_mkldnn_download_info:
36+
@echo "MKLDNN download is enabled by customized setting!"
37+
2738
ifeq ("$(wildcard $(MKLDNN_INSTALLDIR)/include/mkldnn.hpp)", "")
2839
mkldnn_download:
2940
git clone --no-checkout $(MKLDNN_GITHUB) $(MKLDNN_TMPDIR)
@@ -38,6 +49,7 @@ else
3849
mkldnn_download:
3950
mkldnn_build:
4051
endif
52+
endif
4153

4254
mkldnn_clean:
4355
@rm -rf $(MKLDNN_SRCDIR) $(MKLDNN_BUILDDIR) $(MKLDNN_INSTALLDIR) $(MKLDNN_TMPDIR)
@@ -55,10 +67,14 @@ mkldnnroot_notset: mkldnn_build
5567
$(eval MKLDNN_LDFLAGS += -lmkldnn) \
5668
$(eval MKLDNN_LDFLAGS += -L$(MKLDNN_INSTALLDIR)/lib -Wl,-rpath,${MKLDNN_INSTALLDIR}/lib)
5769

70+
71+
5872
ifneq ($(origin MKLDNNROOT), undefined)
5973
ifdef MKLDNNROOT
6074
mkldnn: mkldnnroot_set
75+
mkldnn: disable_mkldnn_download_info
6176
endif
6277
else
6378
mkldnn: mkldnnroot_notset
79+
mkldnn: disable_mkldnn_download_info
6480
endif

cmake/Dependencies.cmake

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ if(PERFORMANCE_MONITORING)
2525
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPERFORMANCE_MONITORING")
2626
endif()
2727

28+
# ---[ CPU DATA READONLY CO SIM
29+
if(CO_SIM)
30+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCO_SIM")
31+
endif()
32+
2833
# ---[ Google-glog
2934
include("cmake/External/glog.cmake")
3035
include_directories(SYSTEM ${GLOG_INCLUDE_DIRS})
@@ -191,8 +196,10 @@ if(NOT APPLE)
191196
set(MKL_INCLUDE_DIR "${MKL_ROOT_DIR}/include/")
192197
if( ${MKL_EXTERNAL} EQUAL 1 )
193198
set(MKL_LIBRARIES "${MKL_ROOT_DIR}/lib/lib${MKL_LIBRARIES}.so")
199+
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MKL_ROOT_DIR}/lib/)
194200
else()
195201
set(MKL_LIBRARIES "${MKL_ROOT_DIR}/lib/intel64/lib${MKL_LIBRARIES}.so")
202+
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MKL_ROOT_DIR}/lib/intel64/)
196203
endif()
197204
message(STATUS "Found MKL: ${MKL_INCLUDE_DIR}")
198205
message(STATUS "Found MKL (include: ${MKL_INCLUDE_DIR}, lib: ${MKL_LIBRARIES}")
@@ -237,6 +244,14 @@ endif()
237244

238245
# ---[ MKLDNN
239246
if(DEFINED ENV{MKLDNNROOT})
247+
if(DISABLE_MKLDNN_DOWNLOAD)
248+
message(STATUS "MKLDNN download is disabled by customized setting!")
249+
message(STATUS "MKLDNNROOT is already set in the ENV, will use ENV MKLDNNROOT in the following compile steps!")
250+
add_definitions("-DDISABLE_MKLDNN_DOWNLOAD=1")
251+
else()
252+
message(STATUS "MKLDNN download is enabled by customized setting!")
253+
add_definitions("-DDISABLE_MKLDNN_DOWNLOAD=0")
254+
endif()
240255
set(MKLDNNROOT_DIR $ENV{MKLDNNROOT})
241256
if(NOT ${MKLDNNROOT_DIR} STREQUAL "")
242257
set(MKLDNNROOT_INCLUDE_DIR "${MKLDNNROOT_DIR}/include/")
@@ -249,6 +264,7 @@ if(DEFINED ENV{MKLDNNROOT})
249264
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MKLDNN_AS_DEFAULT_ENGINE")
250265
endif()
251266
list(APPEND Caffe_LINKER_LIBS "${MKLDNNROOT_DIR}/lib/libmkldnn.so")
267+
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MKLDNNROOT_DIR}/lib/)
252268
include_directories(SYSTEM ${MKLDNNROOT_INCLUDE_DIR})
253269
else()
254270
message(STATUS "MKLDNN not found. MKLDNN_INCLUDE_DIR = ${MKLDNNROOT_INCLUDE_DIR}")
@@ -259,18 +275,27 @@ if(DEFINED ENV{MKLDNNROOT})
259275
endif()
260276
endif()
261277
else()
262-
Download_MKLDNN()
278+
if(DISABLE_MKLDNN_DOWNLOAD)
279+
message(STATUS "MKLDNN download is disabled by customized setting!")
280+
message(STATUS "MKLDNNROOT is not set in the ENV, will cause compile error in the following steps!")
281+
add_definitions("-DDISABLE_MKLDNN_DOWNLOAD=1")
282+
else()
283+
message(STATUS "MKLDNN download is enabled by customized setting!")
284+
add_definitions("-DDISABLE_MKLDNN_DOWNLOAD=0")
285+
Download_MKLDNN()
263286

264-
message(STATUS "MKLDNN will be downloaded from github and installed in ${MKLDNN_INSTALL_DIR}")
265-
message(STATUS "MKLDNN include directory: ${MKLDNN_INCLUDE_DIR}")
266-
set(MKLDNN_SUPPORTED ON)
267-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMKLDNN_SUPPORTED -std=c++11")
268-
if(USE_MKLDNN_AS_DEFAULT_ENGINE)
269-
message(STATUS "MKLDNN engine will be used as a default engine")
270-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MKLDNN_AS_DEFAULT_ENGINE")
287+
message(STATUS "MKLDNN will be downloaded from github and installed in ${MKLDNN_INSTALL_DIR}")
288+
message(STATUS "MKLDNN include directory: ${MKLDNN_INCLUDE_DIR}")
289+
set(MKLDNN_SUPPORTED ON)
290+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMKLDNN_SUPPORTED -std=c++11")
291+
if(USE_MKLDNN_AS_DEFAULT_ENGINE)
292+
message(STATUS "MKLDNN engine will be used as a default engine")
293+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MKLDNN_AS_DEFAULT_ENGINE")
294+
endif()
295+
list(APPEND Caffe_LINKER_LIBS "${MKLDNN_INSTALL_DIR}/lib/libmkldnn.so")
296+
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MKLDNN_INSTALL_DIR}/lib/)
297+
include_directories(${MKLDNN_INCLUDE_DIR})
271298
endif()
272-
list(APPEND Caffe_LINKER_LIBS "${MKLDNN_INSTALL_DIR}/lib/libmkldnn.so")
273-
include_directories(${MKLDNN_INCLUDE_DIR})
274299
endif()
275300

276301
# ---[ Python

cmake/Misc.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,25 @@ if(DISABLE_BN_FOLDING)
1111
add_definitions("-DDISABLE_BN_FOLDING")
1212
endif()
1313

14+
if(DISABLE_CONV_RELU_FUSION)
15+
message(STATUS "CONV + ReLU fusion is disabled!")
16+
add_definitions("-DDISABLE_CONV_RELU_FUSION")
17+
endif()
18+
19+
if(DISABLE_BN_RELU_FUSION)
20+
message(STATUS "Bn + ReLU fusion is disabled!")
21+
add_definitions("-DDISABLE_BN_RELU_FUSION")
22+
endif()
23+
1424
if(DISABLE_CONV_SUM_FUSION)
1525
message(STATUS "conv/eltwise/relu fusion is disabled!")
1626
add_definitions("-DDISABLE_CONV_SUM_FUSION")
1727
endif()
1828

29+
if(DISABLE_SPARSE)
30+
message(STATUS "sparse is disabled!")
31+
add_definitions("-DDISABLE_SPARSE")
32+
endif()
1933
# --[ If user doesn't specify build type then assume release
2034
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
2135
set(CMAKE_BUILD_TYPE Release)

cmake/Modules/CodeCoverage.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
include(CMakeParseArguments)
2+
3+
find_program( GCOV gcov )
4+
if(NOT GCOV)
5+
message(FATAL_ERROR "command gcov not found!")
6+
endif()
7+
8+
set(CCOV_COMPILER_FLAGS "-g -O0 --coverage -fprofile-arcs -ftest-coverage"
9+
CACHE INTERNAL "")
10+
11+
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
12+
message(WARNING "Non debug build may lead to wrong code coverage result.")
13+
endif()
14+
15+
function(APPEND_CCOV_COMPILER_FLAGS)
16+
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${CCOV_COMPILER_FLAGS}" PARENT_SCOPE)
17+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CCOV_COMPILER_FLAGS}" PARENT_SCOPE)
18+
message(STATUS "Setting code coverage compiler flags: ${CCOV_COMPILER_FLAGS}")
19+
endfunction()

cmake/Summary.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ function(caffe_print_configuration_summary)
121121
caffe_status(" ALLOW_LMDB_NOLOCK : ${ALLOW_LMDB_NOLOCK}")
122122
caffe_status(" USE_SYSTEMTAP : ${USE_SYSTEMTAP}")
123123
caffe_status(" PERFORMANCE_MONITORING : ${PERFORMANCE_MONITORING}")
124+
caffe_status(" CO_SIM : ${CO_SIM}")
124125
caffe_status("")
125126
caffe_status("Dependencies:")
126127
caffe_status(" BLAS : " APPLE THEN "Yes (vecLib)" ELSE "Yes (${BLAS})")

docker/standalone/cpu-ubuntu/Dockerfile

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@ MAINTAINER [email protected]
55
#ENV https_proxy proxy:port
66

77
RUN apt-get update && apt-get install -y --no-install-recommends \
8+
cpio \
89
build-essential \
910
cmake \
1011
git \
1112
wget \
1213
ssh \
14+
openssh-server \
15+
numactl \
16+
vim \
17+
net-tools \
18+
iputils-ping \
19+
screen \
20+
libmlx4-1 libmlx5-1 ibutils rdmacm-utils libibverbs1 ibverbs-utils perftest infiniband-diags \
21+
openmpi-bin libopenmpi-dev \
22+
ufw \
23+
iptables \
1324
libboost-all-dev \
1425
libgflags-dev \
1526
libgoogle-glog-dev \
@@ -38,12 +49,27 @@ RUN pip install --upgrade pip
3849
RUN git clone -b ${CLONE_TAG} --depth 1 https://github.com/intel/caffe.git . && \
3950
for req in $(cat python/requirements.txt) pydot; do pip install $req; done && \
4051
mkdir build && cd build && \
41-
cmake -DCPU_ONLY=1 -DCMAKE_BUILD_TYPE=Release .. && \
52+
cmake -DCPU_ONLY=1 -DUSE_MLSL=1 -DCMAKE_BUILD_TYPE=Release .. && \
4253
make all -j"$(nproc)"
4354

4455
ENV PYCAFFE_ROOT $CAFFE_ROOT/python
4556
ENV PYTHONPATH $PYCAFFE_ROOT:$PYTHONPATH
4657
ENV PATH $CAFFE_ROOT/build/tools:$PYCAFFE_ROOT:$PATH
4758
RUN echo "$CAFFE_ROOT/build/lib" >> /etc/ld.so.conf.d/caffe.conf && ldconfig
4859

49-
WORKDIR /workspace
60+
WORKDIR /opt/caffe
61+
62+
RUN mkdir /var/run/sshd
63+
RUN echo 'root:123456' | chpasswd
64+
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
65+
RUN sed -i 's/Port 22/Port 10010/' /etc/ssh/sshd_config
66+
67+
# SSH login fix. Otherwise user is kicked off after login
68+
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
69+
70+
ENV NOTVISIBLE "in users profile"
71+
RUN echo "export VISIBLE=now" >> /etc/profile
72+
73+
EXPOSE 10010
74+
75+
CMD ["/usr/sbin/sshd", "-D"]

0 commit comments

Comments
 (0)