#!/bin/bash
echo "=== DMESG GPU ==="
sudo dmesg | grep -iE "amdgpu|gfx|error|reset|fault" | tail -15

echo "=== KFD THREADS ==="
ls /proc/15070/task/ | while read tid; do
    wchan=$(cat /proc/15070/task/$tid/wchan 2>/dev/null)
    if [ "$wchan" = "kfd_wait_on_events" ] || [ "$wchan" = "poll_idle" ]; then
        echo "Thread $tid: $wchan"
    fi
done

echo "=== LOG ERRORS ==="
grep -i "error\|traceback\|exception\|fail" /home/fabian/comfyui5.log 2>/dev/null | tail -10

echo "=== LOG LAST LINE (not clip) ==="
grep -v "clip missing" /home/fabian/comfyui5.log | tail -5
