run_openblas_train.sh 1017 字节
Newer Older
C
chengduoZH 已提交
1 2
#!/bin/bash

3 4 5
set -e

function train() {
6
  export OPENBLAS_NUM_THREADS=1
7 8 9
  topology=$1
  layer_num=$2
  bs=$3
10 11 12
  thread=`nproc`
  # each trainer_count use only 1 core to avoid conflict
  log="logs/train-${topology}-${layer_num}-${thread}openblas-${bs}.log"
13 14 15 16
  args="batch_size=${bs},layer_num=${layer_num}"
  config="${topology}.py"
  paddle train --job=time \
    --config=$config \
17
    --use_mkldnn=False \
18 19
    --use_gpu=False \
    --trainer_count=$thread \
20 21
    --log_period=3 \
    --test_period=30 \
22 23
    --config_args=$args \
    2>&1 | tee ${log} 
24 25 26 27

  avg_time=`tail ${log} -n 1 | awk -F ' ' '{print $8}' | sed 's/avg=//'`
  fps=`awk 'BEGIN{printf "%.2f",('$bs' / '$avg_time' * 1000)}'`
  echo "FPS: $fps images/sec" 2>&1 | tee -a ${log}
28 29 30 31 32 33 34 35 36 37
}

if [ ! -f "train.list" ]; then
  echo " " > train.list
fi
if [ ! -d "logs" ]; then
  mkdir logs
fi

# training benchmark
38 39 40 41
for batchsize in 64 128 256; do
  train vgg 19 $batchsize
  train resnet 50 $batchsize
  train googlenet v1 $batchsize
T
tensor-tang 已提交
42
  train alexnet 2 $batchsize
43
done