This repository has been archived by the owner on Aug 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprocess.sbatch
89 lines (71 loc) · 2.42 KB
/
process.sbatch
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
#!/usr/bin/env bash
#SBATCH --job-name=FishDetector
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8
#SBATCH --mem-per-cpu=6gb
#SBATCH --time=24:00:00
#SBATCH --partition=gpu
#SBATCH --gres=gpu:2
#SBATCH --output=logs/process_%j.log
set -eu
echo "Job ID: $SLURM_JOB_ID, JobName: $SLURM_JOB_NAME"
echo "Command: $0 $@"
hostname; pwd; date
trap date EXIT
# Error if this is not a GPU node
[ -n "${CUDA_VISIBLE_DEVICES+x}" ]
module purge
module load default-environment slurm/17.11.12
module load gcc/6.5.0 python3/3.6.5
# Load the CUDA modules because OpenCV is linked to them, but we will only use
# them if we're on a GPU node.
module load cuda10.1/{toolkit,blas,fft}
if [ ! -d ./cudnn ]; then
echo "[*] Missing cuDNN directory, loading cuDNN module"
module load cuda10.1/cudnn/8.0.2
fi
# If there isn't a virtual environment, create it
[ ! -d .venv ] && virtualenv .venv
set +u; . .venv/bin/activate; set -u
pip install -r requirements.txt
# Get configuration options
VIDEOFILE="$1"
shift
PROCESS_ARGS="$@"
# Get the name of the video without extension
VIDEONAME="$(basename "$VIDEOFILE" | rev | cut -d . -f 2- | rev)"
# Create a fingerprint for the settings used here
SCRIPT_IDENTIFIER="$(git log -n 1 --pretty=format:%H -- process_video.py)"
if git diff --quiet process_video.py; then
SCRIPT_IDENTIFIER="$SCRIPT_IDENTIFIER"_dirty
fi
FINGERPRINT="$(echo "$SCRIPT_IDENTIFIER;$PROCESS_ARGS" | openssl md5 | cut -d ' ' -f 2)"
echo "Using fingerprint $FINGERPRINT"
# Create a directory for this fingerprint
if [ ! -d data/"$FINGERPRINT" ]; then
mkdir -p data/"$FINGERPRINT"
fi
# Save version and settings info
echo "$SCRIPT_IDENTIFIER" > data/"$FINGERPRINT"/version.txt
echo "$PROCESS_ARGS" > data/"$FINGERPRINT"/settings.txt
# Create a directory for storing processed frames
OUTDIR=data/"$FINGERPRINT"/"$VIDEONAME"
mkdir -p "$OUTDIR"
# Create a link to find the results by job
mkdir -p data/byjob || true
ln -s ../../"$OUTDIR" data/byjob/"$(date +'%Y-%m-%d')"_"$SLURM_JOB_ID"
# If frame lists exist, only process those frames
for LIST in test.txt train.txt valid.txt; do
if [ -f "data/${FINGERPRINT}/${LIST}" ]; then
echo "Frame list ${LIST} detected, using it"
PROCESS_ARGS="$PROCESS_ARGS --frame-list data/${FINGERPRINT}/${LIST}"
fi
done
# Start processing the frames
python process_video.py \
-v "$VIDEOFILE" \
--progress \
--ramdisk \
--num-cores 2 \
--save-preprocessed "$OUTDIR" \
$PROCESS_ARGS