Skip to content

Commit e05f3ea

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into quick_help
2 parents a006c54 + a79676e commit e05f3ea

File tree

254 files changed

+6363
-4118
lines changed

Some content is hidden

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

254 files changed

+6363
-4118
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ option(WITH_GPU "Compile PaddlePaddle with NVIDIA GPU" ${CUDA_F
3939
option(WITH_AMD_GPU "Compile PaddlePaddle with AMD GPU" OFF)
4040
option(WITH_AVX "Compile PaddlePaddle with AVX intrinsics" ${AVX_FOUND})
4141
option(WITH_MKL "Compile PaddlePaddle with MKL support." ${AVX_FOUND})
42+
option(WITH_TENSORRT "Compile PaddlePaddle with TensorRT support." OFF)
4243
option(WITH_DSO "Compile PaddlePaddle with dynamic linked CUDA" ON)
4344
option(WITH_TESTING "Compile PaddlePaddle with unit testing" OFF)
4445
option(WITH_SWIG_PY "Compile PaddlePaddle with inference api" ON)
@@ -181,6 +182,11 @@ if(WITH_GPU)
181182
include(cuda)
182183
endif(WITH_GPU)
183184

185+
# TensorRT depends on GPU.
186+
if (NOT WITH_GPU)
187+
set(WITH_TENSORRT OFF)
188+
endif()
189+
184190
if(WITH_AMD_GPU)
185191
find_package(HIP)
186192
include(hip)

Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# A image for building paddle binaries
22
# Use cuda devel base image for both cpu and gpu environment
3-
FROM nvidia/cuda:8.0-cudnn5-devel-ubuntu16.04
3+
FROM nvidia/cuda:8.0-cudnn7-devel-ubuntu16.04
44
MAINTAINER PaddlePaddle Authors <[email protected]>
55

66
ARG UBUNTU_MIRROR
@@ -45,6 +45,13 @@ ENV PATH=${PATH}:${GOROOT}/bin:${GOPATH}/bin
4545
# install glide
4646
RUN curl -s -q https://glide.sh/get | sh
4747

48+
# Install TensorRT
49+
# The unnecessary files has been removed to make the library small.
50+
RUN wget -qO- http://paddlepaddledeps.bj.bcebos.com/TensorRT-4.0.0.3.Ubuntu-16.04.4.x86_64-gnu.cuda-8.0.cudnn7.0.tar.gz | \
51+
tar -xz -C /usr/local && \
52+
cp -rf /usr/local/TensorRT/include /usr && \
53+
cp -rf /usr/local/TensorRT/lib /usr
54+
4855
# git credential to skip password typing
4956
RUN git config --global credential.helper store
5057

@@ -57,7 +64,7 @@ RUN localedef -i en_US -f UTF-8 en_US.UTF-8
5764
# specify sphinx version as 1.5.6 and remove -U option for [pip install -U
5865
# sphinx-rtd-theme] since -U option will cause sphinx being updated to newest
5966
# version(1.7.1 for now), which causes building documentation failed.
60-
RUN pip install --upgrade pip && \
67+
RUN pip install --upgrade pip==9.0.3 && \
6168
pip install -U wheel && \
6269
pip install -U docopt PyYAML sphinx==1.5.6 && \
6370
pip install sphinx-rtd-theme==0.1.9 recommonmark

benchmark/fluid/mnist.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ def run_benchmark(model, args):
139139

140140
# inference program
141141
inference_program = fluid.default_main_program().clone()
142-
with fluid.program_guard(inference_program):
143-
inference_program = fluid.io.get_inference_program(
144-
target_vars=[batch_acc, batch_size_tensor])
145142

146143
# Optimization
147144
opt = fluid.optimizer.AdamOptimizer(
@@ -161,7 +158,7 @@ def run_benchmark(model, args):
161158
train_reader = paddle.batch(
162159
paddle.dataset.mnist.train(), batch_size=args.batch_size)
163160

164-
accuracy = fluid.average.WeightedAverage()
161+
accuracy = fluid.metrics.Accuracy()
165162
iters, num_samples, start_time = 0, 0, time.time()
166163
for pass_id in range(args.pass_num):
167164
accuracy.reset()
@@ -184,7 +181,7 @@ def run_benchmark(model, args):
184181
"label": y_data},
185182
fetch_list=[avg_cost, batch_acc, batch_size_tensor]
186183
) # The accuracy is the accumulation of batches, but not the current batch.
187-
accuracy.add(value=outs[1], weight=outs[2])
184+
accuracy.update(value=outs[1], weight=outs[2])
188185
iters += 1
189186
num_samples += len(y_data)
190187
loss = np.array(outs[0])

cmake/cblas.cmake

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,33 @@ endif()
6262

6363

6464
## Then find the reference-cblas. www.netlib.org/blas/
65-
66-
6765
set(REFERENCE_CBLAS_ROOT $ENV{REFERENCE_CBLAS_ROOT} CACHE PATH
6866
"Folder contains reference-cblas")
69-
set(REFERENCE_CBLAS_INCLUDE_SEARCH_PATHS
70-
${REFERENCE_CBLAS_ROOT}/include
71-
/usr/include
72-
/usr/include/cblas
73-
)
74-
75-
set(REFERENCE_CBLAS_LIB_SEARCH_PATHS
76-
${REFERENCE_CBLAS_ROOT}/lib
77-
/usr/lib
78-
/usr/lib/blas/reference/
79-
/usr/lib/reference/
80-
)
67+
if(NOT CMAKE_CROSSCOMPILING)
68+
set(REFERENCE_CBLAS_INCLUDE_SEARCH_PATHS
69+
${REFERENCE_CBLAS_ROOT}/include
70+
/usr/include
71+
/usr/include/cblas
72+
)
73+
74+
set(REFERENCE_CBLAS_LIB_SEARCH_PATHS
75+
${REFERENCE_CBLAS_ROOT}/lib
76+
/usr/lib
77+
/usr/lib/blas/reference/
78+
/usr/lib/reference/
79+
)
80+
else()
81+
# Disable the finding of reference cblas under host's system path
82+
set(REFERENCE_CBLAS_INCLUDE_SEARCH_PATHS ${REFERENCE_CBLAS_ROOT}/include)
83+
set(REFERENCE_CBLAS_LIB_SEARCH_PATHS ${REFERENCE_CBLAS_ROOT}/lib)
84+
endif()
8185

8286
find_path(REFERENCE_CBLAS_INCLUDE_DIR NAMES cblas.h PATHS
8387
${REFERENCE_CBLAS_INCLUDE_SEARCH_PATHS})
8488
find_library(REFERENCE_CBLAS_LIBRARY NAMES cblas PATHS
8589
${REFERENCE_CBLAS_LIB_SEARCH_PATHS})
8690

87-
if (REFERENCE_CBLAS_INCLUDE_DIR AND REFERENCE_CBLAS_LIBRARY)
91+
if(REFERENCE_CBLAS_INCLUDE_DIR AND REFERENCE_CBLAS_LIBRARY)
8892
set(CBLAS_FOUND ON)
8993
set(CBLAS_PROVIDER REFERENCE)
9094
set(CBLAS_INC_DIR ${REFERENCE_CBLAS_INCLUDE_DIR})

cmake/external/grpc.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ SET(GRPC_INSTALL_DIR ${THIRD_PARTY_PATH}/install/grpc)
2424
SET(GRPC_INCLUDE_DIR "${GRPC_INSTALL_DIR}/include/" CACHE PATH "grpc include directory." FORCE)
2525
SET(GRPC_CPP_PLUGIN "${GRPC_INSTALL_DIR}/bin/grpc_cpp_plugin" CACHE FILEPATH "GRPC_CPP_PLUGIN" FORCE)
2626
IF(APPLE)
27-
SET(BUILD_CMD make -n HAS_SYSTEM_PROTOBUF=false -s -j8 static grpc_cpp_plugin | sed "s/-Werror//g" | sh)
27+
SET(BUILD_CMD make -n HAS_SYSTEM_PROTOBUF=false -s -j static grpc_cpp_plugin | sed "s/-Werror//g" | sh)
2828
ELSE()
29-
SET(BUILD_CMD make HAS_SYSTEM_PROTOBUF=false -s -j8 static grpc_cpp_plugin)
29+
SET(BUILD_CMD make HAS_SYSTEM_PROTOBUF=false -s -j static grpc_cpp_plugin)
3030
ENDIF()
3131

3232
ExternalProject_Add(
3333
extern_grpc
3434
DEPENDS protobuf zlib
3535
GIT_REPOSITORY "https://github.com/grpc/grpc.git"
36-
GIT_TAG "v1.8.x"
36+
GIT_TAG "v1.10.x"
3737
PREFIX ${GRPC_SOURCES_DIR}
3838
UPDATE_COMMAND ""
3939
CONFIGURE_COMMAND ""

cmake/external/nccl.cmake

Lines changed: 0 additions & 67 deletions
This file was deleted.

cmake/external/snappy.cmake

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
#
1514

16-
IF(MOBILE_INFERENCE)
15+
if(MOBILE_INFERENCE OR RPI)
1716
return()
18-
ENDIF()
17+
endif()
1918

2019
include (ExternalProject)
2120

2221
# NOTE: snappy is needed when linking with recordio
2322

24-
SET(SNAPPY_SOURCES_DIR ${THIRD_PARTY_PATH}/snappy)
25-
SET(SNAPPY_INSTALL_DIR ${THIRD_PARTY_PATH}/install/snappy)
26-
SET(SNAPPY_INCLUDE_DIR "${SNAPPY_INSTALL_DIR}/include/" CACHE PATH "snappy include directory." FORCE)
23+
set(SNAPPY_SOURCES_DIR ${THIRD_PARTY_PATH}/snappy)
24+
set(SNAPPY_INSTALL_DIR ${THIRD_PARTY_PATH}/install/snappy)
25+
set(SNAPPY_INCLUDE_DIR "${SNAPPY_INSTALL_DIR}/include" CACHE PATH "snappy include directory." FORCE)
26+
27+
set(SNAPPY_LIBRARIES "${SNAPPY_INSTALL_DIR}/lib/libsnappy.a")
2728

2829
ExternalProject_Add(
2930
extern_snappy
@@ -51,8 +52,7 @@ ExternalProject_Add(
5152
)
5253

5354
add_library(snappy STATIC IMPORTED GLOBAL)
54-
set_property(TARGET snappy PROPERTY IMPORTED_LOCATION
55-
"${SNAPPY_INSTALL_DIR}/lib/libsnappy.a")
55+
set_property(TARGET snappy PROPERTY IMPORTED_LOCATION ${SNAPPY_LIBRARIES})
5656

5757
include_directories(${SNAPPY_INCLUDE_DIR})
5858
add_dependencies(snappy extern_snappy)

cmake/external/snappystream.cmake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
#
1514

16-
IF(MOBILE_INFERENCE)
15+
IF(MOBILE_INFERENCE OR RPI)
1716
return()
1817
ENDIF()
1918

2019
include (ExternalProject)
2120

2221
# NOTE: snappy is needed when linking with recordio
2322

24-
SET(SNAPPYSTREAM_SOURCES_DIR ${THIRD_PARTY_PATH}/snappy_stream)
25-
SET(SNAPPYSTREAM_INSTALL_DIR ${THIRD_PARTY_PATH}/install/snappy_stream)
26-
SET(SNAPPYSTREAM_INCLUDE_DIR "${SNAPPYSTREAM_INSTALL_DIR}/include/" CACHE PATH "snappy stream include directory." FORCE)
23+
set(SNAPPYSTREAM_SOURCES_DIR ${THIRD_PARTY_PATH}/snappy_stream)
24+
set(SNAPPYSTREAM_INSTALL_DIR ${THIRD_PARTY_PATH}/install/snappy_stream)
25+
set(SNAPPYSTREAM_INCLUDE_DIR "${SNAPPYSTREAM_INSTALL_DIR}/include" CACHE PATH "snappy stream include directory." FORCE)
26+
27+
set(SNAPPYSTREAM_LIBRARIES "${SNAPPYSTREAM_INSTALL_DIR}/lib/libsnappystream.a")
2728

2829
ExternalProject_Add(
2930
extern_snappystream
@@ -51,8 +52,7 @@ ExternalProject_Add(
5152
)
5253

5354
add_library(snappystream STATIC IMPORTED GLOBAL)
54-
set_property(TARGET snappystream PROPERTY IMPORTED_LOCATION
55-
"${SNAPPYSTREAM_INSTALL_DIR}/lib/libsnappystream.a")
55+
set_property(TARGET snappystream PROPERTY IMPORTED_LOCATION ${SNAPPYSTREAM_LIBRARIES})
5656

5757
include_directories(${SNAPPYSTREAM_INCLUDE_DIR}) # For snappysteam to include its own headers.
5858
include_directories(${THIRD_PARTY_PATH}/install) # For Paddle to include snappy stream headers.

cmake/generic.cmake

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,7 @@ function(cc_library TARGET_NAME)
195195
list(REMOVE_ITEM cc_library_DEPS warpctc)
196196
add_dependencies(${TARGET_NAME} warpctc)
197197
endif()
198-
if("${cc_library_DEPS}" MATCHES "ARCHIVE_START")
199-
# Support linking flags: --whole-archive (Linux) / -force_load (MacOS).
200-
# WARNING: Please don't use ARCHIVE_START&ARCHIVE_END if TARGET_NAME will be linked by other libraries.
201-
target_circle_link_libraries(${TARGET_NAME} ${cc_library_DEPS})
202-
list(REMOVE_ITEM cc_library_DEPS ARCHIVE_START ARCHIVE_END)
203-
else()
204-
target_link_libraries(${TARGET_NAME} ${cc_library_DEPS})
205-
endif()
198+
target_link_libraries(${TARGET_NAME} ${cc_library_DEPS})
206199
add_dependencies(${TARGET_NAME} ${cc_library_DEPS})
207200
endif()
208201

@@ -243,11 +236,7 @@ function(cc_test TARGET_NAME)
243236
set(multiValueArgs SRCS DEPS ARGS)
244237
cmake_parse_arguments(cc_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
245238
add_executable(${TARGET_NAME} ${cc_test_SRCS})
246-
# Support linking flags: --whole-archive (Linux) / -force_load (MacOS)
247-
target_circle_link_libraries(${TARGET_NAME} ${cc_test_DEPS} paddle_gtest_main memory gtest gflags glog)
248-
if("${cc_test_DEPS}" MATCHES "ARCHIVE_START")
249-
list(REMOVE_ITEM cc_test_DEPS ARCHIVE_START ARCHIVE_END)
250-
endif()
239+
target_link_libraries(${TARGET_NAME} ${cc_test_DEPS} paddle_gtest_main memory gtest gflags glog)
251240
add_dependencies(${TARGET_NAME} ${cc_test_DEPS} paddle_gtest_main memory gtest gflags glog)
252241
add_test(NAME ${TARGET_NAME}
253242
COMMAND ${TARGET_NAME} ${cc_test_ARGS}

cmake/inference_lib.cmake

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1+
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
set_property(GLOBAL PROPERTY FLUID_MODULES "")
216
# find all fluid modules is used for paddle fluid static library
317
function(find_fluid_modules TARGET_NAME)
418
get_filename_component(__target_path ${TARGET_NAME} ABSOLUTE)
19+
string(REGEX REPLACE "^${PADDLE_SOURCE_DIR}/" "" __target_path ${__target_path})
520
string(FIND "${__target_path}" "fluid" pos)
621
if(pos GREATER 1)
722
get_property(fluid_modules GLOBAL PROPERTY FLUID_MODULES)
@@ -77,6 +92,23 @@ elseif (WITH_MKLML)
7792
)
7893
endif()
7994

95+
if(NOT MOBILE_INFERENCE AND NOT RPI)
96+
set(dst_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/snappy")
97+
copy(snappy_lib
98+
SRCS ${SNAPPY_INCLUDE_DIR} ${SNAPPY_LIBRARIES}
99+
DSTS ${dst_dir} ${dst_dir}/lib)
100+
101+
set(dst_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/snappystream")
102+
copy(snappystream_lib
103+
SRCS ${SNAPPYSTREAM_INCLUDE_DIR} ${SNAPPYSTREAM_LIBRARIES}
104+
DSTS ${dst_dir} ${dst_dir}/lib)
105+
106+
set(dst_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/zlib")
107+
copy(zlib_lib
108+
SRCS ${ZLIB_INCLUDE_DIR} ${ZLIB_LIBRARIES}
109+
DSTS ${dst_dir} ${dst_dir}/lib)
110+
endif()
111+
80112
# paddle fluid module
81113
set(src_dir "${PADDLE_SOURCE_DIR}/paddle/fluid")
82114
set(dst_dir "${CMAKE_INSTALL_PREFIX}/paddle/fluid")

0 commit comments

Comments
 (0)