In our laboratory we have 3 Tesla cards plus one Quadro on a single machine. I have to run scientific cuda-enabled codes written by other persons, and i would like to know what cards are used and gpu and memory loads when i run theese codes. I’ll need to do this in a command-line environment. Also, I was wondering if there is a way to select cards to use at runtime.
for i in seq 0 $N;do
PROC=/usr/sbin/lsof /dev/nvidia$i |grep mem |awk '{print $4}'
if [ “$PROC” = “mem” ];then
echo card $i in use
else
echo card $i is available
fi
done
You may want to look at the exclusive mode in CUDA 2.2, the driver will automatically select an available device for you.