#!/usr/bin/env bash
# Activate GPU training environment with correct library paths

VENV_DIR="$HOME/.venv/spies-gpu"

if [ ! -d "$VENV_DIR" ]; then
  echo "GPU environment not found. Run setup first:"
  echo "  bash tools/setup-local-gpu-final.sh"
  return 1
fi

source "$VENV_DIR/bin/activate"

# Set library paths for CUDA and NVIDIA driver
export LD_LIBRARY_PATH="/nix/store/ab3753m6i7isgvzphlar0a8xb84gl96i-gcc-15.2.0-lib/lib:/nix/store/755d2m4ix0gm2k0nn4l85cziaccn4dr2-nvidia-x11-580.142-6.12.85/lib:$LD_LIBRARY_PATH"

echo "GPU training environment activated"
echo "=================================="
python3 -c "
import torch
print(f'PyTorch: {torch.__version__}')
print(f'CUDA: {torch.cuda.is_available()}')
if torch.cuda.is_available():
    print(f'GPU: {torch.cuda.get_device_name(0)}')
    print(f'Memory: {torch.cuda.get_device_properties(0).total_memory / 1e9:.2f} GB')
"
