Support multi-gpu environment
This commit is contained in:
parent
60c2017fb0
commit
14ad891d3d
1 changed files with 6 additions and 6 deletions
|
@ -4,7 +4,7 @@ get_platform()
|
||||||
{
|
{
|
||||||
case $(uname -s) in
|
case $(uname -s) in
|
||||||
Linux)
|
Linux)
|
||||||
gpu=$(lspci -v | grep -i gpu | grep driver | awk '{print $5}')
|
gpu=$(lspci -v | grep VGA | head -n 1 | awk '{print $5}')
|
||||||
echo $gpu
|
echo $gpu
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -20,10 +20,12 @@ get_platform()
|
||||||
get_gpu()
|
get_gpu()
|
||||||
{
|
{
|
||||||
gpu=$(get_platform)
|
gpu=$(get_platform)
|
||||||
if [ $gpu == nvidia-gpu ]; then
|
if [[ "$gpu" == NVIDIA ]]; then
|
||||||
usage=$(nvidia-smi | grep "%" | awk '{print $13}')
|
usage=$(nvidia-smi | grep '%' | awk '{ sum += $13 } END { printf("%d%%\n", sum / NR) }')
|
||||||
echo $usage
|
else
|
||||||
|
usage='unknown'
|
||||||
fi
|
fi
|
||||||
|
echo $usage
|
||||||
}
|
}
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
|
@ -33,5 +35,3 @@ main()
|
||||||
}
|
}
|
||||||
# run the main driver
|
# run the main driver
|
||||||
main
|
main
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue