Skip to content

Commit 40c7a43

Browse files
Merge pull request #253 from wangguan1995/tipc_fix
Tipc fix
2 parents 2a84ea8 + 715cc1e commit 40c7a43

File tree

5 files changed

+49
-34
lines changed

5 files changed

+49
-34
lines changed

test_tipc/README.MD

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,22 @@ cd ./test_tipc/
3838
wget https://paddle-qa.bj.bcebos.com/benchmark/tools.tar.gz
3939
tar -zxvf tools.tar.gz
4040
export BENCHMARK_ROOT=$PWD/tools
41+
cd ..
4142
```
42-
在根目录下运行
43+
在PaddleScience主目录下运行
4344
```
44-
bash ./test_tipc/benchmark_train.sh ./test_tipc/configs/train_2d_unsteady_continuous.txt benchmark_train
45+
export prepare_params=./test_tipc/configs/train_2d_unsteady_continuous/prepare_2d_unsteady_continuous.txt
46+
export train_params=./test_tipc/configs/train_2d_unsteady_continuous/train_2d_unsteady_continuous.txt
47+
source ./test_tipc/prepare.sh $prepare_params benchmark_train
48+
bash ./test_tipc/benchmark_train.sh $train_params benchmark_train
4549
```
4650
benchmark训练得到训练日志后,会自动保存训练日志并解析得到ips等信息,日志解析代码位于:
4751
- https://console.cloud.baidu-int.com/devops/icode/repos/baidu/paddle/benchmark-frame/blob/master/tools/scripts/analysis.py
4852
运行成功会显示
4953
```
5054
Run successfully with command
5155
```
52-
如果运行成功会生成index文件夹,该目录下面生成json文件[PaddleScience_cylinder2d_unsteady_train_newapi_bs1_fp32_SingleP_DP_N1C1_speed],其中可以找到对应的ips数值
56+
如果运行成功会生成index文件夹,该目录下面生成json文件[PaddleScience_cylinder2d_unsteady_train_newapi_bs1_fp32_DP_N1C1_speed],其中可以找到对应的ips数值
5357
```
54-
{"model_branch": "branch_test_1", "model_commit": "77723dd801a83fd9bcee94fec04fdcbdbb87d85a", "model_name": "cylinder2d_unsteady_train_newapi_bs1_fp32_SingleP_DP", "batch_size": 1, "fp_item": "fp32", "run_mode": "DP", "convergence_value": "207.94940185546875", "convergence_key": "loss:", "ips": 599765.06, "speed_unit": "samples/s", "device_num": "N1C1", "model_run_time": "19", "frame_commit": "caf2008b55fe0ee34cd6fa71090701517ac33eda", "frame_version": "0.0.0"}
58+
{"model_branch": "tipc_fix", "model_commit": "51558e06db7b58d5683a0fccc67d77f4340719d4", "model_name": "cylinder2d_unsteady_train_newapi_bs1_fp32_DP", "batch_size": 1, "fp_item": "fp32", "run_mode": "DP", "convergence_value": "207.94940185546875", "convergence_key": "loss:", "ips": 775299.78, "speed_unit": "samples/s", "device_num": "N1C1", "model_run_time": "15", "frame_commit": "5c19bfc8015b79f861aae9be6c98371de7ccef19", "frame_version": "0.0.0"}
5559
```

test_tipc/benchmark_train.sh

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,7 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
17-
export PDSC_DIR=$(cd "$( dirname ${BASH_SOURCE[0]})"; cd ..; pwd)
18-
export TEST_DIR="${PDSC_DIR}"
19-
export TIPC_TEST="ON" # open tipc log in solver.py
20-
BENCHMARK_ROOT=${TEST_DIR}"/test_tipc/tools"
2116
source ${TEST_DIR}/test_tipc/common_func.sh
22-
echo -e "\n* [TEST_DIR] is now set : \n" ${TEST_DIR} "\n"
23-
echo -e "\n* [BENCHMARK_ROOT] is now set : \n" ${BENCHMARK_ROOT} "\n"
24-
25-
python=python3.7
26-
pip="python3.7 -m pip"
27-
echo -e "\n* [pip] is now set : \n" ${pip} "\n"
28-
export model_branch=`git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3`
29-
export model_commit=$(git log|head -n1|awk '{print $2}')
30-
export str_tmp=$(echo `${pip} list|grep paddlepaddle-gpu|awk -F ' ' '{print $2}'`)
31-
export frame_version=${str_tmp%%.post*}
32-
export frame_commit=$(echo `${python} -c "import paddle;print(paddle.version.commit)"`)
3317

3418
function func_parser_params(){
3519
strs=$1
@@ -88,20 +72,14 @@ cmd=`yes|cp $FILENAME $new_filename`
8872
FILENAME=$new_filename
8973
# MODE must be one of ['benchmark_train']
9074
MODE=$2
91-
if [ ${MODE} = "benchmark_train" ];then
92-
python3.7 -m pip install -r requirements.txt
93-
export PYTHONPATH=${PDSC_DIR}
94-
echo -e "\n* [PYTHONPATH] is now set : \n" ${PYTHONPATH} "\n"
95-
python3.7 ${PDSC_DIR}/examples/cylinder/2d_unsteady_continuous/download_dataset.py
96-
fi
97-
9875

9976
PARAMS=$3
10077
IFS=$'\n'
10178
dataline=`cat $FILENAME`
10279
IFS=$'\n'
10380
lines=(${dataline})
10481
model_name=$(func_parser_value "${lines[1]}")
82+
python=$(func_parser_value "${lines[2]}")
10583
line_num=`grep -n "train_benchmark_params" $FILENAME | cut -d ":" -f 1`
10684
batch_size=$(func_parser_value "${lines[line_num]}")
10785
line_num=`expr $line_num + 1`
@@ -117,6 +95,12 @@ profile_option="${profile_option_key}:${profile_option_params}"
11795
line_num=`expr $line_num + 1`
11896
flags_value=$(func_parser_value "${lines[line_num]}")
11997

98+
export model_branch=`git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3`
99+
export model_commit=$(git log|head -n1|awk '{print $2}')
100+
export str_tmp=$(echo `${pip} list|grep paddlepaddle-gpu|awk -F ' ' '{print $2}'`)
101+
export frame_version=${str_tmp%%.post*}
102+
export frame_commit=$(echo `${python} -c "import paddle;print(paddle.version.commit)"`)
103+
120104
IFS=";"
121105
flags_list=(${flags_value})
122106
for _flag in ${flags_list[*]}; do
@@ -182,10 +166,10 @@ for batch_size in ${batch_size_list[*]}; do
182166
gpu_id=$(set_gpu_id $device_num)
183167

184168
if [ ${#gpu_id} -le 1 ];then
185-
run_process_type="SingleP"
169+
# run_process_type="SingleP"
186170
log_path="$SAVE_LOG/profiling_log"
187171
mkdir -p $log_path
188-
log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_process_type}_${run_mode}_${device_num}_profiling"
172+
log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_profiling"
189173
func_sed_params "$FILENAME" "${line_gpuid}" "0" # sed used gpu_id
190174
# set profile_option params
191175
tmp=`sed -i "${line_profile}s/.*/${profile_option}/" "${FILENAME}"`
@@ -201,8 +185,8 @@ for batch_size in ${batch_size_list[*]}; do
201185
speed_log_path="$SAVE_LOG/index"
202186
mkdir -p $log_path
203187
mkdir -p $speed_log_path
204-
log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_process_type}_${run_mode}_${device_num}_log"
205-
speed_log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_process_type}_${run_mode}_${device_num}_speed"
188+
log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_log"
189+
speed_log_name="${repo_name}_${model_name}_bs${batch_size}_${precision}_${run_mode}_${device_num}_speed"
206190
func_sed_params "$FILENAME" "${line_profile}" "null" # sed profile_id as null
207191
cmd="bash ${TEST_DIR}/test_tipc/test_train_inference_python.sh ${FILENAME} benchmark_train > ${log_path}/${log_name} 2>&1 "
208192
echo $cmd
@@ -212,7 +196,7 @@ for batch_size in ${batch_size_list[*]}; do
212196
export model_run_time=$((${job_et}-${job_bt}))
213197
eval "cat ${log_path}/${log_name}"
214198
# parser log
215-
_model_name="${model_name}_bs${batch_size}_${precision}_${run_process_type}_${run_mode}"
199+
_model_name="${model_name}_bs${batch_size}_${precision}_${run_mode}"
216200
cmd="${python} ${BENCHMARK_ROOT}/scripts/analysis.py --filename ${log_path}/${log_name} \
217201
--speed_log_file '${speed_log_path}/${speed_log_name}' \
218202
--model_name ${_model_name} \
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
===========================prepare_params===========================
2+
download_dataset:/examples/cylinder/2d_unsteady/download_dataset.py
3+
python:python3.7
4+
pip:pip

test_tipc/configs/train_2d_unsteady_continuous.txt renamed to test_tipc/configs/train_2d_unsteady_continuous/train_2d_unsteady_continuous.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ train_infer_img_dir:null
1313
--profiler_options:null
1414
##
1515
trainer:norm_train
16-
norm_train:/examples/cylinder/2d_unsteady_continuous/cylinder2d_unsteady_train_newapi.py
16+
norm_train:/examples/cylinder/2d_unsteady/cylinder2d_unsteady_train_newapi.py
1717
pact_train:null
1818
fpgm_train:null
1919
distill_train:null
@@ -54,4 +54,4 @@ batch_size:1
5454
fp_items:fp32
5555
epoch:20
5656
--profiler_options:batch_range=[1,1];state=GPU;tracer_option=Default;profile_path=model.profile
57-
flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=0
57+
flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=0

test_tipc/prepare.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Set directories
2+
export PDSC_DIR=$(cd "$( dirname ${BASH_SOURCE[0]})"; cd ..; pwd)
3+
export TEST_DIR="${PDSC_DIR}"
4+
export TIPC_TEST="ON" # open tipc log in solver.py
5+
export PYTHONPATH=${PDSC_DIR}
6+
7+
echo -e "\n* [TEST_DIR] is now set : \n" ${TEST_DIR} "\n"
8+
echo -e "\n* [BENCHMARK_ROOT] is now set : \n" ${BENCHMARK_ROOT} "\n"
9+
echo -e "\n* [PYTHONPATH] is now set : \n" ${PYTHONPATH} "\n"
10+
11+
BENCHMARK_ROOT=${TEST_DIR}"/test_tipc/tools"
12+
source ${TEST_DIR}/test_tipc/common_func.sh
13+
14+
# Read parameters from [prepare_2d_unsteady_continuous.txt]
15+
PREPARE_PARAM_FILE=$1
16+
dataline=`cat $PREPARE_PARAM_FILE`
17+
lines=(${dataline})
18+
download_dataset=$(func_parser_value "${lines[1]}")
19+
python=$(func_parser_value "${lines[2]}")
20+
export pip=$(func_parser_value "${lines[3]}")
21+
22+
${pip} install -r requirements.txt
23+
${python} ${PDSC_DIR}${download_dataset}

0 commit comments

Comments
 (0)