Skip to content

Commit e043fe2

Browse files
author
skylarch
authored
Merge pull request #1 from PaddlePaddle/develop
pull from base
2 parents 3a29821 + ef4895d commit e043fe2

File tree

1,543 files changed

+35192
-11591
lines changed

Some content is hidden

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

1,543 files changed

+35192
-11591
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323
- id: clang-format-with-version-check
2424
name: clang-format
2525
description: Format files with ClangFormat.
26-
entry: bash ./.clang_format.hook -i
26+
entry: bash ./tools/codestyle/clang_format.hook -i
2727
language: system
2828
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto)$
2929
- repo: local
@@ -52,7 +52,7 @@ repos:
5252
hooks:
5353
- id: copyright_checker
5454
name: copyright_checker
55-
entry: python ./.copyright.hook
55+
entry: python ./tools/codestyle/copyright.hook
5656
language: system
5757
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto|py)$
5858
exclude: (?!.*third_party)^.*$ | (?!.*book)^.*$

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ script:
3131
if [[ "$JOB" != "doc" ]]; then exit 0; fi;
3232
# For document only
3333
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then exit 0; fi;
34-
if [[ "$TRAVIS_BRANCH" != "develop" && ! "$TRAVIS_BRANCH" =~ ^v[[:digit:]]+\.[[:digit:]]+(\.[[:digit:]]+)?(-\S*)?$ ]]; then exit 0; fi;
34+
if [[ "$TRAVIS_BRANCH" != "develop" && ! "$TRAVIS_BRANCH" =~ ^v|release/[[:digit:]]+\.[[:digit:]]+(\.[[:digit:]]+)?(-\S*)?$ ]]; then exit 0; fi;
3535
export DEPLOY_DOCS_SH=https://raw.githubusercontent.com/PaddlePaddle/PaddlePaddle.org/master/scripts/deploy/deploy_docs.sh
3636
export DOCS_DIR=`pwd`
3737
cd ..

AUTHORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
| backyes | Yan-Fei Wang |
55
| baiyfbupt | Yi-Fan Bai |
66
| beckett1124 | Bin Qi |
7+
| ChengduoZH | Cheng-Duo Zhao|
78
| chengxiaohua1105 | Xiao-Hua Cheng |
89
| cxwangyi, yiwangbaidu, wangkuiyi | Yi Wang |
910
| cxysteven | Xing-Yi Cheng |
@@ -21,6 +22,7 @@
2122
| jczaja | Jacek Czaja |
2223
| JiayiFeng | Jia-Yi Feng |
2324
| kbinias | Krzysztof Binias |
25+
| kexinzhao | Ke-Xin Zhao |
2426
| kuke | Yi-Bing Liu |
2527
| lcy-seso | Ying Cao |
2628
| lipeng-unisound | Peng Li |

CMakeLists.txt

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,17 @@ option(WITH_FLUID_ONLY "Compile PaddlePaddle fluid only" OFF)
5555
option(WITH_GOLANG "Compile PaddlePaddle with GOLANG" OFF)
5656
option(GLIDE_INSTALL "Download and install go dependencies " ON)
5757
option(USE_NNPACK "Compile PaddlePaddle with NNPACK library" OFF)
58-
option(WITH_DISTRIBUTE "Compile with grpc distributed support" OFF)
58+
option(WITH_DISTRIBUTE "Compile with distributed support" OFF)
5959
option(USE_EIGEN_FOR_BLAS "Use matrix multiplication in Eigen" OFF)
6060
option(EIGEN_USE_THREADS "Compile with multi-threaded Eigen" OFF)
6161
option(WITH_ARM_FP16 "Use half precision support on armv8.2-a cpu" OFF)
6262
option(WITH_FAST_BUNDLE_TEST "Bundle tests that can be run in a single process together to reduce launch overhead" OFF)
6363
option(WITH_CONTRIB "Compile the third-party contributation" OFF)
64+
option(REPLACE_ENFORCE_GLOG "Replace PADDLE_ENFORCE with glog/CHECK for better debug." OFF)
65+
option(WITH_ANAKIN "Compile with Anakin library" OFF)
66+
option(WITH_GRPC "Use grpc as the default rpc framework" ${WITH_DISTRIBUTE})
67+
option(WITH_BRPC_RDMA "Use brpc rdma as the rpc protocal" OFF)
68+
option(WITH_SYSTEM_BLAS "Use system blas library" OFF)
6469

6570
# CMAKE_BUILD_TYPE
6671
if(NOT CMAKE_BUILD_TYPE)
@@ -129,6 +134,10 @@ if (NOT DEFINED WITH_MKLDNN)
129134
set(WITH_MKLDNN OFF)
130135
endif()
131136
endif()
137+
138+
if (REPLACE_ENFORCE_GLOG)
139+
add_definitions("-DREPLACE_ENFORCE_GLOG")
140+
endif()
132141
########################################################################################
133142

134143
include(external/mklml) # download mklml package
@@ -147,7 +156,28 @@ include(external/any) # download libn::any
147156
include(external/eigen) # download eigen3
148157
include(external/pybind11) # download pybind11
149158
include(external/cares)
150-
include(external/grpc)
159+
160+
if(WITH_DISTRIBUTE)
161+
if(WITH_GRPC)
162+
include(external/grpc)
163+
message(STATUS "Use grpc framework.")
164+
else()
165+
message(STATUS "Use brpc framework.")
166+
include(external/leveldb)
167+
include(external/brpc)
168+
endif()
169+
endif()
170+
171+
if(WITH_BRPC_RDMA)
172+
message(STATUS "Use brpc with rdma.")
173+
if(WITH_GRPC)
174+
message(FATAL_ERROR "Can't use grpc with brpc rdma.")
175+
endif()
176+
if(NOT WITH_DISTRIBUTE)
177+
message(FATAL_ERROR "Can't use brpc rdma in no distribute env.")
178+
endif()
179+
endif()
180+
151181
include(external/snappy) # download snappy
152182
include(external/snappystream)
153183
include(external/threadpool)
@@ -167,7 +197,7 @@ include(inference_lib) # add paddle fluid inference libraries
167197

168198

169199
include_directories("${PADDLE_SOURCE_DIR}")
170-
include_directories("${PADDLE_SOURCE_DIR}/paddle/cuda/include")
200+
include_directories("${PADDLE_SOURCE_DIR}/paddle/legacy/cuda/include")
171201
include_directories("${CMAKE_CURRENT_BINARY_DIR}/proto")
172202
include_directories("${CMAKE_CURRENT_BINARY_DIR}/go/pserver/client/c")
173203

@@ -183,7 +213,10 @@ set(EXTERNAL_LIBS
183213
if(WITH_GPU)
184214
include(cuda)
185215
include(tensorrt)
186-
endif(WITH_GPU)
216+
include(external/anakin)
217+
else()
218+
set(WITH_ANAKIN OFF CACHE STRING "Anakin is valid only when GPU is set." FORCE)
219+
endif()
187220

188221
if(WITH_AMD_GPU)
189222
find_package(HIP)
@@ -208,7 +241,7 @@ add_subdirectory(proto)
208241
if(NOT MOBILE_INFERENCE AND NOT WITH_FLUID_ONLY)
209242
# "add_subdirectory(go)" should be placed after the following loine,
210243
# because it depends on paddle/optimizer.
211-
add_subdirectory(paddle/optimizer)
244+
add_subdirectory(paddle/legacy/optimizer)
212245
endif()
213246

214247
# "add_subdirectory(paddle)" and "add_subdirectory(python)" should be

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ PaddlePaddle uses this [Git branching model](http://nvie.com/posts/a-successful-
5858
create mode 100644 233
5959
```
6060

61+
NOTE: The `yapf` installed by `pip install pre-commit` and `conda install -c conda-forge pre-commit` is slightly different. Paddle developers use `pip install pre-commit`.
62+
6163
1. Build and test
6264

6365
Users can build PaddlePaddle natively on Linux and Mac OS X. But to unify the building environment and to make it easy for debugging, the recommended way is [using Docker](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/howto/dev/build_en.md).
@@ -157,4 +159,4 @@ This will enable VLOG messages generated by `buddy_allocator.{h,cc}` and in the
157159
- verbose level 1: [framework](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/framework)
158160
- verbose level 3: [operators](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/operators)
159161
- verbose level 5: [memory](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/memory), [platform](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/platform)
160-
- verbose level 7: [math](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/math)
162+
- verbose level 7: [math](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/legacy/math)

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ ENV HOME /root
2323
COPY ./paddle/scripts/docker/root/ /root/
2424

2525
RUN apt-get update && \
26-
apt-get install -y --allow-downgrades \
27-
git python-pip python-dev openssh-server bison \
26+
apt-get install -y --allow-downgrades patchelf \
27+
git python-pip python-dev python-opencv openssh-server bison \
2828
libnccl2=2.1.2-1+cuda8.0 libnccl-dev=2.1.2-1+cuda8.0 \
2929
wget unzip unrar tar xz-utils bzip2 gzip coreutils ntp \
3030
curl sed grep graphviz libjpeg-dev zlib1g-dev \
3131
python-matplotlib gcc-4.8 g++-4.8 \
32-
automake locales clang-format swig doxygen cmake \
32+
automake locales clang-format swig cmake \
3333
liblapack-dev liblapacke-dev \
3434
clang-3.8 llvm-3.8 libclang-3.8-dev \
3535
net-tools libtool ccache && \

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
[![Build Status](https://travis-ci.org/PaddlePaddle/Paddle.svg?branch=develop)](https://travis-ci.org/PaddlePaddle/Paddle)
55
[![Documentation Status](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](http://www.paddlepaddle.org/docs/develop/documentation/en/getstarted/index_en.html)
66
[![Documentation Status](https://img.shields.io/badge/中文文档-最新-brightgreen.svg)](http://www.paddlepaddle.org/docs/develop/documentation/zh/getstarted/index_cn.html)
7-
[![Coverage Status](https://coveralls.io/repos/github/PaddlePaddle/Paddle/badge.svg?branch=develop)](https://coveralls.io/github/PaddlePaddle/Paddle?branch=develop)
87
[![Release](https://img.shields.io/github/release/PaddlePaddle/Paddle.svg)](https://github.com/PaddlePaddle/Paddle/releases)
98
[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE)
109

@@ -19,6 +18,8 @@ learning to many products at Baidu.
1918
Our vision is to enable deep learning for everyone via PaddlePaddle.
2019
Please refer to our [release announcement](https://github.com/PaddlePaddle/Paddle/releases) to track the latest feature of PaddlePaddle.
2120

21+
### Lastest PaddlePaddle Version: [Fluid](https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/fluid)
22+
2223
## Features
2324

2425
- **Flexibility**

benchmark/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ paddle/rnn/imdb.pkl
77
caffe/image/logs
88
tensorflow/image/logs
99
tensorflow/rnn/logs
10+
fluid/models/*.pyc
11+
fluid/logs
12+
fluid/nohup.out

benchmark/fluid/Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
2+
3+
# Use UBUNTU_MIRROR can speed up apt-get speed.
4+
# ARG UBUNTU_MIRROR
5+
# RUN /bin/bash -c 'if [[ -n ${UBUNTU_MIRROR} ]]; then sed -i 's#http://archive.ubuntu.com/ubuntu#${UBUNTU_MIRROR}#g' /etc/apt/sources.list; fi'
6+
7+
RUN apt-get update && apt-get install -y python python-pip iputils-ping libgtk2.0-dev wget vim net-tools iftop python-opencv
8+
RUN ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.7 /usr/lib/libcudnn.so && ln -s /usr/lib/x86_64-linux-gnu/libnccl.so.2 /usr/lib/libnccl.so
9+
10+
# IMPORTANT:
11+
# Add "ENV http_proxy=http://ip:port" if your download is slow, and don't forget to unset it at runtime.
12+
# exmaple: unset http_proxy && unset https_proxy && python fluid_benchmark.py ...
13+
14+
RUN pip install -U pip
15+
RUN pip install -U kubernetes paddlepaddle
16+
17+
RUN sh -c 'echo "import paddle.v2 as paddle\npaddle.dataset.cifar.train10()\npaddle.dataset.flowers.fetch()" | python'
18+
RUN sh -c 'echo "import paddle.v2 as paddle\npaddle.dataset.mnist.train()\npaddle.dataset.mnist.test()\npaddle.dataset.imdb.fetch()" | python'
19+
RUN sh -c 'echo "import paddle.v2 as paddle\npaddle.dataset.imikolov.fetch()" | python'
20+
RUN pip uninstall -y paddlepaddle && mkdir /workspace
21+
22+
ADD https://raw.githubusercontent.com/PaddlePaddle/cloud/develop/docker/paddle_k8s /usr/bin
23+
ADD https://raw.githubusercontent.com/PaddlePaddle/cloud/develop/docker/k8s_tools.py /root
24+
RUN chmod +x /usr/bin/paddle_k8s
25+
26+
ADD *.whl /
27+
RUN pip install /*.whl && rm -f /*.whl
28+
29+
ENV LD_LIBRARY_PATH=/usr/local/lib
30+
ADD fluid_benchmark.py recordio_converter.py args.py recordio_converter.py run.sh run_fluid_benchmark.sh /workspace/
31+
ADD models/ /workspace/models/

benchmark/fluid/README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@ Currently supported `--model` argument include:
2424

2525
* Run the following command to start a benchmark job locally:
2626
```bash
27-
python fluid_benchmark.py --model mnist --device GPU
27+
python fluid_benchmark.py --model mnist --device GPU
2828
```
2929
You can choose to use GPU/CPU training. With GPU training, you can specify
3030
`--gpus <gpu_num>` to run multi GPU training.
31+
You can set async mode parameter server. With async mode, you can specify
32+
`--async_mode` to train model asynchronous.
3133
* Run distributed training with parameter servers:
34+
* see [run_fluid_benchmark.sh](https://github.com/PaddlePaddle/Paddle/blob/develop/benchmark/fluid/run_fluid_benchmark.sh) as an example.
3235
* start parameter servers:
3336
```bash
3437
PADDLE_TRAINING_ROLE=PSERVER PADDLE_PSERVER_PORT=7164 PADDLE_PSERVER_IPS=127.0.0.1 PADDLE_TRAINERS=1 PADDLE_CURRENT_IP=127.0.0.1 PADDLE_TRAINER_ID=0 python fluid_benchmark.py --model mnist --device GPU --update_method pserver
38+
sleep 15
3539
```
3640
* start trainers:
3741
```bash
@@ -42,13 +46,37 @@ Currently supported `--model` argument include:
4246
PADDLE_PSERVER_PORT=7164 PADDLE_TRAINER_IPS=192.168.0.2,192.168.0.3 PADDLE_CURRENT_IP=127.0.0.1 PADDLE_TRAINER_ID=0 python fluid_benchmark.py --model mnist --device GPU --update_method nccl2
4347
```
4448

49+
## Prepare the RecordIO file to Achieve Better Performance
50+
51+
Run the following command will generate RecordIO files like "mnist.recordio" under the path
52+
and batch_size you choose, you can use batch_size=1 so that later reader can change the batch_size
53+
at any time using `fluid.batch`.
54+
55+
```bash
56+
python -c 'from recordio_converter import *; prepare_mnist("data", 1)'
57+
```
58+
4559
## Run Distributed Benchmark on Kubernetes Cluster
4660

61+
You may need to build a Docker image before submitting a cluster job onto Kubernetes, or you will
62+
have to start all those processes mannually on each node, which is not recommended.
63+
64+
To build the Docker image, you need to choose a paddle "whl" package to run with, you may either
65+
download it from
66+
http://www.paddlepaddle.org/docs/develop/documentation/zh/build_and_install/pip_install_en.html or
67+
build it by your own. Once you've got the "whl" package, put it under the current directory and run:
68+
69+
```bash
70+
docker build -t [your docker image name]:[your docker image tag] .
71+
```
72+
73+
Then push the image to a Docker registry that your Kubernetes cluster can reach.
74+
4775
We provide a script `kube_gen_job.py` to generate Kubernetes yaml files to submit
4876
distributed benchmark jobs to your cluster. To generate a job yaml, just run:
4977
5078
```bash
51-
python kube_gen_job.py --jobname myjob --pscpu 4 --cpu 8 --gpu 8 --psmemory 20 --memory 40 --pservers 4 --trainers 4 --entry "python fluid_benchmark.py --model mnist --parallel 1 --device GPU --update_method pserver " --disttype pserver
79+
python kube_gen_job.py --jobname myjob --pscpu 4 --cpu 8 --gpu 8 --psmemory 20 --memory 40 --pservers 4 --trainers 4 --entry "python fluid_benchmark.py --model mnist --gpus 8 --device GPU --update_method pserver " --disttype pserver
5280
```
5381
5482
Then the yaml files are generated under directory `myjob`, you can run:

0 commit comments

Comments
 (0)