-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtg-pipeline.sh
executable file
·104 lines (81 loc) · 2.44 KB
/
rtg-pipeline.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
#SBATCH --partition=xxx
### SBATCH --mem=32g
#SBATCH --time=1-12:00:00
#SBATCH --nodes=1 --ntasks=1
#SBATCH --cpus-per-task=40
#SBATCH --gres=gpu:v100:4
#SBATCH --output=R-%x.out.%j
#SBATCH --error=R-%x.err.%j
#SBATCH --export=NONE
# Pipeline script for MT
#
# Author = Thamme Gowda (tg@isi.edu)
# Date = April 3, 2019
#SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") # get the directory name
#RTG_PATH=$(realpath "${SCRIPTS_DIR}/..")
# If using compute grid, and dont rely on this relative path resolution, set the RTG_PATH here
#RTG_PATH=/full/path/to/rtg-master
RTG_PATH=~tgowda/repos/rtg
# Use tmp dir
#export RTG_TMP=$TMPDIR
export RTG_TMP=$SCRATCH/tmp
# restrict threads / cpus
export RTG_CPUS=8 #$SLURM_CPUS_ON_NODE
export OMP_NUM_THREADS=$RTG_CPUS
export MKL_NUM_THREADS=$RTG_CPUS
OUT=
CONF_PATH=
#defaults
#CONDA_ENV=rtg # empty means don't activate environment
CONDA_ENV=
source ~/.bashrc
usage() {
echo "Usage: $0 -d <exp/dir>
[-c conf.yml (default: <exp/dir>/conf.yml) ]
[-e conda_env default:$CONDA_ENV (empty string disables activation)] " 1>&2;
exit 1;
}
while getopts ":fd:c:e:p:" o; do
case "${o}" in
d) OUT=${OPTARG} ;;
c) CONF_PATH=${OPTARG} ;;
e) CONDA_ENV=${OPTARG} ;;
*) usage ;;
esac
done
[[ -n $OUT ]] || usage # show usage and exit
#################
#NUM_GPUS=$(echo ${CUDA_VISIBLE_DEVICES} | tr ',' '\n' | wc -l)
echo "Output dir = $OUT"
[[ -d $OUT ]] || mkdir -p $OUT
OUT=`realpath $OUT`
if [[ ! -f $OUT/rtg.zip ]]; then
[[ -f $RTG_PATH/rtg/__init__.py ]] || { echo "Error: RTG_PATH=$RTG_PATH is not valid"; exit 2; }
echo "Zipping source code to $OUT/rtg.zip"
OLD_DIR=$PWD
cd ${RTG_PATH}
zip -r $OUT/rtg.zip rtg -x "*__pycache__*"
git rev-parse HEAD > $OUT/githead # git commit message
cd $OLD_DIR
fi
if [[ -n ${CONDA_ENV} ]]; then
echo "Activating environment $CONDA_ENV"
source activate ${CONDA_ENV} || { echo "Unable to activate $CONDA_ENV" ; exit 3; }
fi
export PYTHONPATH=$OUT/rtg.zip
# copy this script for reproducibility
cp "${BASH_SOURCE[0]}" $OUT/job.sh.bak
echo "`date`: Starting pipeline... $OUT"
CONF_ARG="$CONF_PATH"
if [[ -f $OUT/conf.yml && -n $CONF_PATH ]]; then
echo "ignoring $CONF_PATH, because $OUT/conf.yml exists"
CONF_ARG=""
fi
cmd="python -m rtg.pipeline $OUT $CONF_ARG --gpu-only"
echo "command::: $cmd"
if eval ${cmd}; then
echo "`date` :: Done"
else
echo "Error: exit status=$?"
fi