#!/bin/bash
echo "=== ENV ==="
echo "HSA_OVERRIDE=$HSA_OVERRIDE_GFX_VERSION"
echo "SDMA=$HSA_ENABLE_SDMA"
echo "HIP_VIS=$HIP_VISIBLE_DEVICES"

echo "=== RAM ==="
free -m

echo "=== COMFYUI ==="
if [ -f ~/ComfyUI/main.py ]; then echo "ComfyUI: EXISTS"; else echo "ComfyUI: MISSING"; fi
if [ -f ~/ComfyUI/venv/bin/python3.11 ]; then echo "Venv: EXISTS"; else echo "Venv: MISSING"; fi

echo "=== MODELS ==="
ls -lh ~/ComfyUI/models/unet/ 2>/dev/null || echo "NO unet dir"
ls -lh ~/ComfyUI/models/text_encoders/ 2>/dev/null || echo "NO text_encoders dir"
ls -lh ~/ComfyUI/models/vae/ 2>/dev/null || echo "NO vae dir"

echo "=== PYTORCH BUILD ==="
if [ -d ~/pytorch-build ]; then du -sh ~/pytorch-build; else echo "NO BUILD DIR"; fi

echo "=== PYTHON ==="
python3.11 --version 2>/dev/null || echo "NO python3.11"
if [ -f ~/ComfyUI/venv/bin/python ]; then
    source ~/ComfyUI/venv/bin/activate
    python -c "import torch; print('PyTorch:', torch.__version__); print('CUDA avail:', torch.cuda.is_available()); print('Arch list:', torch.cuda.get_arch_list())" 2>/dev/null || echo "PyTorch import failed"
fi

echo "=== DMESG ==="
sudo dmesg 2>/dev/null | grep -cE "KIQ|GPU died|GPU unreachable" || echo "0"
sudo dmesg 2>/dev/null | grep -c "BC-250" || echo "0"
sudo dmesg 2>/dev/null | grep "BC-250" | head -3

echo "=== CUSTOM NODES ==="
ls ~/ComfyUI/custom_nodes/ 2>/dev/null || echo "NO custom_nodes"

echo "=== DONE ==="
