diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8f53abacb4052febc23c6ac76f2481776730056e..4b0682c4fe991a5656e02d6a1845f7d73f61d6ff 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,7 +30,7 @@ include(simd)
################################ Configurations #######################################
option(WITH_GPU "Compile PaddlePaddle with NVIDIA GPU" ${CUDA_FOUND})
option(WITH_AVX "Compile PaddlePaddle with AVX intrinsics" ${AVX_FOUND})
-option(WITH_DSO "Compile PaddlePaddle with dynamic linked CUDA" OFF)
+option(WITH_DSO "Compile PaddlePaddle with dynamic linked CUDA" ON)
option(WITH_TESTING "Compile PaddlePaddle with unit testing" ON)
option(WITH_SWIG_PY "Compile PaddlePaddle with inference api" ON)
option(WITH_STYLE_CHECK "Compile PaddlePaddle with style check" ON)
diff --git a/cmake/util.cmake b/cmake/util.cmake
index 7da52bb758a3ab28db85f7c6c4d3a99b141e6342..24ad5c815ca20d9b6b317b1be4d2dc93a9e06fba 100644
--- a/cmake/util.cmake
+++ b/cmake/util.cmake
@@ -108,6 +108,7 @@ function(link_paddle_exe TARGET_NAME)
endif()
if(WITH_GPU)
+ target_link_libraries(${TARGET_NAME} ${CUDA_CUDART_LIBRARY})
if(NOT WITH_DSO OR WITH_METRIC)
target_link_libraries(${TARGET_NAME}
${CUDNN_LIBRARY}
diff --git a/demo/image_classification/train.sh b/demo/image_classification/train.sh
index 6fc11caf1c75192242482c2e85f8167eb9fba4ec..e45bd47ad5925c6674d628a70a7ad7c4d5d5c173 100755
--- a/demo/image_classification/train.sh
+++ b/demo/image_classification/train.sh
@@ -27,5 +27,6 @@ paddle train \
--num_passes=300 \
--save_dir=$output \
2>&1 | tee $log
+paddle usage -l $log -e $? -n "image_classification_train" >/dev/null 2>&1
python -m paddle.utils.plotcurve -i $log > plot.png
diff --git a/demo/introduction/train.sh b/demo/introduction/train.sh
index b7bbb90ddd287e3e312a490b53924ae76fb20d2c..2ce6446d7c943ffc9bea8da43d153539f6f9f15f 100755
--- a/demo/introduction/train.sh
+++ b/demo/introduction/train.sh
@@ -19,3 +19,4 @@ paddle train \
--save_dir=./output \
--num_passes=30 \
2>&1 |tee 'train.log'
+paddle usage -l "train.log" -e $? -n "introduction" >/dev/null 2>&1
diff --git a/demo/mnist/train.sh b/demo/mnist/train.sh
index da90cd749a02976633d0f0d6e4352d8a85c7cdef..ca2b1ad9eb960685b95b0f294a9b929e1a4acab1 100755
--- a/demo/mnist/train.sh
+++ b/demo/mnist/train.sh
@@ -27,5 +27,6 @@ paddle train \
--num_passes=100 \
--save_dir=$output \
2>&1 | tee $log
+paddle usage -l $log -e $? -n "mnist_train" >/dev/null 2>&1
python -m paddle.utils.plotcurve -i $log > plot.png
diff --git a/demo/quick_start/cluster/cluster_train.sh b/demo/quick_start/cluster/cluster_train.sh
index aac9b89b14b98ac8e2db7def19e5f06c01682493..a7b1f01064b29cf6abc4cd6b706ee466a6d6da36 100755
--- a/demo/quick_start/cluster/cluster_train.sh
+++ b/demo/quick_start/cluster/cluster_train.sh
@@ -25,6 +25,7 @@ log_file="$bin_dir/train.log"
pushd "$home_dir"
cfg=trainer_config.lr.py
paddle train \
+ --start_pserver=false \
--config=$cfg \
--save_dir=${model_dir} \
--trainer_count=4 \
diff --git a/demo/quick_start/predict.sh b/demo/quick_start/predict.sh
index f02e5038e92790c7f1ddcd84a09c6d9a02f84ac4..e47c2dd01fb5c919203964e298018e6dc2bd366e 100755
--- a/demo/quick_start/predict.sh
+++ b/demo/quick_start/predict.sh
@@ -26,5 +26,7 @@ paddle train \
--init_model_path=$model \
--config_args=is_predict=1 \
--predict_output_dir=. \
+2>&1 | tee 'predict.log'
+paddle usage -l 'predict.log' -e $? -n "quick_start_predict_${cfg}" >/dev/null 2>&1
mv rank-00000 result.txt
diff --git a/demo/quick_start/train.sh b/demo/quick_start/train.sh
index e3595fce7519297058e1eeb66487692267ddcfcc..01697fed48054be8ad98a01d4cbb5029e6a1ead0 100755
--- a/demo/quick_start/train.sh
+++ b/demo/quick_start/train.sh
@@ -31,3 +31,4 @@ paddle train \
--show_parameter_stats_period=100 \
--test_all_data_in_one_period=1 \
2>&1 | tee 'train.log'
+paddle usage -l "train.log" -e $? -n "quick_start_${cfg}" >/dev/null 2>&1
diff --git a/demo/recommendation/run.sh b/demo/recommendation/run.sh
index e341d1cc7a3267bef9db916719b2e4b1981e31bc..22aef556082ba429e9ca7c6dd3ec72699b9dbcf4 100755
--- a/demo/recommendation/run.sh
+++ b/demo/recommendation/run.sh
@@ -22,3 +22,4 @@ paddle train \
--log_period=100 \
--dot_period=1 \
--num_passes=50 2>&1 | tee 'log.txt'
+paddle usage -l log.txt -e $? -n "recommendation" >/dev/null 2>&1
diff --git a/demo/semantic_role_labeling/test.sh b/demo/semantic_role_labeling/test.sh
index 11d9d6a19c1b17ad1b7540ee7a03017f85dd821e..095bbff2ea42627a13d8ebab436f5a05abc09743 100755
--- a/demo/semantic_role_labeling/test.sh
+++ b/demo/semantic_role_labeling/test.sh
@@ -38,3 +38,4 @@ paddle train \
--config_args=is_test=1 \
--test_all_data_in_one_period=1 \
2>&1 | tee 'test.log'
+paddle usage -l test.log -e $? -n "semantic_role_labeling_test" >/dev/null 2>&1
diff --git a/demo/semantic_role_labeling/train.sh b/demo/semantic_role_labeling/train.sh
index 9354e72f46dc4dfc46138a04c330933d404c6cb8..eee14010d7b04a1b824f39090fa82fc532085e0d 100755
--- a/demo/semantic_role_labeling/train.sh
+++ b/demo/semantic_role_labeling/train.sh
@@ -27,3 +27,4 @@ paddle train \
--load_missing_parameter_strategy=rand \
--test_all_data_in_one_period=1 \
2>&1 | tee 'train.log'
+paddle usage -l train.log -e $? -n "semantic_role_labeling_train" >/dev/null 2>&1
diff --git a/demo/sentiment/test.sh b/demo/sentiment/test.sh
index 8af827c3388c8df88a872bd87d121a4f9631c3ff..85c4f3ccfc3ede23fcf701769b9701ecbf57c789 100755
--- a/demo/sentiment/test.sh
+++ b/demo/sentiment/test.sh
@@ -37,3 +37,4 @@ paddle train --config=$net_conf \
--trainer_count=4 \
--config_args=is_test=1 \
2>&1 | tee 'test.log'
+paddle usage -l test.log -e $? -n "sentiment_test" >/dev/null 2>&1
diff --git a/demo/sentiment/train.sh b/demo/sentiment/train.sh
index 5ce8bf4b997d962b9b61593cec0954d76c4874bc..14620f733bf03444e5ba3b3b792dfbed6146ecde 100755
--- a/demo/sentiment/train.sh
+++ b/demo/sentiment/train.sh
@@ -27,3 +27,4 @@ paddle train --config=$config \
--show_parameter_stats_period=100 \
--test_all_data_in_one_period=1 \
2>&1 | tee 'train.log'
+paddle usage -l train.log -e $? -n "sentiment_train" >/dev/null 2>&1
diff --git a/demo/seqToseq/paraphrase/train.sh b/demo/seqToseq/paraphrase/train.sh
index 33a42f6eff2b0414c466d5f78c89989a6a517eb9..9bb6dbdb1d4c5e35bfb31855e0331f0250a69a20 100755
--- a/demo/seqToseq/paraphrase/train.sh
+++ b/demo/seqToseq/paraphrase/train.sh
@@ -27,3 +27,4 @@ paddle train \
--log_period=10 \
--dot_period=5 \
2>&1 | tee 'paraphrase/train.log'
+paddle usage -l 'paraphrase/train.log' -e $? -n "seqToseq_paraphrase_train" >/dev/null 2>&1
diff --git a/demo/seqToseq/translation/gen.sh b/demo/seqToseq/translation/gen.sh
index a700ae213473dfe7c5b77156de15775b8fe9a9f0..64b78f5e9654e7b206740f92e224e0164108c9f1 100755
--- a/demo/seqToseq/translation/gen.sh
+++ b/demo/seqToseq/translation/gen.sh
@@ -24,3 +24,4 @@ paddle train \
--test_pass=12 \
--trainer_count=1 \
2>&1 | tee 'translation/gen.log'
+paddle usage -l 'translation/gen.log' -e $? -n "seqToseq_translation_gen" >/dev/null 2>&1
diff --git a/demo/seqToseq/translation/train.sh b/demo/seqToseq/translation/train.sh
index bdece693e5c407c89bc172c461bac7f9b20560d3..b0ec9854b118cbb9ed39d6bed0cdd845403926a4 100755
--- a/demo/seqToseq/translation/train.sh
+++ b/demo/seqToseq/translation/train.sh
@@ -25,3 +25,4 @@ paddle train \
--log_period=10 \
--dot_period=5 \
2>&1 | tee 'translation/train.log'
+paddle usage -l 'translation/train.log' -e $? -n "seqToseq_translation_train" >/dev/null 2>&1
diff --git a/demo/sequence_tagging/train.sh b/demo/sequence_tagging/train.sh
index 9a706b98d8686101ba21b513644bdd791062ec26..37e196c84200dc26ccb523076a81dbc393b1280f 100755
--- a/demo/sequence_tagging/train.sh
+++ b/demo/sequence_tagging/train.sh
@@ -7,4 +7,6 @@ paddle train \
--dot_period=10 \
--log_period=1000 \
--test_period=0 \
- --num_passes=10
+ --num_passes=10 \
+2>&1 | tee 'train.log'
+paddle usage -l 'train.log' -e $? -n "sequence_tagging_train" >/dev/null 2>&1
diff --git a/demo/sequence_tagging/train_linear.sh b/demo/sequence_tagging/train_linear.sh
index 597b5afea9c63a8e209b69b6a40e74556e27ac31..ad6e2d8ee7f813c69f9dd250c6f7bbb4403a0ed5 100755
--- a/demo/sequence_tagging/train_linear.sh
+++ b/demo/sequence_tagging/train_linear.sh
@@ -7,3 +7,5 @@ paddle train \
--log_period=10000 \
--test_period=0 \
--num_passes=10
+2>&1 | tee 'train_linear.log'
+paddle usage -l 'train_linear.log' -e $? -n "sequence_tagging_train_linear" >/dev/null 2>&1
diff --git a/doc/faq/index_cn.rst b/doc/faq/index_cn.rst
index 7d425a05d46131d84ba895d0fefc3a592a9a36e1..6d5367177da2af6276698f94f86664a5b506dca2 100644
--- a/doc/faq/index_cn.rst
+++ b/doc/faq/index_cn.rst
@@ -286,22 +286,3 @@ PaddlePaddle的参数使用名字 :code:`name` 作为参数的ID,相同名字
.. code-block:: bash
paddle train --use_gpu=true --trainer_count=2 --gpu_id=2
-
-12. 编译源码提示warp-ctc/include/ctc.h 找不到的情况
----------------------------------------------------
-
-目前Paddle使用\ :code:`git submodule`\ 来引用一些第三方模块。简单的\
-:code:`git clone`\ 命令不能得到第三方模块的代码。需要使用\:
-
-.. code-block:: bash
-
- git clone --recursive https://github.com/PaddlePaddle/Paddle.git
-
-来获取所有源码。对于已经clone的git版本库,可以在Paddle的源码目录中执行\:
-
-.. code-block:: bash
-
- git submodule init
- git submodule update
-
-来获得所有第三方模块。
diff --git a/doc/getstarted/build_and_install/build_from_source_en.md b/doc/getstarted/build_and_install/build_from_source_en.md
index aaa07d49d3148266db27670a98c2b27db4dc0a8f..6954be3b2bb956755c7820bf285addfd15226874 100644
--- a/doc/getstarted/build_and_install/build_from_source_en.md
+++ b/doc/getstarted/build_and_install/build_from_source_en.md
@@ -11,32 +11,21 @@ You can download PaddlePaddle from the [github source](https://github.com/Paddle
```bash
git clone https://github.com/PaddlePaddle/Paddle paddle
cd paddle
-git submodule update --init --recursive
```
-
-If you already have a local PaddlePaddle repo and have not initialized the submodule, your local submodule folder will be empty. You can simply run the last line of the above codes in your PaddlePaddle home directory to initialize your submodule folder.
-
-If you have already initialized your submodule and you would like to sync with the upstream submodule repo, you can run the following command
-```
-git submodule update --remote
-```
-
## Requirements
To compile the source code, your computer must be equipped with the following dependencies.
- **Compiler**: GCC >= 4.8 or Clang >= 3.3 (AppleClang >= 5.1)
-- **CMake**: version >= 2.8
+- **CMake**: version >= 3.0 (at least CMake 3.4 on Mac OS X)
- **BLAS**: MKL, OpenBlas or ATLAS
-- **Protocol Buffers**: version >= 2.4, **Note: 3.x is not supported**
-- **Python**: only python 2.7 is supported currently
**Note:** For CUDA 7.0 and CUDA 7.5, GCC 5.0 and up are not supported!
For CUDA 8.0, GCC versions later than 5.3 are not supported!
### Options
-PaddlePaddle supports some build options. To enable it, first you need to install the related libraries.
+PaddlePaddle supports some build options.
@@ -47,12 +36,21 @@ PaddlePaddle supports some build options. To enable it, first you need to instal
-WITH_GPU | Compile with GPU mode. |
-WITH_DOUBLE | Compile with double precision floating-point, default: single precision. |
-WITH_TESTING | Compile with gtest for PaddlePaddle's unit testing. |
-WITH_DOC | Compile to generate PaddlePaddle's docs, default: disabled (OFF). |
-WITH_SWIG_PY | Compile with python predict API, default: disabled (OFF). |
-WITH_STYLE_CHECK | Compile with code style check, default: enabled (ON). |
+WITH_GPU | Compile PaddlePaddle with NVIDIA GPU |
+WITH_AVX | Compile PaddlePaddle with AVX intrinsics |
+WITH_DSO | Compile PaddlePaddle with dynamic linked CUDA |
+WITH_TESTING | Compile PaddlePaddle with unit testing |
+WITH_SWIG_PY | Compile PaddlePaddle with inference api |
+WITH_STYLE_CHECK | Compile PaddlePaddle with style check |
+WITH_PYTHON | Compile PaddlePaddle with python interpreter |
+WITH_DOUBLE | Compile PaddlePaddle with double precision |
+WITH_RDMA | Compile PaddlePaddle with RDMA support |
+WITH_TIMER | Compile PaddlePaddle with stats timer |
+WITH_PROFILER | Compile PaddlePaddle with GPU profiler |
+WITH_DOC | Compile PaddlePaddle with documentation |
+ON_COVERALLS | Compile PaddlePaddle with code coverage |
+COVERALLS_UPLOAD | Package code coverage data to coveralls |
+ON_TRAVIS | Exclude special unit test on Travis CI |
@@ -64,18 +62,15 @@ PaddlePaddle supports some build options. To enable it, first you need to instal
As a simple example, consider the following:
-1. **Python Dependencies(optional)**
+1. **BLAS Dependencies(optional)**
- To compile PaddlePaddle with python predict API, make sure swig installed and set `-DWITH_SWIG_PY=ON` as follows:
+ Paddle will find BLAS from system's default path. But you can specify MKL, OpenBLAS or ATLAS via `MKL_ROOT`, `OPENBLAS_ROOT` or `ATLAS_ROOT`.
```bash
- # install swig on ubuntu
- sudo apt-get install swig
- # install swig on Mac OS X
- brew install swig
-
- # active swig in cmake
- cmake .. -DWITH_SWIG_PY=ON
+ # specify MKL
+ cmake .. -DMKL_ROOT=
+ # or specify OpenBLAS
+ cmake .. -DOPENBLAS_ROOT=
```
2. **Doc Dependencies(optional)**
@@ -104,17 +99,9 @@ As a simple example, consider the following:
```bash
# necessary
sudo apt-get update
- sudo apt-get install -y g++ make cmake swig build-essential libatlas-base-dev python python-pip libpython-dev m4 libprotobuf-dev protobuf-compiler python-protobuf python-numpy git
- # optional
- sudo apt-get install libgoogle-glog-dev
- sudo apt-get install libgflags-dev
- sudo apt-get install libgtest-dev
- sudo pip install wheel
- pushd /usr/src/gtest
- cmake .
- make
- sudo cp *.a /usr/lib
- popd
+ sudo apt-get install -y g++ make cmake build-essential libatlas-base-dev python python-pip libpython-dev git
+ sudo pip install wheel numpy
+ sudo pip install 'protobuf>=3.0.0'
```
- **GPU Dependencies (optional)**
@@ -149,51 +136,17 @@ As usual, the best option is to create build folder under paddle project directo
```bash
mkdir build && cd build
-cmake ..
-```
-
-CMake first check PaddlePaddle's dependencies in system default path. After installing some optional
-libraries, corresponding build option will be set automatically (for instance, glog, gtest and gflags).
-If still not found, you can manually set it based on CMake error information from your screen.
-
-As a simple example, consider the following:
+```
-- **Only CPU with swig**
-
- ```bash
- cmake .. -DWITH_GPU=OFF -DWITH_SWIG_PY=ON
- ```
-- **GPU with swig**
-
- ```bash
- cmake .. -DWITH_GPU=ON -DWITH_SWIG_PY=ON
- ```
-
-- **GPU with doc and swig**
-
- ```bash
- cmake .. -DWITH_GPU=ON -DWITH_DOC=ON -DWITH_SWIG_PY=ON
- ```
-
-Finally, you can build PaddlePaddle:
+Finally, you can build and install PaddlePaddle:
```bash
# you can add build option here, such as:
-cmake .. -DWITH_GPU=ON -DCMAKE_INSTALL_PREFIX= -DWITH_SWIG_PY=ON
+cmake .. -DCMAKE_INSTALL_PREFIX=
# please use sudo make install, if you want to install PaddlePaddle into the system
make -j `nproc` && make install
# set PaddlePaddle installation path in ~/.bashrc
export PATH=/bin:$PATH
-```
-
-If you set `WITH_SWIG_PY=ON`, related python dependencies also need to be installed.
-Otherwise, PaddlePaddle will automatically install python dependencies
-at first time when user run paddle commands, such as `paddle version`, `paddle train`.
-It may require sudo privileges:
-
-```bash
-# you can run
+# install PaddlePaddle Python modules.
sudo pip install /opt/paddle/share/wheels/*.whl
-# or just run
-sudo paddle version
```
diff --git a/doc/getstarted/build_and_install/cmake/build_from_source_cn.rst b/doc/getstarted/build_and_install/cmake/build_from_source_cn.rst
index 3a52c8723bbccd70dd89e8913092d92813925f90..be0c1ffa451b2901ec06621dd4d886f800b4562e 100644
--- a/doc/getstarted/build_and_install/cmake/build_from_source_cn.rst
+++ b/doc/getstarted/build_and_install/cmake/build_from_source_cn.rst
@@ -40,4 +40,4 @@ PaddePaddle通过编译时指定路径来实现引用各种BLAS/CUDA/Cudnn库。
cmake .. -DMKL_ROOT=/opt/mkl/ -DCUDNN_ROOT=/opt/cudnnv5
-注意:这几个编译选项的设置,只在第一次cmake的时候有效。如果之后想要重新设置,推荐清理整个编译目录(``rm -rf``)后,再指定。
\ No newline at end of file
+注意:这几个编译选项的设置,只在第一次cmake的时候有效。如果之后想要重新设置,推荐清理整个编译目录(``rm -rf``)后,再指定。
diff --git a/doc/getstarted/build_and_install/docker_install_en.rst b/doc/getstarted/build_and_install/docker_install_en.rst
index 34279a29b2e4c84aa5039f2e5ab2c6ed9a06da2f..51a1a11674d98781d04137ff14bf8debe3277318 100644
--- a/doc/getstarted/build_and_install/docker_install_en.rst
+++ b/doc/getstarted/build_and_install/docker_install_en.rst
@@ -16,23 +16,13 @@ Developers can work on PaddlePaddle using Docker. This allows
developers to work on different platforms -- Linux, Mac OS X, and
Windows -- in a consistent way.
-The general development workflow with Docker and Bazel is as follows:
+The general development workflow with Docker and CMake is as follows:
1. Get the source code of Paddle:
.. code-block:: bash
- git clone --recursive https://github.com/PaddlePaddle/Paddle.git
-
-
- Here **git clone --recursive is required** as we have a submodule `warp-ctc `_.
-
- If you have used :code:`git clone https://github.com/PaddlePaddle/Paddle` and find that the directory :code:`warp-ctc` is
- empty, please use the following command to get the submodule.
-
- .. code-block:: bash
-
- git submodule update --init --recursive
+ git clone https://github.com/PaddlePaddle/Paddle.git
2. Build a development Docker image :code:`paddle:dev` from the source
@@ -162,7 +152,6 @@ source code:
cd ~
git clone https://github.com/PaddlePaddle/Paddle.git
cd Paddle
- git submodule update --init --recursive
docker build --build-arg WITH_AVX=OFF -t paddle:cpu-noavx -f paddle/scripts/docker/Dockerfile .
docker build --build-arg WITH_AVX=OFF -t paddle:gpu-noavx -f paddle/scripts/docker/Dockerfile.gpu .
diff --git a/doc/howto/dev/contribute_to_paddle_cn.md b/doc/howto/dev/contribute_to_paddle_cn.md
index e0a63f5a14c7b2e8953aa21739668ee2a9ebeff1..ee1b3213eaed3bfd94e449997dff9848b8fb4228 100644
--- a/doc/howto/dev/contribute_to_paddle_cn.md
+++ b/doc/howto/dev/contribute_to_paddle_cn.md
@@ -33,7 +33,6 @@ cd Paddle
git checkout -b develop # 创建 develop 分支
git remote add upstream https://github.com/PaddlePaddle/Paddle.git # 添加 upstream 到 baidu/Paddle
git pull upstream develop # 更新 upstream
-git submodule update --init --recursive
```
然后你可以通过做一个本地开发分支开始开发
diff --git a/doc/howto/dev/contribute_to_paddle_en.md b/doc/howto/dev/contribute_to_paddle_en.md
index e578f6fce8b94180da7d5de041a0e17b1d59f6ea..9b0d3e83c0dc264650eda73e6801c60a75439b4a 100644
--- a/doc/howto/dev/contribute_to_paddle_en.md
+++ b/doc/howto/dev/contribute_to_paddle_en.md
@@ -38,7 +38,6 @@ cd Paddle
git checkout -b develop # create develop branch.
git remote add upstream https://github.com/PaddlePaddle/Paddle.git # add upstream to baidu/Paddle
git pull upstream develop # update to upstream
-git submodule update --init --recursive
```
Then you can start to develop by making a local developement branch
diff --git a/paddle/api/paddle_api_config.py.in b/paddle/api/paddle_api_config.py.in
index e11ee920362aed3ec79a2e62d447d7dde4a99248..82f45ba6ccec49eb190d1814a67a575f311689e8 100644
--- a/paddle/api/paddle_api_config.py.in
+++ b/paddle/api/paddle_api_config.py.in
@@ -13,5 +13,5 @@ GFLAGS_LIBRARIES="@GFLAGS_LIBRARIES@"
GFLAGS_LOCATION="@GFLAGS_LOCATION@"
CBLAS_LIBRARIES="@CBLAS_LIBRARIES@"
-CUDA_LIBRARIES="@CUDA_cudart_shared_LIBRARY@"
+CUDA_LIBRARIES="@CUDA_CUDART_LIBRARY@"
WITH_COVERALLS="@ON_COVERALLS@"
diff --git a/paddle/cuda/CMakeLists.txt b/paddle/cuda/CMakeLists.txt
index 57fb89608f4bcf3e6829fe850a61c2a626adfbdc..a28ccd6f07cfd56b7f1978f67fdcf6e7e5fe6337 100755
--- a/paddle/cuda/CMakeLists.txt
+++ b/paddle/cuda/CMakeLists.txt
@@ -15,7 +15,6 @@ else()
endif()
set(CUDA_CXX_WITH_GPU_SOURCES
- src/hl_cudart_wrap.cc
src/hl_cuda_cublas.cc
src/hl_cuda_cudnn.cc
src/hl_cuda_device.cc)
diff --git a/paddle/cuda/include/hl_dso_loader.h b/paddle/cuda/include/hl_dso_loader.h
index 20c13f21e61a92b0635b686f6f724ae2b44518cc..276a07d3c735c771c851e8b4bd14c720f9ab6569 100644
--- a/paddle/cuda/include/hl_dso_loader.h
+++ b/paddle/cuda/include/hl_dso_loader.h
@@ -36,14 +36,6 @@ void GetCublasDsoHandle(void** dso_handle);
*/
void GetCudnnDsoHandle(void** dso_handle);
-/**
- * @brief load the DSO of CUDA Run Time
- *
- * @param **dso_handle dso handler
- *
- */
-void GetCudartDsoHandle(void** dso_handle);
-
/**
* @brief load the DSO of CURAND
*
diff --git a/paddle/cuda/src/hl_cuda_device.cc b/paddle/cuda/src/hl_cuda_device.cc
index a71eecba2736234dafaf6b67e5efac5358a30871..6dfb12e00b80db36ad2e53326b880c7d1ed59263 100644
--- a/paddle/cuda/src/hl_cuda_device.cc
+++ b/paddle/cuda/src/hl_cuda_device.cc
@@ -22,10 +22,9 @@ limitations under the License. */
#include
#include
#include
-#include "hl_cuda.h"
#include "hl_cuda.ph"
-#include "hl_dso_loader.h"
#include "hl_thread.ph"
+#include "hl_dso_loader.h"
#include "paddle/utils/Logging.h"
// clang-format on
@@ -77,78 +76,6 @@ CURAND_RAND_ROUTINE_EACH(DYNAMIC_LOAD_CURAND_WRAP)
#undef CURAND_RAND_ROUTINE_EACH
#undef DYNAMIC_LOAD_CURAND_WRAP
-std::once_flag cudart_dso_flag;
-void *cudart_dso_handle = nullptr;
-
-/**
- * The following macro definition can generate structs
- * (for each function) to dynamic load cuda routine
- * via operator overloading.
- *
- * note: default dynamic linked libs
- */
-#ifdef PADDLE_USE_DSO
-#define DYNAMIC_LOAD_CUDART_WRAP(__name) \
- struct DynLoad__##__name { \
- template \
- auto operator()(Args... args) -> decltype(__name(args...)) { \
- using cudart_func = decltype(__name(args...)) (*)(Args...); \
- std::call_once(cudart_dso_flag, GetCudartDsoHandle, &cudart_dso_handle); \
- void *p_##__name = dlsym(cudart_dso_handle, #__name); \
- return reinterpret_cast(p_##__name)(args...); \
- } \
- } __name; /* struct DynLoad__##__name */
-#else
-#define DYNAMIC_LOAD_CUDART_WRAP(__name) \
- struct DynLoad__##__name { \
- template \
- auto operator()(Args... args) -> decltype(__name(args...)) { \
- return __name(args...); \
- } \
- } __name; /* struct DynLoad__##__name */
-#endif
-
-/* include all needed cuda functions in HPPL */
-// clang-format off
-#define CUDA_ROUTINE_EACH(__macro) \
- __macro(cudaMalloc) \
- __macro(cudaHostAlloc) \
- __macro(cudaFree) \
- __macro(cudaFreeHost) \
- __macro(cudaMemcpy) \
- __macro(cudaMemset) \
- __macro(cudaMemcpyAsync) \
- __macro(cudaSetDevice) \
- __macro(cudaGetDevice) \
- __macro(cudaGetDeviceCount) \
- __macro(cudaGetDeviceProperties) \
- __macro(cudaDeviceSynchronize) \
- __macro(cudaDeviceCanAccessPeer) \
- __macro(cudaDeviceEnablePeerAccess) \
- __macro(cudaStreamCreate) \
- __macro(cudaStreamDestroy) \
- __macro(cudaStreamSynchronize) \
- __macro(cudaStreamWaitEvent) \
- __macro(cudaEventCreate) \
- __macro(cudaEventRecord) \
- __macro(cudaEventQuery) \
- __macro(cudaEventDestroy) \
- __macro(cudaEventSynchronize) \
- __macro(cudaEventElapsedTime) \
- __macro(cudaSetDeviceFlags) \
- __macro(cudaGetLastError) \
- __macro(cudaFuncSetCacheConfig) \
- __macro(cudaRuntimeGetVersion) \
- __macro(cudaGetErrorString) \
- __macro(cudaProfilerStart) \
- __macro(cudaProfilerStop)
-// clang-format on
-
-CUDA_ROUTINE_EACH(DYNAMIC_LOAD_CUDART_WRAP)
-
-#undef CUDA_ROUNTINE_EACH
-#undef DYNAMIC_LOAD_CUDART_WRAP
-
} /* namespace dynload */
/**
@@ -171,11 +98,11 @@ int g_cuda_lib_version = 0;
* Check build-in cuda function using glog and it **does not**
* support << operator for more details error info.
*/
-#define CHECK_CUDA(cudaFunc) \
- do { \
- cudaError_t cudaStat = cudaFunc; \
- CHECK_EQ(cudaSuccess, cudaStat) << "Cuda Error: " \
- << dynload::cudaGetErrorString(cudaStat); \
+#define CHECK_CUDA(cudaFunc) \
+ do { \
+ cudaError_t cudaStat = cudaFunc; \
+ CHECK_EQ(cudaSuccess, cudaStat) << "Cuda Error: " \
+ << cudaGetErrorString(cudaStat); \
} while (0)
/**
@@ -284,13 +211,13 @@ void hl_fini() {
tmp_stream = (char *)t_device[dev]->stream;
}
for (int j = 0; j < NUMBER_OF_THREAD_STREAM; j++) {
- CHECK_CUDA(dynload::cudaStreamDestroy(t_device[dev]->stream[j]));
+ CHECK_CUDA(cudaStreamDestroy(t_device[dev]->stream[j]));
}
/* free device memory */
hl_free_mem_device(t_device[dev]->gpu_mem);
hl_free_mem_host(t_device[dev]->cpu_mem);
- CHECK_CUDA(dynload::cudaEventDestroy(t_device[dev]->mem_event));
+ CHECK_CUDA(cudaEventDestroy(t_device[dev]->mem_event));
}
free(tmp);
@@ -308,7 +235,7 @@ void hl_set_device(int device) {
CHECK(device >= 0 && device < g_system_device_num && g_device[device])
<< "Device: " << device << " is not specified in startup.";
- CHECK_CUDA(dynload::cudaSetDevice(device));
+ CHECK_CUDA(cudaSetDevice(device));
/* switch thread stream */
for (int i = 0; i < NUMBER_OF_GLOBAL_STREAM; i++) {
@@ -336,7 +263,7 @@ void hl_set_device(int device) {
int hl_get_device() {
int device;
- CHECK_CUDA(dynload::cudaGetDevice(&device));
+ CHECK_CUDA(cudaGetDevice(&device));
return device;
}
@@ -344,7 +271,7 @@ void *hl_malloc_device(size_t size) {
void *dest_d;
CHECK(size) << __func__ << ": the size for device memory is 0, please check.";
- CHECK_CUDA(dynload::cudaMalloc((void **)&dest_d, size));
+ CHECK_CUDA(cudaMalloc((void **)&dest_d, size));
return dest_d;
}
@@ -352,7 +279,7 @@ void *hl_malloc_device(size_t size) {
void hl_free_mem_device(void *dest_d) {
CHECK_NOTNULL(dest_d);
- cudaError_t err = dynload::cudaFree(dest_d);
+ cudaError_t err = cudaFree(dest_d);
CHECK(cudaSuccess == err || cudaErrorCudartUnloading == err)
<< hl_get_device_error_string();
}
@@ -361,8 +288,7 @@ void *hl_malloc_host(size_t size) {
void *dest_h;
CHECK(size) << __func__ << ": the size for device memory is 0, please check.";
- CHECK_CUDA(
- dynload::cudaHostAlloc((void **)&dest_h, size, cudaHostAllocDefault));
+ CHECK_CUDA(cudaHostAlloc((void **)&dest_h, size, cudaHostAllocDefault));
return dest_h;
}
@@ -370,7 +296,7 @@ void *hl_malloc_host(size_t size) {
void hl_free_mem_host(void *dest_h) {
CHECK_NOTNULL(dest_h);
- cudaError_t err = dynload::cudaFreeHost(dest_h);
+ cudaError_t err = cudaFreeHost(dest_h);
CHECK(cudaSuccess == err || cudaErrorCudartUnloading == err)
<< hl_get_device_error_string();
}
@@ -381,11 +307,11 @@ void hl_memcpy(void *dst, void *src, size_t size) {
}
CHECK_NOTNULL(dst);
CHECK_NOTNULL(src);
- CHECK_CUDA(dynload::cudaMemcpy(dst, src, size, cudaMemcpyDefault));
+ CHECK_CUDA(cudaMemcpy(dst, src, size, cudaMemcpyDefault));
}
void hl_memset_device(void *dest_d, int value, size_t size) {
- CHECK_CUDA(dynload::cudaMemset(dest_d, value, size));
+ CHECK_CUDA(cudaMemset(dest_d, value, size));
}
void hl_memcpy_host2device(void *dest_d, void *src_h, size_t size) {
@@ -394,7 +320,7 @@ void hl_memcpy_host2device(void *dest_d, void *src_h, size_t size) {
}
CHECK_NOTNULL(src_h);
CHECK_NOTNULL(dest_d);
- CHECK_CUDA(dynload::cudaMemcpy(dest_d, src_h, size, cudaMemcpyHostToDevice));
+ CHECK_CUDA(cudaMemcpy(dest_d, src_h, size, cudaMemcpyHostToDevice));
}
void hl_memcpy_device2host(void *dest_h, void *src_d, size_t size) {
@@ -403,7 +329,7 @@ void hl_memcpy_device2host(void *dest_h, void *src_d, size_t size) {
}
CHECK_NOTNULL(dest_h);
CHECK_NOTNULL(src_d);
- CHECK_CUDA(dynload::cudaMemcpy(dest_h, src_d, size, cudaMemcpyDeviceToHost));
+ CHECK_CUDA(cudaMemcpy(dest_h, src_d, size, cudaMemcpyDeviceToHost));
}
void hl_memcpy_device2device(void *dest_d, void *src_d, size_t size) {
@@ -412,8 +338,7 @@ void hl_memcpy_device2device(void *dest_d, void *src_d, size_t size) {
}
CHECK_NOTNULL(dest_d);
CHECK_NOTNULL(src_d);
- CHECK_CUDA(
- dynload::cudaMemcpy(dest_d, src_d, size, cudaMemcpyDeviceToDevice));
+ CHECK_CUDA(cudaMemcpy(dest_d, src_d, size, cudaMemcpyDeviceToDevice));
}
void hl_memcpy_async(void *dst, void *src, size_t size, hl_stream_t stream) {
@@ -427,8 +352,7 @@ void hl_memcpy_async(void *dst, void *src, size_t size, hl_stream_t stream) {
CHECK_LT(stream, HPPL_STREAM_END);
cu_stream = t_resource.stream[stream];
- CHECK_CUDA(
- dynload::cudaMemcpyAsync(dst, src, size, cudaMemcpyDefault, cu_stream));
+ CHECK_CUDA(cudaMemcpyAsync(dst, src, size, cudaMemcpyDefault, cu_stream));
}
void hl_start() {
@@ -439,8 +363,7 @@ void hl_start() {
bool hl_device_can_access_peer(int device, int peerDevice) {
int canAccessPeer;
- CHECK_CUDA(
- dynload::cudaDeviceCanAccessPeer(&canAccessPeer, device, peerDevice));
+ CHECK_CUDA(cudaDeviceCanAccessPeer(&canAccessPeer, device, peerDevice));
if (canAccessPeer == 1) {
return true;
@@ -450,9 +373,9 @@ bool hl_device_can_access_peer(int device, int peerDevice) {
}
void hl_device_enable_peer_access(int peerDevice) {
- cudaError_t err = dynload::cudaDeviceEnablePeerAccess(peerDevice, 0);
+ cudaError_t err = cudaDeviceEnablePeerAccess(peerDevice, 0);
if (cudaErrorPeerAccessAlreadyEnabled == err) {
- dynload::cudaGetLastError();
+ cudaGetLastError();
} else {
CHECK_CUDA(err);
}
@@ -463,9 +386,9 @@ void hl_create_global_resources(hl_device_prop device_prop) {
int device = device_prop->device;
global_device_resources device_res = device_prop->device_resources;
- CHECK_CUDA(dynload::cudaSetDevice(device));
+ CHECK_CUDA(cudaSetDevice(device));
/* device properties */
- CHECK_CUDA(dynload::cudaGetDeviceProperties(&cu_prop, device));
+ CHECK_CUDA(cudaGetDeviceProperties(&cu_prop, device));
device_prop->major = cu_prop.major;
device_prop->minor = cu_prop.minor;
@@ -474,7 +397,7 @@ void hl_create_global_resources(hl_device_prop device_prop) {
/* create device stream */
for (int j = 0; j < NUMBER_OF_GLOBAL_STREAM; j++) {
- CHECK_CUDA(dynload::cudaStreamCreate(&device_res->stream[j]));
+ CHECK_CUDA(cudaStreamCreate(&device_res->stream[j]));
}
/* cublas init */
@@ -501,18 +424,18 @@ void hl_create_global_resources(hl_device_prop device_prop) {
device_res->gen_mutex = (pthread_mutex_t *)(malloc(sizeof(pthread_mutex_t)));
pthread_mutex_init(device_res->gen_mutex, NULL);
- CHECK_CUDA(dynload::cudaRuntimeGetVersion(&g_cuda_lib_version));
+ CHECK_CUDA(cudaRuntimeGetVersion(&g_cuda_lib_version));
}
int hl_get_cuda_version() { return g_cuda_lib_version; }
void hl_create_thread_resources(int device,
thread_device_resources device_res) {
- CHECK_CUDA(dynload::cudaSetDevice(device));
+ CHECK_CUDA(cudaSetDevice(device));
/* create thread stream */
for (int j = 0; j < NUMBER_OF_THREAD_STREAM; j++) {
- CHECK_CUDA(dynload::cudaStreamCreate(&device_res->stream[j]));
+ CHECK_CUDA(cudaStreamCreate(&device_res->stream[j]));
}
/* allocation device memory */
@@ -521,14 +444,14 @@ void hl_create_thread_resources(int device,
/* allocation host memory */
device_res->cpu_mem = (real *)hl_malloc_host(HPPL_GPU_MEMORY_SIZE);
- CHECK_CUDA(dynload::cudaEventCreate(&device_res->mem_event));
+ CHECK_CUDA(cudaEventCreate(&device_res->mem_event));
}
void hl_specify_devices_start(int *device, int number) {
if (hl_start_flag) return;
/* 1. get the number of devices */
- CHECK_CUDA(dynload::cudaGetDeviceCount(&g_system_device_num));
+ CHECK_CUDA(cudaGetDeviceCount(&g_system_device_num));
CHECK_NE(g_system_device_num, 0) << "[Start failed] there is no GPU device";
if (device == NULL) {
number = g_system_device_num;
@@ -640,7 +563,7 @@ void hl_stream_synchronize(hl_stream_t stream) {
<< ": the parameter stream is error.";
cu_stream = t_resource.stream[stream];
- CHECK_CUDA(dynload::cudaStreamSynchronize(cu_stream));
+ CHECK_CUDA(cudaStreamSynchronize(cu_stream));
}
void hl_create_event(hl_event_t *event) {
@@ -649,7 +572,7 @@ void hl_create_event(hl_event_t *event) {
struct _hl_event_st *st_event =
(struct _hl_event_st *)malloc(sizeof(struct _hl_event_st));
- CHECK_CUDA(dynload::cudaEventCreate(&st_event->cu_event));
+ CHECK_CUDA(cudaEventCreate(&st_event->cu_event));
*event = st_event;
}
@@ -659,8 +582,7 @@ float hl_event_elapsed_time(hl_event_t start, hl_event_t end) {
CHECK_NOTNULL(start);
CHECK_NOTNULL(end);
- CHECK_CUDA(
- dynload::cudaEventElapsedTime(&time, start->cu_event, end->cu_event));
+ CHECK_CUDA(cudaEventElapsedTime(&time, start->cu_event, end->cu_event));
return time;
}
@@ -672,7 +594,7 @@ void hl_stream_record_event(hl_stream_t stream, hl_event_t event) {
<< ": the parameter stream is error.";
cu_stream = t_resource.stream[stream];
- CHECK_CUDA(dynload::cudaEventRecord(event->cu_event, cu_stream));
+ CHECK_CUDA(cudaEventRecord(event->cu_event, cu_stream));
}
void hl_stream_wait_event(hl_stream_t stream, hl_event_t event) {
@@ -683,12 +605,12 @@ void hl_stream_wait_event(hl_stream_t stream, hl_event_t event) {
<< ": the parameter stream is error.";
cu_stream = t_resource.stream[stream];
- CHECK_CUDA(dynload::cudaStreamWaitEvent(cu_stream, event->cu_event, 0));
+ CHECK_CUDA(cudaStreamWaitEvent(cu_stream, event->cu_event, 0));
}
void hl_destroy_event(hl_event_t event) {
CHECK_NOTNULL(event);
- CHECK_CUDA(dynload::cudaEventDestroy(event->cu_event));
+ CHECK_CUDA(cudaEventDestroy(event->cu_event));
free(event);
event = NULL;
@@ -696,7 +618,7 @@ void hl_destroy_event(hl_event_t event) {
void hl_event_synchronize(hl_event_t event) {
CHECK_NOTNULL(event);
- CHECK_CUDA(dynload::cudaEventSynchronize(event->cu_event));
+ CHECK_CUDA(cudaEventSynchronize(event->cu_event));
}
void hl_get_device_name(char *name, int len, int device) {
@@ -725,24 +647,24 @@ void hl_get_device_compute_capability(int *major, int *minor, int device) {
*minor = g_device[device]->minor;
}
-int hl_get_device_last_error() { return (int)dynload::cudaGetLastError(); }
+int hl_get_device_last_error() { return (int)cudaGetLastError(); }
const char *hl_get_device_error_string() {
- cudaError_t err = dynload::cudaGetLastError();
- return dynload::cudaGetErrorString(err);
+ cudaError_t err = cudaGetLastError();
+ return cudaGetErrorString(err);
}
const char *hl_get_device_error_string(size_t err) {
- return dynload::cudaGetErrorString((cudaError_t)err);
+ return cudaGetErrorString((cudaError_t)err);
}
-void hl_device_synchronize() { CHECK_CUDA(dynload::cudaDeviceSynchronize()); }
+void hl_device_synchronize() { CHECK_CUDA(cudaDeviceSynchronize()); }
void hl_set_device_flags_block() {
- CHECK_CUDA(dynload::cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync));
+ CHECK_CUDA(cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync));
}
bool hl_cuda_event_is_ready(hl_event_t event) {
- cudaError_t err = dynload::cudaEventQuery(event->cu_event);
+ cudaError_t err = cudaEventQuery(event->cu_event);
CHECK(cudaSuccess == err || cudaErrorNotReady == err);
if (cudaErrorNotReady == err) {
@@ -751,6 +673,6 @@ bool hl_cuda_event_is_ready(hl_event_t event) {
return true;
}
-void hl_profiler_start() { CHECK_CUDA(dynload::cudaProfilerStart()); }
+void hl_profiler_start() { CHECK_CUDA(cudaProfilerStart()); }
-void hl_profiler_end() { CHECK_CUDA(dynload::cudaProfilerStop()); }
+void hl_profiler_end() { CHECK_CUDA(cudaProfilerStop()); }
diff --git a/paddle/cuda/src/hl_cudart_wrap.cc b/paddle/cuda/src/hl_cudart_wrap.cc
deleted file mode 100644
index ecc03a729dde2f2b4f8f004234a47d9272997a50..0000000000000000000000000000000000000000
--- a/paddle/cuda/src/hl_cudart_wrap.cc
+++ /dev/null
@@ -1,200 +0,0 @@
-/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License. */
-
-#ifdef PADDLE_USE_DSO
-
-#include
-#include
-#include "hl_dso_loader.h"
-
-/**
- * cudart wrapper: for dynamic load libcudart.so.
- * When nvcc compile cuda kernels, it will insert
- * some build-in runtime routines, which must be
- * provided by us if PADDLE_USE_DSO is true. If
- * PADDLE_USE_DSO is false, all of them must be
- * ignored to avoid multiple definitions.
- */
-namespace dynload {
-
-extern std::once_flag cudart_dso_flag;
-extern void *cudart_dso_handle;
-
-/**
- * The following macro definition can generate structs
- * (for each function) to dynamic load cuda routine
- * via operator overloading.
- **/
-#define DYNAMIC_LOAD_CUDART_WRAP(__name, __type) \
- struct DynLoad__##__name { \
- template \
- __type operator()(Args... args) { \
- typedef __type (*cudartFunc)(Args...); \
- std::call_once(cudart_dso_flag, GetCudartDsoHandle, &cudart_dso_handle); \
- void *p_##__name = dlsym(cudart_dso_handle, #__name); \
- return reinterpret_cast(p_##__name)(args...); \
- } \
- } __name; /* struct DynLoad__##__name */
-
-/* include all needed cuda functions in HPPL */
-// clang-format off
-#define CUDA_ROUTINE_EACH(__macro) \
- __macro(cudaLaunch, cudaError_t) \
- __macro(cudaSetupArgument, cudaError_t) \
- __macro(cudaConfigureCall, cudaError_t) \
- __macro(__cudaRegisterFatBinary, void**) \
- __macro(__cudaUnregisterFatBinary, void) \
- __macro(__cudaRegisterFunction, void) \
- __macro(__cudaRegisterVar, void) \
- __macro(__cudaRegisterManagedVar, void) \
- __macro(__cudaInitModule, char) \
- __macro(__cudaRegisterTexture, void) \
- __macro(__cudaRegisterSurface, void)
-// clang-format on
-
-CUDA_ROUTINE_EACH(DYNAMIC_LOAD_CUDART_WRAP)
-
-#if CUDART_VERSION >= 7000
-DYNAMIC_LOAD_CUDART_WRAP(cudaLaunchKernel, cudaError_t)
-#endif
-
-#undef CUDA_ROUNTINE_EACH
-
-} /* namespace dynload */
-
-#if CUDART_VERSION >= 7000
-__host__ cudaError_t CUDARTAPI cudaLaunchKernel(const void *func,
- dim3 gridDim,
- dim3 blockDim,
- void **args,
- size_t sharedMem,
- cudaStream_t stream) {
- return dynload::cudaLaunchKernel(
- func, gridDim, blockDim, args, sharedMem, stream);
-}
-#endif /* CUDART_VERSION >= 7000 */
-
-__host__ cudaError_t CUDARTAPI cudaLaunch(const void *func) {
- return dynload::cudaLaunch(func);
-}
-
-__host__ cudaError_t CUDARTAPI cudaSetupArgument(const void *arg,
- size_t size,
- size_t offset) {
- return dynload::cudaSetupArgument(arg, size, offset);
-}
-
-__host__ cudaError_t CUDARTAPI cudaConfigureCall(dim3 gridDim,
- dim3 blockDim,
- size_t sharedMem,
- cudaStream_t stream) {
- return dynload::cudaConfigureCall(gridDim, blockDim, sharedMem, stream);
-}
-
-extern "C" {
-
-void **CUDARTAPI __cudaRegisterFatBinary(void *fatCubin) {
- return dynload::__cudaRegisterFatBinary(fatCubin);
-}
-
-void CUDARTAPI __cudaUnregisterFatBinary(void **fatCubinHandle) {
- return dynload::__cudaUnregisterFatBinary(fatCubinHandle);
-}
-
-void CUDARTAPI __cudaRegisterFunction(void **fatCubinHandle,
- const char *hostFun,
- char *deviceFun,
- const char *deviceName,
- int thread_limit,
- uint3 *tid,
- uint3 *bid,
- dim3 *bDim,
- dim3 *gDim,
- int *wSize) {
- return dynload::__cudaRegisterFunction(fatCubinHandle,
- hostFun,
- deviceFun,
- deviceName,
- thread_limit,
- tid,
- bid,
- bDim,
- gDim,
- wSize);
-}
-
-void CUDARTAPI __cudaRegisterVar(void **fatCubinHandle,
- char *hostVar,
- char *deviceAddress,
- const char *deviceName,
- int ext,
- int size,
- int constant,
- int global) {
- return dynload::__cudaRegisterVar(fatCubinHandle,
- hostVar,
- deviceAddress,
- deviceName,
- ext,
- size,
- constant,
- global);
-}
-
-extern void CUDARTAPI __cudaRegisterManagedVar(void **fatCubinHandle,
- void **hostVarPtrAddress,
- char *deviceAddress,
- const char *deviceName,
- int ext,
- int size,
- int constant,
- int global) {
- return dynload::__cudaRegisterManagedVar(fatCubinHandle,
- hostVarPtrAddress,
- deviceAddress,
- deviceName,
- ext,
- size,
- constant,
- global);
-}
-
-char CUDARTAPI __cudaInitModule(void **fatCubinHandle) {
- return dynload::__cudaInitModule(fatCubinHandle);
-}
-
-void CUDARTAPI __cudaRegisterTexture(void **fatCubinHandle,
- const struct textureReference *hostVar,
- const void **deviceAddress,
- const char *deviceName,
- int dim,
- int norm,
- int ext) {
- return dynload::__cudaRegisterTexture(
- fatCubinHandle, hostVar, deviceAddress, deviceName, dim, norm, ext);
-}
-
-void CUDARTAPI __cudaRegisterSurface(void **fatCubinHandle,
- const struct surfaceReference *hostVar,
- const void **deviceAddress,
- const char *deviceName,
- int dim,
- int ext) {
- return dynload::__cudaRegisterSurface(
- fatCubinHandle, hostVar, deviceAddress, deviceName, dim, ext);
-}
-
-} /* extern "C" */
-
-#endif
diff --git a/paddle/cuda/src/hl_dso_loader.cc b/paddle/cuda/src/hl_dso_loader.cc
index c92909de534a875028d6d4784b02f08648c85a9a..53164dd27c7c5f5254e743b6fcf1d7b6fc895e31 100644
--- a/paddle/cuda/src/hl_dso_loader.cc
+++ b/paddle/cuda/src/hl_dso_loader.cc
@@ -25,10 +25,8 @@ DEFINE_string(cudnn_dir,
DEFINE_string(cuda_dir,
"",
"Specify path for loading cuda library, such as libcublas, "
- "libcurand. For instance, /usr/local/cuda/lib64. (Note: "
- "libcudart can not be specified by cuda_dir, since some "
- "build-in function in cudart already ran before main entry). "
- "If default, dlopen will search cuda from LD_LIBRARY_PATH");
+ "libcurand. For instance, /usr/local/cuda/lib64. If default, "
+ "dlopen will search cuda from LD_LIBRARY_PATH");
DEFINE_string(warpctc_dir, "", "Specify path for loading libwarpctc.so.");
@@ -147,14 +145,6 @@ void GetCudnnDsoHandle(void** dso_handle) {
#endif
}
-void GetCudartDsoHandle(void** dso_handle) {
-#if defined(__APPLE__) || defined(__OSX__)
- GetDsoHandleFromSearchPath("", "libcudart.dylib", dso_handle);
-#else
- GetDsoHandleFromSearchPath("", "libcudart.so", dso_handle);
-#endif
-}
-
void GetCurandDsoHandle(void** dso_handle) {
#if defined(__APPLE__) || defined(__OSX__)
GetDsoHandleFromSearchPath(FLAGS_cuda_dir, "libcurand.dylib", dso_handle);
diff --git a/paddle/pserver/CMakeLists.txt b/paddle/pserver/CMakeLists.txt
index 1c1e1964b8d3fd83c801f3988760a72dfc032e7f..b7f85ea1a6dfda2a37c315ba15c6ca1979cf4131 100644
--- a/paddle/pserver/CMakeLists.txt
+++ b/paddle/pserver/CMakeLists.txt
@@ -24,13 +24,15 @@ set(PSERVER_SOURCES
BaseClient.cpp
ParameterClient2.cpp
ParameterServer2.cpp
- SparseParameterDistribution.cpp)
+ SparseParameterDistribution.cpp
+ ParameterServerController.cpp)
set(PSERVER_HEADERS
BaseClient.h
ParameterClient2.h
ParameterServer2.h
- SparseParameterDistribution.h)
+ SparseParameterDistribution.h
+ ParameterServerController.h)
add_library(paddle_pserver STATIC
${PSERVER_SOURCES})
diff --git a/paddle/pserver/ParameterServer2Main.cpp b/paddle/pserver/ParameterServer2Main.cpp
index ffc521f2c143d95ff07c3825e0a746cb31743d9b..845a2c27e242cfbe31679fea6eae13d2b400ec81 100644
--- a/paddle/pserver/ParameterServer2Main.cpp
+++ b/paddle/pserver/ParameterServer2Main.cpp
@@ -13,66 +13,17 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include
-#include "paddle/utils/StringUtil.h"
-#include "paddle/utils/Util.h"
-
-#include "ParameterServer2.h"
-#include "RDMANetwork.h"
-#include "paddle/utils/Flags.h"
+#include "ParameterServerController.h"
using namespace paddle; // NOLINT
int main(int argc, char** argv) {
initMain(argc, argv);
- std::vector devices;
- std::vector> pservers;
-
- // round robin to loadbalance RDMA server ENGINE
- int rdmaCpu = 0;
- int onlineCpus = rdma::numCpus();
- int numPorts = FLAGS_ports_num + FLAGS_ports_num_for_sparse;
- if (FLAGS_nics.empty()) {
- pservers.resize(numPorts);
- for (int i = 0; i < numPorts; ++i) {
- if (FLAGS_rdma_tcp == "rdma") {
- pservers[i].reset(
- new ParameterServer2(std::string(), FLAGS_port + i, rdmaCpu++));
- rdmaCpu = rdmaCpu % onlineCpus;
- } else {
- pservers[i].reset(new ParameterServer2(std::string(), FLAGS_port + i));
- }
- CHECK(pservers[i]->init()) << "Fail to initialize parameter server"
- << FLAGS_port + i;
- LOG(INFO) << "pserver started : " << FLAGS_port + i;
- pservers[i]->start();
- }
- } else {
- str::split(FLAGS_nics, ',', &devices);
- pservers.resize(devices.size() * numPorts);
- for (int i = 0; i < numPorts; ++i) {
- for (size_t j = 0; j < devices.size(); ++j) {
- if (FLAGS_rdma_tcp == "rdma") {
- pservers[i * devices.size() + j].reset(new ParameterServer2(
- getIpAddr(devices[j]), FLAGS_port + i, rdmaCpu++));
- rdmaCpu = rdmaCpu % onlineCpus;
- } else {
- pservers[i * devices.size() + j].reset(
- new ParameterServer2(getIpAddr(devices[j]), FLAGS_port + i));
- }
- CHECK(pservers[i * devices.size() + j]->init())
- << "Fail to initialize parameter server" << devices[j]
- << FLAGS_port + i;
- LOG(INFO) << "pserver started : " << devices[j] << ":"
- << FLAGS_port + i;
- pservers[i * devices.size() + j]->start();
- }
- }
- }
-
- for (auto& pserver : pservers) {
- pserver->join();
- }
+ std::unique_ptr parameterServerPtr(
+ paddle::ParameterServerController::createFromGflags());
+ parameterServerPtr->start();
+ parameterServerPtr->wait();
return 0;
}
diff --git a/paddle/pserver/ParameterServerController.cpp b/paddle/pserver/ParameterServerController.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1d11a2e1acbc0f091901f3854ca99490d89ebe36
--- /dev/null
+++ b/paddle/pserver/ParameterServerController.cpp
@@ -0,0 +1,102 @@
+/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License. */
+
+#include "ParameterServerController.h"
+
+namespace paddle {
+
+ParameterServerController::ParameterServerController(
+ const ParameterServerConfig& config) {
+ // round robin to load balance RDMA server ENGINE
+ std::vector devices;
+ int rdmaCpu = 0;
+ int onlineCpus = rdma::numCpus();
+ int numPorts = config.ports_num() + config.ports_num_for_sparse();
+
+ if (config.nics().empty()) {
+ parameterServers_.resize(numPorts);
+ for (int i = 0; i < numPorts; ++i) {
+ if (config.rdma_tcp() == "rdma") {
+ parameterServers_[i].reset(
+ new ParameterServer2(std::string(), config.port() + i, rdmaCpu++));
+ rdmaCpu = rdmaCpu % onlineCpus;
+ } else {
+ parameterServers_[i].reset(
+ new ParameterServer2(std::string(), config.port() + i));
+ }
+ CHECK(parameterServers_[i]->init()) << "Fail to initialize parameter "
+ "server on port "
+ << config.port() + i;
+ }
+ } else {
+ str::split(config.nics(), ',', &devices);
+ parameterServers_.resize(devices.size() * numPorts);
+ for (int i = 0; i < numPorts; ++i) {
+ for (size_t j = 0; j < devices.size(); ++j) {
+ if (config.rdma_tcp() == "rdma") {
+ parameterServers_[i * devices.size() + j].reset(new ParameterServer2(
+ getIpAddr(devices[j]), config.port() + i, rdmaCpu++));
+ rdmaCpu = rdmaCpu % onlineCpus;
+ } else {
+ parameterServers_[i * devices.size() + j].reset(
+ new ParameterServer2(getIpAddr(devices[j]), config.port() + i));
+ }
+ CHECK(parameterServers_[i * devices.size() + j]->init())
+ << "Fail to initialize parameter server with device " << devices[j]
+ << config.port() + i;
+ }
+ }
+ }
+}
+
+ParameterServerController::~ParameterServerController() { this->wait(); }
+
+ParameterServerController* ParameterServerController::createFromGflags() {
+ ParameterServerConfig config;
+
+ config.set_nics(FLAGS_nics);
+ config.set_rdma_tcp(FLAGS_rdma_tcp);
+ config.set_port(FLAGS_port);
+ config.set_ports_num(FLAGS_ports_num);
+ config.set_ports_num_for_sparse(FLAGS_ports_num_for_sparse);
+
+ return create(config);
+}
+
+ParameterServerController* ParameterServerController::create(
+ const ParameterServerConfig& config) {
+ return new ParameterServerController(config);
+}
+
+void ParameterServerController::start() {
+ LOG(INFO) << "number of parameterServer instances: "
+ << parameterServers_.size();
+ int i = 0;
+ for (const auto& parameterServer : parameterServers_) {
+ LOG(INFO) << "Starting parameterServer[" << i << "]";
+ parameterServer->start();
+ i++;
+ }
+}
+
+void ParameterServerController::wait() {
+ int i = 0;
+ for (const auto& parameterServer : parameterServers_) {
+ LOG(INFO) << "Waiting parameterServer[" << i << "]";
+ parameterServer->join();
+ i++;
+ }
+}
+
+} // namespace paddle
diff --git a/paddle/pserver/ParameterServerController.h b/paddle/pserver/ParameterServerController.h
new file mode 100644
index 0000000000000000000000000000000000000000..fe9bb0b4d02339d0d31d5bc2942932e1f876098b
--- /dev/null
+++ b/paddle/pserver/ParameterServerController.h
@@ -0,0 +1,74 @@
+/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License. */
+
+#pragma once
+
+#include "ParameterServer2.h"
+#include "ParameterServerConfig.pb.h"
+#include "RDMANetwork.h"
+#include "paddle/utils/StringUtil.h"
+
+namespace paddle {
+
+/**
+ * @brief ParameterServerController is used for create, init and manage multi
+ * parameter server instances. The num of the instances is decided by port
+ * num(the ports number for parameter send) and network devices configured
+ * by gflags or proto.
+ */
+class ParameterServerController final {
+public:
+ DISABLE_COPY(ParameterServerController);
+
+ /**
+ * @brief Ctor, Create a ParameterServerController from ParameterServerConfig.
+ */
+ explicit ParameterServerController(const ParameterServerConfig& config);
+
+ /**
+ * @brief Dtor.
+ */
+ ~ParameterServerController();
+
+ /**
+ * @brief create ParameterServerController from gflags, this is used for
+ * compatibility with the old usage of configuration by gflags.
+ */
+ static ParameterServerController* createFromGflags();
+
+ /**
+ * @brief create ParameterServerController with ParameterServerConfig, remove
+ * gflags from ParameterServer. Init all ParameterServer2 instances according
+ * to
+ * the config.
+ */
+ static ParameterServerController* create(const ParameterServerConfig& config);
+
+ /**
+ * @brief start all ParameterServer2 instances in this
+ * ParameterServerController.
+ */
+ void start();
+
+ /**
+ * @brief join and wait for all ParameterServer2 instances thread in this
+ * ParameterServerController.
+ */
+ void wait();
+
+private:
+ std::vector> parameterServers_;
+};
+
+} // namespace paddle
diff --git a/paddle/scripts/CMakeLists.txt b/paddle/scripts/CMakeLists.txt
index 1bae396a18688cd53e164774df07660ccc2451d7..66a46e1883a49d491f0cb3056a7039407d72e337 100644
--- a/paddle/scripts/CMakeLists.txt
+++ b/paddle/scripts/CMakeLists.txt
@@ -2,8 +2,16 @@ configure_file(submit_local.sh.in
submit_local.sh
@ONLY)
-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/submit_local.sh DESTINATION bin
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
RENAME paddle)
+
+configure_file(tools/usage_stat/usage.sh
+ usage.sh
+ @ONLY)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/usage.sh DESTINATION opt/paddle/bin
+ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
+ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
+ RENAME paddle_usage)
diff --git a/paddle/scripts/submit_local.sh.in b/paddle/scripts/submit_local.sh.in
index 283fd34a6d8a2268f3800ec69920e128ac75e7dc..f29d32f0d947dc7cde6112160e4f79ce8113505f 100644
--- a/paddle/scripts/submit_local.sh.in
+++ b/paddle/scripts/submit_local.sh.in
@@ -122,6 +122,9 @@ case "$1" in
"make_diagram")
python -m paddle.utils.make_model_diagram ${@:2}
;;
+ "usage")
+ $MYDIR/../opt/paddle/bin/paddle_usage ${@:2}
+ ;;
"version")
version
;;
diff --git a/paddle/scripts/tools/usage_stat/usage.sh b/paddle/scripts/tools/usage_stat/usage.sh
new file mode 100755
index 0000000000000000000000000000000000000000..7dbd1f58842f50ea1df0e2476c4a493569b1dda9
--- /dev/null
+++ b/paddle/scripts/tools/usage_stat/usage.sh
@@ -0,0 +1,168 @@
+#!/bin/bash
+
+ARGPARSE=`getopt -o u:vin:l:e: --long git-user:,help,dry-run,task-name:,log-file:,exit-code: -- "$@"`
+KEEP_ANONYMOUS="A_USER_DOES_NOT_TELL_US"
+# paddle config home dir, same as paddle
+PADDLE_CONF_HOME="$HOME/.config/paddle"
+# api url, mirror url(s) will be append later
+PD_URLS="http://api.paddlepaddle.org/version"
+
+usage()
+{
+ echo "Usage: `basename $0` [options]"
+ echo "Options:"
+ echo " -e, --exit-code=EXIT_CODE The train/predict process's exit code"
+ echo " -l, --log-file=LOG_FILE_PATH Read which log file to get the duration of process"
+ echo " -n, --task-name=TASK_NAME The name of demo or example"
+ echo " -u, --git-user=GITHUB_USER provide contact info, like username or email"
+ echo " -v, -i Verbose output and interact with user when necessary"
+ echo " --help display this help message"
+}
+
+eval set -- "${ARGPARSE}"
+while true; do
+ case "$1" in
+ -l|--log-file)
+ log_file=$2
+ shift 2
+ ;;
+ -e|--exit-code)
+ exit_code=$2
+ shift 2
+ ;;
+ -u|--git-user)
+ github_user=$2
+ shift 2
+ ;;
+ -n|--task-name)
+ task=$2
+ shift 2
+ ;;
+ -v|-i)
+ v=1
+ shift
+ ;;
+ --dry-run)
+ dry_run=1
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
+ --help)
+ usage
+ exit 0
+ ;;
+ *)
+ echo "Invalid option $1"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+# parse the log_file to get the time costs
+if [ -s "${log_file}" ]; then
+ duration=`awk 'BEGIN{day=0;last_sec=0;min_sec=0;max_sec=0;}
+ {if(index($2,":")==3){
+ t=substr($2,1,8);
+ sec=day*86400+substr(t,1,2)*3600+substr(t,4,2)*60+substr(t,7,2);
+ if(secsec){min_sec=sec;}
+ if(max_sec==0 || max_sec/dev/null`
+ git_url=`git config --get remote.origin.url 2>/dev/null`
+ if [ "`echo ${git_url} | cut -b 1-19`" = "https://github.com/" ]; then
+ # under a git url, like https://github.com/user_xxx/proj_yyy.git
+ if [ "${v}" = "1" ]; then echo " from github url..."; fi
+ github_user=`echo ${git_url} | cut -d "/" -f 4`
+ if [ "${github_user}" = "PaddlePaddle" ]; then
+ github_user=
+ fi
+ fi
+ if [ -n "${git_username}" -a -z "${github_user}" ]; then
+ if [ "${v}" = "1" ]; then echo " from global git username..."; fi
+ github_user=${git_username}
+ fi
+ fi
+fi
+# allow user to set the user name, if it's not found
+if [ -z "${github_user}" -a "${v}" = "1" ]; then
+ read -p "Please input your github username or email, or just return to keep this feedback anonymous:"
+ github_user=${REPLY}
+ if [ -z "${github_user}" ]; then
+ # empty input, consider as one anonymous user
+ github_user="${KEEP_ANONYMOUS}"
+ fi
+fi
+if [ -n "${github_user}" -a -z "${dry_run}" ]; then
+ # valid user and not in dry-run mode, then save to cache
+ mkdir -p ${PADDLE_CONF_HOME}
+ echo "${github_user}" >${PADDLE_CONF_HOME}/github_user
+fi
+if [ "${v}" = "1" ]; then echo "username: ${github_user}"; fi
+if [ "${github_user}" = "${KEEP_ANONYMOUS}" ]; then
+ # anonymous user should keep the var empty.
+ github_user=
+fi
+
+# read local paddle version
+paddle_version=`paddle version | grep PaddlePaddle | head -n1 | cut -d " " -f 2 | cut -d "," -f 1`
+if [ "${v}" = "1" ]; then echo "version:${paddle_version}"; fi
+
+# read local system time
+system_time=`date "+%Y%m%d%H%M%S"`
+if [ "${v}" = "1" ]; then echo "system time:${system_time}"; fi
+
+# make empty job_name as default value.
+if [ -z "${task}" ]; then
+ task="(unknown_task)"
+fi
+if [ "${v}" = "1" ]; then echo "task: ${task}"; fi
+
+# concat the curl command
+params="content={\"data_type\":\"usage\",\
+\"system_time\":${system_time},\"paddle_version\":\"${paddle_version}\",\
+\"github_user\":\"${github_user}\",\"job_name\":\"${task}\",\
+\"duration\":${duration},\"exit_code\":\"${exit_code}\"\
+}&type=1"
+curl_cmd_prefix="curl -m 5 -X POST -d ${params}\
+ -b ${PADDLE_CONF_HOME}/paddle.cookie -c ${PADDLE_CONF_HOME}/paddle.cookie "
+
+if [ "${dry_run}" = "1" ]; then
+ first_url=`echo ${PD_URLS} | cut -d " " -f 1`
+ echo "(dry-run mode)curl command: ${curl_cmd_prefix} ${first_url}"
+ exit 0
+else
+ for u in ${PD_URLS}; do
+ curl_cmd="${curl_cmd_prefix} ${u}"
+ if [ "${v}" = "1" ]; then echo "run: ${curl_cmd}"; fi
+ ${curl_cmd} >/dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ if [ "${v}" = "1" ]; then echo "upload OK!"; fi
+ exit 0
+ else
+ if [ "${v}" = "1" ]; then echo "upload failed...try next"; fi
+ fi
+ done
+ if [ "${v}" = "1" ]; then echo "all urls tried but all failed...exit"; fi
+ exit 1
+fi
diff --git a/paddle/trainer/TrainerMain.cpp b/paddle/trainer/TrainerMain.cpp
index e2fbd21e14afa7c89b82999b08bf91c1de182906..c5c1d484e5f85c774fd4b8f1d4a8d46abfa2f547 100644
--- a/paddle/trainer/TrainerMain.cpp
+++ b/paddle/trainer/TrainerMain.cpp
@@ -12,14 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
-#include "paddle/pserver/ParameterServer2.h"
-#include "paddle/utils/Common.h"
+#include
+#include "paddle/pserver/ParameterServerController.h"
#include "paddle/utils/PythonUtil.h"
-#include "paddle/utils/StringUtil.h"
#include "ParamUtil.h"
#include "Trainer.h"
-#include "paddle/pserver/RDMANetwork.h"
DEFINE_bool(start_pserver, false, "Whether to start pserver");
DECLARE_int32(gpu_id);
@@ -38,54 +36,11 @@ int main(int argc, char** argv) {
initMain(argc, argv);
initPython(argc, argv);
- std::vector> pservers;
- std::vector devices;
-
+ std::unique_ptr parameterServerPtr(nullptr);
if (FLAGS_start_pserver) {
- // round robin to loadbalance RDMA server ENGINE
- int rdmaCpu = 0;
- int onlineCpus = rdma::numCpus();
- int numPorts = FLAGS_ports_num + FLAGS_ports_num_for_sparse;
- if (FLAGS_nics.empty()) {
- pservers.resize(numPorts);
- for (int i = 0; i < numPorts; ++i) {
- if (FLAGS_rdma_tcp == "rdma") {
- pservers[i].reset(
- new ParameterServer2(std::string(), FLAGS_port + i, rdmaCpu++));
- rdmaCpu = rdmaCpu % onlineCpus;
- } else {
- pservers[i].reset(
- new ParameterServer2(std::string(), FLAGS_port + i));
- }
-
- CHECK(pservers[i]->init()) << "Fail to initialize parameter server"
- << FLAGS_port + i;
- LOG(INFO) << "pserver started : " << FLAGS_port + i;
- pservers[i]->start();
- }
- } else {
- str::split(FLAGS_nics, ',', &devices);
- pservers.resize(devices.size() * numPorts);
- for (int i = 0; i < numPorts; ++i) {
- for (size_t j = 0; j < devices.size(); ++j) {
- if (FLAGS_rdma_tcp == "rdma") {
- pservers[i * devices.size() + j].reset(new ParameterServer2(
- getIpAddr(devices[j]), FLAGS_port + i, rdmaCpu++));
- rdmaCpu = rdmaCpu % onlineCpus;
- } else {
- pservers[i * devices.size() + j].reset(
- new ParameterServer2(getIpAddr(devices[j]), FLAGS_port + i));
- }
-
- CHECK(pservers[i * devices.size() + j]->init())
- << "Fail to initialize parameter server" << devices[j]
- << FLAGS_port + i;
- LOG(INFO) << "pserver started : " << devices[j] << ":"
- << FLAGS_port + i;
- pservers[i * devices.size() + j]->start();
- }
- }
- }
+ parameterServerPtr.reset(
+ paddle::ParameterServerController::createFromGflags());
+ parameterServerPtr->start();
}
Trainer trainer;
auto config = TrainerConfigHelper::createFromFlags();
diff --git a/proto/CMakeLists.txt b/proto/CMakeLists.txt
index e854b2b427e550ec491dacf931cc2d2cce7ba6c2..62d5b9e38b21ee82d1e78c3bde5aa5df7e4a33ee 100644
--- a/proto/CMakeLists.txt
+++ b/proto/CMakeLists.txt
@@ -4,7 +4,8 @@ set(proto_filenames
ModelConfig.proto
ParameterConfig.proto
ParameterService.proto
- TrainerConfig.proto)
+ TrainerConfig.proto
+ ParameterServerConfig.proto)
set(PROTO_GEN)
set(PROTO_GEN_PY)
diff --git a/proto/ParameterServerConfig.proto b/proto/ParameterServerConfig.proto
new file mode 100644
index 0000000000000000000000000000000000000000..3068bba8b10d89b432b41076dc6eb3ebc40b3883
--- /dev/null
+++ b/proto/ParameterServerConfig.proto
@@ -0,0 +1,50 @@
+/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License. */
+syntax = "proto2";
+
+package paddle;
+
+
+/**
+ * Configuration structure for ParameterClient2.
+ */
+message ParameterClientConfig {
+ required int32 trainer_id = 1;
+}
+
+/**
+ * Configuration structure for ParameterServer2.
+ */
+message ParameterServerConfig {
+ // The ports number for parameter send,
+ // increment based on default port number
+ required int32 ports_num = 1 [default = 1];
+ // The ports number for parameter send,
+ // increment based on default (port + ports_num
+ required int32 ports_num_for_sparse = 2 [default = 0];
+ // network device name for pservers
+ required string nics = 3 [default = "xgbe0,xgbe1"];
+ required string rdma_tcp = 4 [default = "tcp"];
+ // Listening port for pserver
+ required int32 port = 5 [default = 20134];
+ // number of gradient servers
+ required int32 num_gradient_servers = 6 [default = 1];
+ // number of threads for sync op exec
+ required int32 pserver_num_threads = 7 [default = 1];
+ // control config_.async_lagged_grad_discard_ratio() min value
+ required double async_lagged_ratio_min = 8 [default = 1.0];
+ // if async_lagged_grad_discard_ratio is not set in trainer_config.conf
+ // use it as defalut value
+ required double async_lagged_ratio_default = 9 [default = 1.5];
+}
\ No newline at end of file