#!/bin/bash
cd /home/fabian/ComfyUI
source venv/bin/activate

export HSA_OVERRIDE_GFX_VERSION=10.1.0
export HSA_ENABLE_SDMA=0
export HIP_VISIBLE_DEVICES=0
export ROCM_PATH=/opt/rocm
export OMP_NUM_THREADS=12
export MKL_NUM_THREADS=12
export NUMEXPR_NUM_THREADS=12
export PYTORCH_HIP_ALLOC_CONF="expandable_segments:False"

# Unset harmful vars
unset GPU_MAX_HW_QUEUES 2>/dev/null || true
unset HIP_LAUNCH_BLOCKING 2>/dev/null || true

echo "Starting ComfyUI..."
echo "PyTorch: $(python3.11 -c 'import torch; print(torch.__version__)')"
echo "GPU: $(python3.11 -c 'import torch; print(torch.cuda.get_device_name(0) if torch.cuda.is_available() else \"NONE\")')"

python main.py \
    --listen 0.0.0.0 \
    --port 8188 \
    --force-fp32 \
    --lowvram
