XciD's picture
XciD HF staff
initial commit
8969f81
#!/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