File size: 1,036 Bytes
8969f81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
pgrep -f gunicorn | xargs kill -9
kill $(lsof -t -i:3000)

cd id
npm run start &
sleep 5
cd -

if [[ "$1" == "" ]]; then
    echo "JSON file argument not supplied. Exiting." 1>&2
    exit 1
fi

# Number of GPUs 
N_GPU=$(nvidia-smi -L | wc -l)

export FILE=$1
export GPU_PER_WORKER=`cat "$FILE" | jq -r .gpu_per_worker`

# Are there enough GPUs ?
if [[ $(($N_GPU / $GPU_PER_WORKER)) -eq 0 ]]; then
    echo "Not enough GPUs to run this." 1>&2
    exit 1
fi

N_WORKERS=$(($N_GPU / $GPU_PER_WORKER))

echo "File $FILE"
echo "Available GPUs $N_GPU"
echo "GPUs per worker $GPU_PER_WORKER"
echo "Total workers $N_WORKERS"

function sys_exit ()
{
    echo "Ctrl-C caught...performing clean up"
    echo "Cleaning up the servers."
    echo $INST1
    kill -9 $INST1
    exit 2

}

trap "sys_exit" INT

echo "Running server with" ${N_WORKERS} "workers."
gunicorn --statsd-host=localhost:8125 -w ${N_WORKERS}  API --bind=0.0.0.0:6006 --statsd-prefix=transformer-autocomplete -t 600 &
INST1=$!

while true; do sleep 1000; done