#!/usr/bin/env bash export n_gpus=`lspci | grep -i "controller: nvidia" | wc -l` if [ $n_gpus -eq 0 ]; then echo "-1" exit -1 fi if [[ -x $(which nvidia-smi) ]]; then f_gpu=`nvidia-smi | sed -e '1,/Processes/d' \ | tail -n+3 | head -n-1 | awk '{print $2}'\ | awk -v ng=$n_gpus 'BEGIN{for (n=0;n