Skip to content

Commit cc04a7d

Browse files
committed
Merge branch 'develop' of https://github.com/baidu/Paddle into bilinear
2 parents db17575 + 125c19a commit cc04a7d

25 files changed

+228
-157
lines changed

.travis.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,21 @@ addons:
3838
- curl
3939
- lcov
4040
- graphviz
41+
- swig
4142
before_install:
43+
- |
44+
if [ ${JOB} == "BUILD_AND_TEST" ]; then
45+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
46+
TRAVIS_COMMIT_RANGE="FETCH_HEAD...$TRAVIS_BRANCH"
47+
fi
48+
git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md$)' || {
49+
echo "Only markdown docs were updated, stopping build process."
50+
exit
51+
}
52+
fi
4253
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo paddle/scripts/travis/before_install.linux.sh; fi
4354
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then paddle/scripts/travis/before_install.osx.sh; fi
44-
- pip install wheel protobuf sphinx breathe recommonmark
55+
- pip install wheel protobuf sphinx breathe recommonmark virtualenv numpy
4556
script:
4657
- paddle/scripts/travis/main.sh
4758
notifications:

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,26 @@ if(NOT WITH_GPU)
9595
add_definitions(-DHPPL_STUB_FUNC)
9696
list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS cu)
9797
else()
98+
if(${CUDA_VERSION_MAJOR} GREATER 6)
99+
if(COMPILER_SUPPORT_CXX11)
100+
LIST(APPEND CUDA_NVCC_FLAGS -std=c++11)
101+
endif()
102+
endif()
103+
98104
# TODO(yuyang18): Change it to remove std=c++11 in cuda compile.
99105
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
100106
if(NOT CUDNN_FOUND)
101107
message(FATAL_ERROR "Paddle need cudnn to compile")
102108
endif()
109+
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-g -O3 --use_fast_math")
110+
111+
if(WITH_AVX)
112+
if(AVX_FOUND)
113+
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler -mavx")
114+
endif(AVX_FOUND)
115+
else(WITH_AVX)
116+
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler -msse3")
117+
endif(WITH_AVX)
103118

104119
if(WITH_DSO)
105120
set(CUDA_LIBRARIES "")

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ developed by Baidu scientists and engineers for the purpose of applying deep
1414
learning to many products at Baidu.
1515

1616
Our vision is to enable deep learning for everyone via PaddlePaddle.
17-
Please refer to our [release log](https://github.com/baidu/Paddle/releases) to track the latest feature of PaddlePaddle.
17+
Please refer to our [release announcement](https://github.com/baidu/Paddle/releases) to track the latest feature of PaddlePaddle.
1818

1919
## Features
2020

cmake/util.cmake

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,6 @@ macro(add_simple_unittest TARGET_NAME)
188188
add_unittest(${TARGET_NAME} ${TARGET_NAME}.cpp)
189189
endmacro()
190190

191-
macro(add_paddle_culib TARGET_NAME)
192-
set(NVCC_FLAG ${CUDA_NVCC_FLAGS})
193-
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};--use_fast_math)
194-
cuda_add_library(${TARGET_NAME} STATIC ${ARGN})
195-
set(CUDA_NVCC_FLAGS ${NVCC_FLAG})
196-
endmacro()
197-
198-
199191
# Creates C resources file from files in given resource file
200192
function(create_resources res_file output)
201193
# Create empty output file

demo/quick_start/preprocess.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@
2121
set -e
2222

2323
export LC_ALL=C
24+
UNAME_STR=`uname`
25+
26+
if [[ ${UNAME_STR} == 'Linux' ]]; then
27+
SHUF_PROG='shuf'
28+
else
29+
SHUF_PROG='gshuf'
30+
fi
2431

2532
mkdir -p data/tmp
2633
python preprocess.py -i data/reviews_Electronics_5.json.gz
2734
# uniq and shuffle
2835
cd data/tmp
2936
echo 'uniq and shuffle...'
30-
cat pos_*|sort|uniq|shuf> pos.shuffed
31-
cat neg_*|sort|uniq|shuf> neg.shuffed
37+
cat pos_*|sort|uniq|${SHUF_PROG}> pos.shuffed
38+
cat neg_*|sort|uniq|${SHUF_PROG}> neg.shuffed
3239

3340
min_len=`sed -n '$=' neg.shuffed`
3441
test_num=$((min_len/10))
@@ -42,8 +49,8 @@ head -n$train_num neg.shuffed >train.neg
4249
tail -n$test_num pos.shuffed >test.pos
4350
tail -n$test_num neg.shuffed >test.neg
4451

45-
cat train.pos train.neg|shuf>../train.txt
46-
cat test.pos test.neg|shuf>../test.txt
52+
cat train.pos train.neg | ${SHUF_PROG} >../train.txt
53+
cat test.pos test.neg | ${SHUF_PROG} >../test.txt
4754

4855
cd -
4956
echo 'data/train.txt' > data/train.list

doc/build/build_from_source.md

Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Installing from Sources
44
* [1. Download and Setup](#download)
55
* [2. Requirements](#requirements)
66
* [3. Build on Ubuntu](#ubuntu)
7-
* [4. Build on Mac OS X](#mac)
87

98
## <span id="download">Download and Setup</span>
109
You can download PaddlePaddle from the [github source](https://github.com/gangliao/Paddle).
@@ -191,121 +190,3 @@ sudo pip install <path to install>/opt/paddle/share/wheels/*.whl
191190
# or just run
192191
sudo paddle version
193192
```
194-
195-
## <span id="mac">Building on Mac OS X</span>
196-
197-
### Prerequisites
198-
This guide is based on Mac OS X 10.11 (El Capitan). Note that if you are running an up to date version of OS X,
199-
you will already have Python 2.7.10 and Numpy 1.8 installed.
200-
201-
The best option is to use the package manager homebrew to handle installations and upgrades for you.
202-
To install [homebrew](http://brew.sh/), first open a terminal window (you can find Terminal in the Utilities folder in Applications), and issue the command:
203-
204-
```bash
205-
# install brew
206-
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
207-
# install pip
208-
easy_install pip
209-
```
210-
211-
### Install Dependencies
212-
213-
- **CPU Dependencies**
214-
215-
```bash
216-
# Install fundamental dependents
217-
brew install glog gflags cmake protobuf openblas
218-
219-
# Install google test on Mac OS X
220-
# Download gtest 1.7.0
221-
wget https://github.com/google/googletest/archive/release-1.7.0.tar.gz
222-
tar -xzf googletest-release-1.7.0.tar.gz && cd googletest-release-1.7.0
223-
# Build gtest
224-
mkdir build && cd build && cmake .. && make
225-
# Install gtest library
226-
sudo cp -r ../include/gtest /usr/local/include/
227-
sudo cp lib*.a /usr/local/lib
228-
```
229-
230-
- **GPU Dependencies(optional)**
231-
232-
To build GPU version, you will need the following installed:
233-
234-
1. a CUDA-capable GPU
235-
2. Mac OS X 10.11 or later
236-
2. the Clang compiler and toolchain installed using Xcode
237-
3. NVIDIA CUDA Toolkit (available at http://developer.nvidia.com/cuda-downloads)
238-
4. NVIDIA cuDNN Library (availabel at https://developer.nvidia.com/cudnn)
239-
240-
The CUDA development environment relies on tight integration with the host development environment,
241-
including the host compiler and C runtime libraries, and is therefore only supported on
242-
distribution versions that have been qualified for this CUDA Toolkit release.
243-
244-
1. After downloading cuDNN library, issue the following commands:
245-
246-
```bash
247-
sudo tar -xzf cudnn-7.5-osx-x64-v5.0-ga.tgz -C /usr/local
248-
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib/libcudnn*
249-
```
250-
2. Then you need to set DYLD\_LIBRARY\_PATH, PATH environment variables in ~/.bashrc.
251-
252-
```bash
253-
export DYLD_LIBRARY_PATH=/usr/local/cuda/lib:$DYLD_LIBRARY_PATH
254-
export PATH=/usr/local/cuda/bin:$PATH
255-
```
256-
257-
### Build and Install
258-
259-
As usual, the best option is to create build folder under paddle project directory.
260-
261-
```bash
262-
mkdir build && cd build
263-
cmake ..
264-
```
265-
266-
CMake first check PaddlePaddle's dependencies in system default path. After installing some optional
267-
libraries, corresponding build option will be set automatically (for instance, glog, gtest and gflags).
268-
If still not found, you can manually set it based on CMake error information from your screen.
269-
270-
As a simple example, consider the following:
271-
272-
- **Only CPU**
273-
274-
```bash
275-
cmake .. -DWITH_GPU=OFF
276-
```
277-
- **GPU**
278-
279-
```bash
280-
cmake .. -DWITH_GPU=ON
281-
```
282-
283-
- **GPU with doc and swig**
284-
285-
```bash
286-
cmake .. -DWITH_GPU=ON -DWITH_DOC=ON -DWITH_SWIG_PY=ON
287-
```
288-
289-
Finally, you can build PaddlePaddle:
290-
291-
```bash
292-
# you can add build option here, such as:
293-
cmake .. -DWITH_GPU=ON -DCMAKE_INSTALL_PREFIX=<installation path>
294-
# please use sudo make install, if you want to install PaddlePaddle into the system
295-
make -j `sysctl -n hw.ncpu` && make install
296-
# set PaddlePaddle installation path in ~/.bashrc
297-
export PATH=<installation path>/bin:$PATH
298-
```
299-
**Note:**
300-
301-
If you set `WITH_SWIG_PY=ON`, related python dependencies also need to be installed.
302-
Otherwise, PaddlePaddle will automatically install python dependencies
303-
at first time when user run paddle commands, such as `paddle version`, `paddle train`.
304-
It may require sudo privileges:
305-
306-
```bash
307-
# you can run
308-
sudo pip install <path to install>/opt/paddle/share/wheels/*.whl
309-
# or just run
310-
sudo paddle version
311-
```

doc_cn/demo/quick_start/index.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ define_py_data_sources2(train_list='data/train.list',
134134
* obj="process": 指定生成数据的函数
135135
* args={"dictionary": word_dict}: 额外的参数,这里指定词典
136136

137-
更详细用例请参考文档<a href = "../../../doc/ui/data_provider/python_case.html">Python Use Case</a>,
138-
数据格式和详细文档请参考<a href = "../../../doc/ui/data_provider/pydataprovider2.html">
139-
PyDataProviderWrapper</a>。
137+
更详细数据格式和用例请参考<a href = "../../ui/data_provider/pydataprovider2.html">
138+
PyDataProvider2</a>。
140139

141140
## 网络结构(Network Architecture)
142141
本节我们将专注于网络结构的介绍。

doc_cn/faq/index.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,40 @@ PaddlePaddle的参数使用名字 :code:`name` 作为参数的ID,相同名字
177177
178178
pip install --upgrade pip
179179
180+
8. python相关的单元测试都过不了
181+
--------------------------------
182+
183+
如果出现以下python相关的单元测试都过不了的情况:
184+
185+
.. code-block:: bash
186+
187+
24 - test_PyDataProvider (Failed)
188+
26 - test_RecurrentGradientMachine (Failed)
189+
27 - test_NetworkCompare (Failed)
190+
28 - test_PyDataProvider2 (Failed)
191+
32 - test_Prediction (Failed)
192+
33 - test_Compare (Failed)
193+
34 - test_Trainer (Failed)
194+
35 - test_TrainerOnePass (Failed)
195+
36 - test_CompareTwoNets (Failed)
196+
37 - test_CompareTwoOpts (Failed)
197+
38 - test_CompareSparse (Failed)
198+
39 - test_recurrent_machine_generation (Failed)
199+
40 - test_PyDataProviderWrapper (Failed)
200+
41 - test_config_parser (Failed)
201+
42 - test_swig_api (Failed)
202+
43 - layers_test (Failed)
203+
204+
并且查询PaddlePaddle单元测试的日志,提示:
205+
206+
.. code-block:: bash
207+
208+
paddle package is already in your PYTHONPATH. But unittest need a clean environment.
209+
Please uninstall paddle package before start unittest. Try to 'pip uninstall paddle'.
210+
211+
解决办法是:卸载paddle包 :code:`pip uninstall paddle`。
212+
213+
原因是:单元测试使用了一个旧版本的python包,而没有测试到代码中实际修改的python包。即单元测试需要一个干净的环境:
214+
215+
* 如果paddle包已经在python的site-packages里面了,那么单元测试时使用的paddle包,就是site-packages里面的python包,而不是源码目录里 :code:`/python` 目录下的python包。
216+
* 即便设置了 :code:`PYTHONPATH` 到 :code:`/python` 也没用,因为python的搜索路径是优先已经安装的python包。

paddle/api/paddle_api_config.py.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
PADDLE_BUILD_DIR="@CMAKE_CURRENT_BINARY_DIR@/../"
22
WITH_GPU="@WITH_GPU@"
33
PROTOBUF_LIB="@PROTOBUF_LIBRARY@"
4+
ZLIB_LIB="@ZLIB_LIBRARIES@"
45
CMAKE_THREAD_LIB="@CMAKE_THREAD_LIBS_INIT@"
56
CMAKE_DL_LIBS="@CMAKE_DL_LIBS@"
67

@@ -15,3 +16,4 @@ GFLAGS_LOCATION="@GFLAGS_LOCATION@"
1516
CBLAS_LIBRARIES="@CBLAS_LIBS@"
1617

1718
CUDA_LIBRARIES="@CUDA_LIBRARIES@"
19+
WITH_COVERALLS="@ON_COVERALLS@"

paddle/api/paddle_ld_flags.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(self):
3838
self.paddle_build_dir = os.path.abspath(self.paddle_build_dir)
3939
self.with_gpu = PaddleLDFlag.cmake_bool(WITH_GPU)
4040
self.protolib = PROTOBUF_LIB
41+
self.zlib = ZLIB_LIB
4142
self.thread = CMAKE_THREAD_LIB
4243
self.dl_libs = CMAKE_DL_LIBS
4344
self.with_python = PaddleLDFlag.cmake_bool(WITH_PYTHON)
@@ -47,6 +48,7 @@ def __init__(self):
4748
self.glog_libs = LIBGLOG_LIBRARY
4849

4950
self.with_gflags = PaddleLDFlag.cmake_bool(WITH_GFLAGS)
51+
self.with_coverage = PaddleLDFlag.cmake_bool(WITH_COVERALLS)
5052
self.gflags_libs = GFLAGS_LIBRARIES
5153
self.gflags_location = GFLAGS_LOCATION
5254
self.cblas_libs = CBLAS_LIBRARIES
@@ -64,7 +66,7 @@ def libs_dir_str(self):
6466

6567
def parent_dir_str(self):
6668
libdirs = PARENT_LIB_DIRS
67-
return " ".join(map(lambda x: "-L" + os.path.join(self.paddle_build_dir, '..', x),
69+
return " ".join(map(lambda x: "-L" + os.path.join(self.paddle_build_dir, '..', x),
6870
libdirs))
6971

7072
def libs_str(self):
@@ -82,6 +84,7 @@ def libs_str(self):
8284
"-lpaddle_cuda",
8385
"-lpaddle_api",
8486
self.normalize_flag(self.protolib),
87+
self.normalize_flag(self.zlib),
8588
self.normalize_flag(self.thread),
8689
self.normalize_flag(self.dl_libs),
8790
self.normalize_flag(self.cblas_libs),
@@ -95,6 +98,8 @@ def libs_str(self):
9598
libs.append(self.normalize_flag(self.gflags_libs))
9699
if self.with_gpu:
97100
libs.append(self.normalize_flag(self.curt))
101+
if self.with_coverage:
102+
libs.append("-fprofile-arcs")
98103
return " ".join(filter(lambda l: len(l) != 0, libs))
99104

100105
def normalize_flag(self, cmake_flag):
@@ -131,8 +136,14 @@ def cmake_bool(cmake_str):
131136
return False
132137
else:
133138
return True
134-
139+
def c_flag(self):
140+
if self.with_coverage:
141+
return ["-fprofile-arcs", "-ftest-coverage", "-O0", "-g"]
142+
else:
143+
return None
135144
except ImportError:
136145
class PaddleLDFlag(object):
137146
def ldflag_str(self):
138147
pass
148+
def c_flag(self):
149+
pass

0 commit comments

Comments
 (0)