HNTAI / scripts /switch_hf_config.sh
sachinchandrankallar's picture
changes for publishing the latest including generate_generic api
4156c57
#!/bin/bash
# Quick configuration switcher for HF Spaces deployment
# Usage: ./switch_hf_config.sh [minimal|small-gpu|medium-gpu]
set -e
CONFIG=$1
if [ -z "$CONFIG" ]; then
echo "Usage: $0 [minimal|small-gpu|medium-gpu]"
echo ""
echo "Options:"
echo " minimal - CPU only, fastest deployment (recommended)"
echo " small-gpu - T4 Small GPU, good balance"
echo " medium-gpu - T4 Medium GPU, full preloading (Pro/Enterprise)"
echo ""
exit 1
fi
case $CONFIG in
minimal)
echo "πŸ”§ Switching to MINIMAL configuration (CPU-only)..."
cat > .huggingface.yaml << 'EOF'
runtime: docker
sdk: docker
python_version: "3.10"
build:
dockerfile: Dockerfile.hf-spaces-minimal
cache: true
env:
- HF_SPACES=true
- FAST_MODE=true
- PRELOAD_GGUF=false
- PRELOAD_SMALL_MODELS=false
EOF
echo "βœ… Configuration updated to CPU-only mode"
echo "πŸ“ This will deploy on the free tier (no GPU)"
echo "⚑ Build time: ~5-10 minutes"
;;
small-gpu)
echo "πŸ”§ Switching to SMALL GPU configuration (T4 Small)..."
cat > .huggingface.yaml << 'EOF'
runtime: docker
sdk: docker
python_version: "3.10"
build:
dockerfile: Dockerfile.hf-spaces-minimal
cache: true
hardware:
gpu: t4-small
env:
- HF_SPACES=true
- FAST_MODE=true
- PRELOAD_GGUF=false
- PRELOAD_SMALL_MODELS=false
- CUDA_VISIBLE_DEVICES=0
- PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:128
EOF
echo "βœ… Configuration updated to T4 Small GPU"
echo "πŸ“ Requires GPU access in your HF account"
echo "⚑ Build time: ~10-15 minutes"
;;
medium-gpu)
echo "πŸ”§ Switching to MEDIUM GPU configuration (T4 Medium + Preloading)..."
cat > .huggingface.yaml << 'EOF'
runtime: docker
sdk: docker
python_version: "3.10"
build:
dockerfile: Dockerfile.hf-spaces
cache: true
hardware:
gpu: t4-medium
env:
- SPACE_ID=$SPACE_ID
- HF_HOME=/app/.cache/huggingface
- TORCH_HOME=/app/.cache/torch
- MODEL_CACHE_DIR=/app/models
- PRELOAD_GGUF=true
- HF_SPACES=true
- CUDA_VISIBLE_DEVICES=0
- PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512
EOF
echo "βœ… Configuration updated to T4 Medium GPU with preloading"
echo "πŸ“ Requires Pro/Enterprise tier"
echo "⚑ Build time: ~20-30 minutes (first time), instant startup"
;;
*)
echo "❌ Invalid option: $CONFIG"
echo "Use: minimal, small-gpu, or medium-gpu"
exit 1
;;
esac
echo ""
echo "πŸ“‹ Next steps:"
echo " 1. Review the changes: git diff .huggingface.yaml"
echo " 2. Commit: git commit -am 'Switch to $CONFIG configuration'"
echo " 3. Push: git push"
echo " 4. Monitor your Space build logs"
echo ""
echo "πŸ” Check status at: https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE"