#!/bin/bash
PID=$(pgrep -f main.py | head -n 1)
echo "PID=$PID"
echo "=== Process State ==="
cat /proc/$PID/status | grep -E "State|Threads|VmRSS"
echo ""
echo "=== GPU busy ==="
cat /sys/class/drm/card0/device/gpu_busy_percent 2>/dev/null
echo ""
echo "=== VRAM/GTT ==="
cat /sys/class/drm/card0/device/mem_info_gtt_used 2>/dev/null | awk '{printf "GTT used: %.0f MB\n", $1/1024/1024}'
cat /sys/class/drm/card0/device/mem_info_vram_used 2>/dev/null | awk '{printf "VRAM used: %.0f MB\n", $1/1024/1024}'
echo ""
echo "=== CPU usage ==="
top -b -n 2 -d 1 -p $PID 2>/dev/null | grep python | tail -n 1
echo ""
echo "=== dmesg GPU ==="
sudo dmesg | grep -i "amdgpu\|gfx\|drm" | tail -n 5
