Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A bash script to determine GPU and its RAM (under Linux)
- # Prerequisites: bash, sed, awk, lshw
- # (c) 2010 Artem S. Tashkinov. Licensed under GPLv2 :)
- #! /bin/bash
- if ! lshw -version &> /dev/null; then
- echo "Please, install lshw utility"
- exit 0
- fi
- ramregions()
- {
- ram=`sed 's/(prefetchable)//g' | awk '{for (i=1;i<=NF;i++) if ($i ~ "memory") print $i}' | awk -F : '{print $2}' | tr a-z A-Z`
- echo -e "ibase=16;\n$ram" | bc | awk '{sum+=$1}END{print (0-sum)/1024/1024"MB"}'
- }
- cpu2gpu()
- {
- if echo "$@" | grep -q "Core Processor"; then
- echo `grep "model name" /proc/cpuinfo | head -1 | awk -F : '{print $2}' | sed 's/[ ]\{2,\}/ /g;s/^ *//;s/ *$//'`" Integrated Graphics"
- else
- echo "$@"
- fi
- }
- outfile=`mktemp` || exit 1
- lshw -class display -disable dmi -quiet &> "$outfile" || exit 2
- cat "$outfile" | while read a; do
- case "$a" in
- *product:*)
- gpu=`echo $a | awk -F 'product: ' '/product:/ {print $2}'`
- ;;
- *memory:*)
- ram=`echo $a | ramregions`
- ;;
- esac
- if [ -n "$gpu" -a -n "$ram" ]; then
- gpu=`cpu2gpu "$gpu"`
- echo "GPU: [$gpu] RAM: [$ram]"
- unset gpu
- unset ram
- fi
- done
- /bin/rm $outfile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement