-
Notifications
You must be signed in to change notification settings - Fork 1
/
5_translate_ct2.sh
executable file
·74 lines (57 loc) · 1.28 KB
/
5_translate_ct2.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
if [ -z $ENGINEDIR ]
then
if [ ! -z "$1" ]
then
ENGINEDIR=$1
else
echo 'Specify or export ENGINEDIR'
exit 1
fi
fi
if [ ! -z $SKIPBPE ]
then
SKIPBPE=1
else
SKIPBPE=0
fi
if [ -z $SUFFIX ]
then
SUFFIX=''
else
SUFFIX=${SUFFIX}'.'
fi
if [ -z $GPUID ]
then
GPUID=0
fi
DATADIR=$ENGINEDIR/data
MODELDIR=$2
SCRIPTPATH=$( cd $( dirname $( readlink -f $0 ) ) && pwd )
OPENNMT=${SCRIPTPATH}'/OpenNMT-py'
SUBWORDTools=${SCRIPTPATH}/"MTTools"/"subword-nmt"
INPUT=$1
CUDA_VISIBLE_DEVICES=0,1,2
echo $SKIPBPE
if [ "$SKIPBPE" -eq "0" ];
then
$SUBWORDTools/apply_bpe.py -c $DATADIR/bpe.src < $INPUT > ${INPUT}.sw
INPUT=${INPUT}.sw
fi
echo $INPUT
OUTPUT=${INPUT}.${SUFFIX}out
echo "Launching GPU monitoring"
GPUMONPID=$( nvidia-smi dmon -i ${GPUID} -s mpucv -d 5 -o TD > $ENGINEDIR/model/gpu_trans_ct2${SUFFIX}.log & )
rm $ENGINEDIR/model/power_log_trans_ct2${SUFFIX} -rf
mkdir $ENGINEDIR/model/power_log_trans_ct2${SUFFIX}
python power_monitor.py $ENGINEDIR/model/power_log_trans_ct2${SUFFIX} &
POWERMONPID=$!
echo 'Launching translation on GPU ' $GPUID
python3 5_translate_ct2.py \
--model-dir $MODELDIR \
--gpuid ${GPUID} \
--input ${INPUT} \
--output ${OUTPUT}
kill -s 9 $GPUMONPID
kill $POWERMONPID
echo "Done."