File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,7 +7,30 @@ osname=$(cat /etc/*release | grep PRETTY_NAME | awk -F= ' {print $2 } ')
77cpuname=$( cat /proc/cpuinfo | grep ' model name' | awk -F: ' { sum+=1; model=$2 } END { print $2 ", " sum " cores" }' )
88meminfo=$( free -g | grep Mem | awk ' { print $2 } ' )
99
10+ if command -v lspci & > /dev/null; then
11+ gpuinfo=$( lspci | grep -E -i ' (vga|3d controller|display controller)' | sed ' s/.*: //' )
12+ else
13+ gpuinfo=" (lspci not available)"
14+ fi
15+
16+ # Try to get GPU VRAM: nvidia-smi for NVIDIA, sysfs for AMD
17+ gpumem=" "
18+ if command -v nvidia-smi & > /dev/null; then
19+ gpumem=$( nvidia-smi --query-gpu=memory.total --format=csv,noheader 2> /dev/null | paste -sd ' /' -)
20+ elif ls /sys/class/drm/card* /device/mem_info_vram_total & > /dev/null 2>&1 ; then
21+ gpumem=$( awk ' {printf "%.0f MiB", $1/1024/1024}' /sys/class/drm/card* /device/mem_info_vram_total | paste -sd ' /' -)
22+ fi
23+
1024# print it
1125echo " - OS: $osname "
1226echo " - Processor: $cpuname "
13- echo " - Memory available: ${meminfo} GB memory"
27+ echo " - Memory available: ${meminfo} GB memory"
28+ if [ -n " $gpuinfo " ]; then
29+ memsuffix=" "
30+ [ -n " $gpumem " ] && memsuffix=" ($gpumem )"
31+ echo " $gpuinfo " | while IFS= read -r line; do
32+ echo " - GPU: ${line}${memsuffix} "
33+ done
34+ else
35+ echo " - GPU: none detected"
36+ fi
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Tested on macOS (Intel and Apple Silicon)
4+
5+ echo " System info:"
6+ osname=$( sw_vers -productName) " " $( sw_vers -productVersion)
7+ cpuname=$( sysctl -n machdep.cpu.brand_string 2> /dev/null || sysctl -n hw.model)
8+ cpucores=$( sysctl -n hw.logicalcpu)
9+ meminforaw=$( sysctl -n hw.memsize)
10+ meminfo=$(( meminforaw / 1024 / 1024 / 1024 ))
11+
12+ gpuinfo=$( system_profiler SPDisplaysDataType 2> /dev/null \
13+ | awk ' /Chipset Model:/ { sub(/.*Chipset Model: /, ""); print }' )
14+
15+ # print it
16+ echo " - OS: $osname "
17+ echo " - Processor: $cpuname , $cpucores cores"
18+ echo " - Memory available: ${meminfo} GB memory"
19+ if [ -n " $gpuinfo " ]; then
20+ echo " $gpuinfo " | while IFS= read -r line; do
21+ echo " - GPU: $line "
22+ done
23+ else
24+ echo " - GPU: none detected"
25+ fi
You can’t perform that action at this time.
0 commit comments