research-rainfallradar/aimodel/slurm-pretrain.job

69 lines
1.9 KiB
Plaintext
Raw Normal View History

2022-08-31 15:32:17 +00:00
#!/usr/bin/env bash
2022-09-02 18:08:16 +00:00
#SBATCH -J RainAIv3
2022-08-31 15:32:17 +00:00
#SBATCH -N 1
2022-09-02 18:09:07 +00:00
#SBATCH -n 14
2022-08-31 15:32:17 +00:00
#SBATCH --gres=gpu:1
2022-11-10 21:09:34 +00:00
#SBATCH -o %j.%N.%a.pretrain.out.log
#SBATCH -e %j.%N.%a.pretrain.err.log
#SBATCH -p gpu05,gpu
2022-08-31 15:32:17 +00:00
#SBATCH --time=5-00:00:00
2022-10-10 16:45:29 +00:00
#SBATCH --mem=61440
# 61440 = 60GiB memory required
2022-08-31 15:32:17 +00:00
module load utilities/multi
module load readline/7.0
module load gcc/10.2.0
module load cuda/11.5.0
module load python/anaconda/4.6/miniconda/3.7
show_help() {
echo -e "Usage:" >&2;
echo -e " [INPUT='\$HOME/rainfallwater_records_tfrecord'] [POSTFIX='<string>'] sbatch slurm-pretrain.job" >&2;
echo -e "" >&2;
echo -e "....where:" >&2;
echo -e " INPUT The path to the directory containing the .tfrecord files to use as training data (see the rainfallwrangler for making these)" >&2;
echo -e " POSTFIX Optional. A suffix to apply to the run code name." >&2;
echo -e "" >&2;
echo -e "The code used to identify the run is taken automatically from the filename of the config file." >&2;
exit;
}
2022-09-02 18:05:18 +00:00
INPUT="${INPUT:-$HOME/rainfallwater_records_tfrecord}";
2022-08-31 15:32:17 +00:00
2022-09-02 18:05:18 +00:00
if [[ -z "${INPUT}" ]]; then
echo -e "Error: No INPUT environment variable specified.\n" >&2;
2022-08-31 15:32:17 +00:00
show_help;
exit 0;
fi
if [[ ! -d "${INPUT}" ]]; then
echo -e "Error: The directory '${INPUT}' containing the input .tfrecord dataset either doesn't exist or isn't a directory.";
show_help;
exit 1;
fi
2022-09-02 18:06:54 +00:00
CODE="pretrain_contrast";
2022-08-31 15:32:17 +00:00
if [[ -n "${POSTFIX}" ]]; then
echo -e ">>> Applying postfix of ${POSTFIX}" >&2;
CODE="${CODE}_${POSTFIX}";
fi
echo -e ">>> Input dirpath: ${INPUT}" >&2;
echo -e ">>> Code: ${CODE}" >&2;
echo -e ">>> Additional args: ${ARGS}";
dir_output="output/$(date -u --rfc-3339=date)_${CODE}";
export PATH=$HOME/software/bin:$PATH;
echo ">>> Installing requirements";
conda run -n py38 pip install -r requirements.txt;
echo ">>> Training model";
#shellcheck disable=SC2086
2022-09-02 18:13:56 +00:00
/usr/bin/env time -v conda run -n py38 src/index.py pretrain --input "${INPUT}" --output "${dir_output}" ${ARGS};
2022-08-31 15:32:17 +00:00
echo ">>> exited with code $?";