-
Notifications
You must be signed in to change notification settings - Fork 11
/
runai_one.sh
50 lines (43 loc) · 1.68 KB
/
runai_one.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
#!/bin/bash
# Usage
# bash runai_one.sh job_name num_gpu "command"
# Examples:
# `bash runai_one.sh name-hello-1 1 "python hello.py"`
# - creates a job names `name-hello-1`
# - uses 1 GPU
# - enters MY_WORK_DIR directory (set below) and runs `python hello.py`
#
# `bash runai_one.sh name-hello-2 0.5 "python hello_half.py"`
# - creates a job names `name-hello-2`
# - receives half of a GPUs memory, 2 such jobs can fit on one GPU!
# - enters MY_WORK_DIR directory (set below) and runs `python hello_half.py`
arg_job_name=$1
arg_gpu=$2
# remove newlines from cmd
arg_cmd=`echo $3 | tr '\n' ' '`
CLUSTER_USER=yourname # find this by running `id -un` on iccvlabsrv
CLUSTER_USER_ID=????? # find this by running `id -u` on iccvlabsrv
CLUSTER_GROUP_NAME=CVLAB-unit # find this by running `id -gn` on iccvlabsrv
CLUSTER_GROUP_ID=11166 # find this by running `id -g` on iccvlabsrv
MY_IMAGE="ic-registry.epfl.ch/cvlab/lis/lab-python-ml:cuda11"
MY_WORK_DIR="/cvlabdata2/home/$CLUSTER_USER"
runai_project="cvlab-$CLUSTER_USER" # per-user runai projects now
echo "Job [$arg_job_name] gpu $arg_gpu -> [$arg_cmd]"
runai submit $arg_job_name \
-i $MY_IMAGE \
--gpu $arg_gpu \
--pvc runai-$runai_project-cvlabdata1:/cvlabdata1 \
--pvc runai-$runai_project-cvlabdata2:/cvlabdata2 \
--pvc runai-$runai_project-cvlabsrc1:/cvlabsrc1 \
--large-shm \
-e CLUSTER_USER=$CLUSTER_USER \
-e CLUSTER_USER_ID=$CLUSTER_USER_ID \
-e CLUSTER_GROUP_NAME=$CLUSTER_GROUP_NAME \
-e CLUSTER_GROUP_ID=$CLUSTER_GROUP_ID \
-e TORCH_HOME="/cvlabsrc1/cvlab/pytorch_model_zoo" \
--command -- "/opt/lab/setup_and_run_command.sh 'cd $MY_WORK_DIR && $arg_cmd'"
# check if succeeded
if [ $? -eq 0 ]; then
sleep 1
runai describe job $arg_job_name
fi