-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtraining_inference.sh
64 lines (49 loc) · 1.38 KB
/
training_inference.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
#!/bin/bash
#SBATCH --qos=regular
#SBATCH --job-name=train
#SBATCH --time=1-00:00:00
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=24
#SBATCH --cpus-per-task=1
#SBATCH --gpus=1
#SBATCH --constraint=a100-pcie
#SBATCH --output=%x-%j.out
#SBATCH --error=%x-%j.err
module load Anaconda3
source activate #path of the corresponding anaconda environment
CDIR=`pwd`
export SCRATCH_DIR=/scratch/$USER/wrktmp/$SLURM_JOBID
mkdir -p $SCRATCH_DIR
# Get config file from input parameter
CONFIG_FILE=$1
# Check if config file is provided
if [ -z "$CONFIG_FILE" ]; then
CONFIG_FILE="input.yaml"
fi
# Check if the config file exists
if [ ! -f "$CONFIG_FILE" ]; then
echo "Error: Configuration file '$CONFIG_FILE' does not exist."
exit 1
fi
echo "Using configuration file: $CONFIG_FILE"
# Copy necessary files to SCRATCH_DIR
cp training.py $SCRATCH_DIR
cp "$CONFIG_FILE" $SCRATCH_DIR
cp *.npz $SCRATCH_DIR
cp *.hdf5 $SCRATCH_DIR
cp inference.py $SCRATCH_DIR
cd $SCRATCH_DIR
# Run training
python training.py --config "$CONFIG_FILE"
# Check if training was successful
if [ $? -eq 0 ]; then
echo "Training completed successfully. Starting inference."
# Run inference
python inference.py --config "$CONFIG_FILE"
else
echo "Training failed. Skipping inference."
fi
# Copy outputs back to submission directory
mkdir -p "$CDIR/$SLURM_JOB_ID"
cp -r * "$CDIR/$SLURM_JOB_ID"
rm -fr "$SCRATCH_DIR"