forked from kyamagu/sge-gpuprolog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestPrologEpilog.sh
executable file
·67 lines (53 loc) · 1.82 KB
/
testPrologEpilog.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
#!/bin/bash
#
# Authors: Mozhgan Kabiri Chimeh, Paul Richmond
# Contact: [email protected]
#
# Startup script to allocate GPU devices.
# Based on https://github.com/kyamagu/sge-gpuprolog
#
# The script is written to test if both Prolog and Epilog scripts are working
# For this purpose, we created another script called 'qstat' to emulate what the real 'qstat' command does.
# To execute, simply run ./testPriloEpilog $1 , where $1 is the number of gpus. This is actually the $JOB_ID, but we as we use a fake one, we set this as the number of GPUs user requested
# The system will look for executables in current directory without a "./".
export PATH=$PATH:.
JOB_ID=$1 # num gpus
node_number=$2 # user defined
# Output the directory status list for lock files
check_locks_func(){
echo
echo "------------------------------------"
for device_id in $device_ids
do
lockfile=/tmp/lock_$node_number"_device"$device_id
if [ -d $lockfile ]
then
echo "$lockfile exists"
else
echo "no lock exists on $lockfile"
fi
done
echo "------------------------------------"
echo
}
# Output current list of devices IDS from NVIDIA-SMI
deviceId_func(){
device_ids=$(nvidia-smi -L | cut -f1 -d":" | cut -f2 -d" " | xargs shuf -e)
echo "Current list of devices: $device_ids"
}
#################################################
echo "START ...."
export JOB_ID=$1 # num gpus
export node_number=1 # user defined
deviceId_func
check_locks_func
echo "executing Prolog ..................."
echo "source ./prolog.sh"
. prolog.sh
# setting NVIDIA sample path to check the number of visible devices, make sure to compile/build the deviceQuery before hand
~/NVIDIA_CUDA-8.0_Samples/1_Utilities/deviceQuery/deviceQuery -noprompt | egrep "^Device"
check_locks_func
echo "executing Epilog ..................."
./epilog.sh
check_locks_func
echo "DONE"