Skip to content

Commit e641f94

Browse files
authored
Merge pull request #1011 from jacquesqiao/cluster_train
add cluster train for quick_start
2 parents 6951c8a + 027aaf9 commit e641f94

File tree

5 files changed

+101
-3
lines changed

5 files changed

+101
-3
lines changed

demo/quick_start/api_predict.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ set -e
1717
#Note the default model is pass-00002, you shold make sure the model path
1818
#exists or change the mode path.
1919
#only test on trainer_config.lr.py
20-
model=output/pass-00001/
20+
model=output/model/pass-00001/
2121
config=trainer_config.lr.py
2222
label=data/labels.list
2323
dict=data/dict.txt
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
set -e
16+
17+
# Should run pserver.sh before run this script.
18+
bin_dir=$(cd `dirname $0`; pwd)
19+
home_dir=$(cd "${bin_dir}/.."; pwd)
20+
source "$bin_dir/env.sh"
21+
22+
model_dir="$bin_dir/output"
23+
log_file="$bin_dir/train.log"
24+
25+
pushd "$home_dir"
26+
cfg=trainer_config.lr.py
27+
paddle train \
28+
--config=$cfg \
29+
--save_dir=${model_dir} \
30+
--trainer_count=4 \
31+
--local=0 \
32+
--log_period=100 \
33+
--num_passes=15 \
34+
--use_gpu=false \
35+
--show_parameter_stats_period=100 \
36+
--test_all_data_in_one_period=1 \
37+
--num_gradient_servers=1 \
38+
--nics=`get_nics` \
39+
--port=7164 \
40+
--ports_num=1 \
41+
--pservers="127.0.0.1" \
42+
--comment="paddle_trainer" \
43+
2>&1 | tee "$log_file"
44+
popd

demo/quick_start/cluster/env.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
set -e
16+
17+
function get_nics() {
18+
machine=`uname -s`
19+
local nics=""
20+
if [ "$machine" == "Linux" ]; then
21+
nics="lo"
22+
elif [ "$machine" == "Darwin" ]; then
23+
nics="lo0"
24+
else
25+
nics="unsupport"
26+
fi
27+
echo $nics
28+
}

demo/quick_start/cluster/pserver.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
set -e
16+
bin_dir=$(cd `dirname $0`; pwd)
17+
source "$bin_dir/env.sh"
18+
19+
paddle pserver \
20+
--nics=`get_nics` \
21+
--port=7164 \
22+
--ports_num=1 \
23+
--ports_num_for_sparse=1 \
24+
--num_gradient_servers=1 \
25+
--comment="paddle_pserver" \
26+
2>&1 | tee 'pserver.log'

paddle/trainer/ThreadParameterUpdater.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ namespace paddle {
3333
because at the current moment, the merging on CPU is happening on the
3434
main thread, and the its parameter size can be much larger than the one GPU.
3535
Thus, for GPU, the parameter updates happens in updateImpl() function, which
36-
is called by gradient machines as a callback function as a callback function
37-
supplied to backward() and forwardBackward().
36+
is called by gradient machines as a callback function supplied to backward()
37+
and forwardBackward().
3838
For CPU, the parameter updates happens in separate threads maintained by this
3939
class.
4040
*/

0 commit comments

Comments
 (0)