Skip to content

Commit b4643a2

Browse files
larsvilhuberclaude
andcommitted
Add GPU detection and macOS system info script
Extend linux-system-info.sh with GPU name (via lspci) and VRAM (via nvidia-smi or AMD sysfs). Add macos-system-info.sh with equivalent OS, CPU, memory, and GPU info using macOS-native tools. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5ba7cdc commit b4643a2

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

tools/linux-system-info.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,30 @@ osname=$(cat /etc/*release | grep PRETTY_NAME | awk -F= ' {print $2 } ')
77
cpuname=$(cat /proc/cpuinfo | grep 'model name' | awk -F: ' { sum+=1; model=$2 } END { print $2 ", " sum " cores" }')
88
meminfo=$(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
1125
echo "- OS: $osname"
1226
echo "- 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

tools/macos-system-info.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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

0 commit comments

Comments
 (0)