| # 🚀 Opções para Testar no GCP | |
| Você tem **4 opções** para testar o sistema no GCP. Escolha a mais conveniente: | |
| --- | |
| ## ⭐ OPÇÃO 1: Google Cloud Shell (RECOMENDADO - GRÁTIS!) | |
| **Vantagens**: | |
| - ✅ **100% Grátis** (Cloud Shell é grátis) | |
| - ✅ Já tem gcloud instalado | |
| - ✅ Não precisa instalar nada local | |
| - ✅ Mais rápido e fácil | |
| **Como fazer**: | |
| 1. Abra o Cloud Shell: https://shell.cloud.google.com/ | |
| 2. No terminal do Cloud Shell, rode: | |
| ```bash | |
| # Download do script | |
| curl -O https://huggingface.co/marcosremar2/ensemble-tts-annotation/raw/main/scripts/test/launch_gcp_spot.sh | |
| # Tornar executável | |
| chmod +x launch_gcp_spot.sh | |
| # Rodar | |
| ./launch_gcp_spot.sh | |
| ``` | |
| 3. O script vai: | |
| - ✅ Buscar instância mais barata (~e2-medium) | |
| - ✅ Criar instância spot | |
| - ✅ Instalar dependências | |
| - ✅ Rodar teste | |
| - ✅ Mostrar resultados | |
| 4. Quando terminar, delete a instância: | |
| ```bash | |
| gcloud compute instances delete ensemble-test-XXX --zone=us-central1-a --quiet | |
| ``` | |
| **Custo**: $0 (Cloud Shell) + ~$0.003 (instância por 20min) = **~$0.003 total** | |
| --- | |
| ## 🌐 OPÇÃO 2: Console Web (Interface Gráfica) | |
| **Vantagens**: | |
| - ✅ Visual e intuitivo | |
| - ✅ Não precisa de terminal | |
| - ✅ Fácil para iniciantes | |
| **Como fazer**: | |
| 1. Acesse: https://console.cloud.google.com/compute/instances | |
| 2. Click **CREATE INSTANCE** | |
| 3. Configure: | |
| - Nome: `ensemble-test` | |
| - Região: `us-central1 (Iowa)` | |
| - Zona: `us-central1-a` | |
| - Tipo: `e2-medium` (2 vCPU, 4GB RAM) | |
| - ✅ **Marcar**: Spot (Preemptible) | |
| - Disco: Ubuntu 22.04 LTS, 20GB | |
| 4. Em **Management → Automation**, cole este script: | |
| ```bash | |
| #!/bin/bash | |
| apt-get update && apt-get install -y python3-pip git | |
| pip3 install --upgrade pip | |
| cd /home && git clone https://huggingface.co/marcosremar2/ensemble-tts-annotation | |
| cd ensemble-tts-annotation | |
| pip3 install torch --index-url https://download.pytorch.org/whl/cpu | |
| pip3 install transformers datasets librosa soundfile numpy pandas tqdm scikit-learn | |
| python3 test_local.py > /tmp/test-results.log 2>&1 | |
| echo "✅ Done. Results: cat /tmp/test-results.log" | |
| ``` | |
| 5. Click **CREATE** | |
| 6. Após 2 minutos, click **SSH** e rode: | |
| ```bash | |
| cat /tmp/test-results.log | |
| ``` | |
| 7. **Delete** a instância quando terminar! | |
| **Custo**: ~$0.003 (20 minutos) | |
| --- | |
| ## 💻 OPÇÃO 3: Instalar gcloud CLI Localmente | |
| **Vantagens**: | |
| - ✅ Controle total do terminal | |
| - ✅ Automação completa | |
| - ✅ Reutilizável para outros projetos | |
| **Como fazer**: | |
| 1. Instalar gcloud: | |
| ```bash | |
| # macOS | |
| brew install google-cloud-sdk | |
| # Ou download direto | |
| curl https://sdk.cloud.google.com | bash | |
| exec -l $SHELL | |
| ``` | |
| 2. Configurar: | |
| ```bash | |
| gcloud init | |
| ``` | |
| 3. Rodar o script: | |
| ```bash | |
| cd ensemble-tts-annotation | |
| bash scripts/test/launch_gcp_spot.sh | |
| ``` | |
| **Custo**: ~$0.003 | |
| --- | |
| ## 🐍 OPÇÃO 4: Script Python (Sem gcloud CLI) | |
| **Vantagens**: | |
| - ✅ Não precisa de gcloud CLI | |
| - ✅ Usa API do GCP diretamente | |
| - ✅ Programático | |
| **Como fazer**: | |
| 1. Instalar biblioteca: | |
| ```bash | |
| pip install google-cloud-compute google-auth | |
| ``` | |
| 2. Autenticar: | |
| **Opção A** - Application Default Credentials (se tem gcloud): | |
| ```bash | |
| gcloud auth application-default login | |
| ``` | |
| **Opção B** - Service Account (sem gcloud): | |
| 1. Console: https://console.cloud.google.com/iam-admin/serviceaccounts | |
| 2. Create Service Account | |
| 3. Grant role: **Compute Instance Admin** | |
| 4. Create key → Download JSON | |
| 5. Set environment: | |
| ```bash | |
| export GOOGLE_APPLICATION_CREDENTIALS="/path/to/key.json" | |
| export GCP_PROJECT_ID="seu-projeto-id" | |
| ``` | |
| 3. Rodar script: | |
| ```bash | |
| python scripts/test/launch_gcp_python.py | |
| ``` | |
| **Custo**: ~$0.003 | |
| --- | |
| ## 📊 Comparação das Opções | |
| | Opção | Setup | Facilidade | Custo | Tempo | | |
| |-------|-------|------------|-------|-------| | |
| | **1. Cloud Shell** | 0 min | ⭐⭐⭐⭐⭐ | $0.003 | 5 min | | |
| | **2. Console Web** | 0 min | ⭐⭐⭐⭐ | $0.003 | 10 min | | |
| | **3. gcloud CLI** | 5 min | ⭐⭐⭐ | $0.003 | 5 min | | |
| | **4. Python API** | 10 min | ⭐⭐ | $0.003 | 5 min | | |
| --- | |
| ## 🎯 Minha Recomendação | |
| **Use a OPÇÃO 1 (Cloud Shell)**: | |
| 1. É **grátis** (Cloud Shell não cobra) | |
| 2. É **mais rápido** (já tem tudo instalado) | |
| 3. É **mais fácil** (só copiar e colar) | |
| ```bash | |
| # Literalmente 3 comandos: | |
| curl -O https://huggingface.co/marcosremar2/ensemble-tts-annotation/raw/main/scripts/test/launch_gcp_spot.sh | |
| chmod +x launch_gcp_spot.sh | |
| ./launch_gcp_spot.sh | |
| ``` | |
| --- | |
| ## ⚠️ IMPORTANTE: Deletar Instância | |
| **Não esqueça de deletar** quando terminar! | |
| ```bash | |
| # Via gcloud | |
| gcloud compute instances delete ensemble-test-XXX --zone=us-central1-a --quiet | |
| # Via console | |
| https://console.cloud.google.com/compute/instances | |
| → Selecionar instância → DELETE | |
| ``` | |
| Se esquecer rodando, custo máximo: | |
| - $0.01/hora × 24 horas = **$0.24/dia** | |
| - GCP vai enviar alerta de cobrança | |
| --- | |
| ## 📝 Checklist | |
| Antes de começar, certifique-se: | |
| - [ ] Tem conta GCP (gratuita serve: https://cloud.google.com/free) | |
| - [ ] Tem projeto criado | |
| - [ ] Compute Engine API está habilitada | |
| - [ ] Tem créditos ou cartão configurado (custo: ~$0.003) | |
| Se primeira vez usando GCP: | |
| 1. https://console.cloud.google.com/ | |
| 2. Create new project | |
| 3. Enable Compute Engine API | |
| 4. Seguir OPÇÃO 1 (Cloud Shell) | |
| --- | |
| ## 🚀 Quick Start | |
| **Para começar AGORA (5 minutos)**: | |
| 1. Abrir: https://shell.cloud.google.com/ | |
| 2. Colar: | |
| ```bash | |
| curl -O https://huggingface.co/marcosremar2/ensemble-tts-annotation/raw/main/scripts/test/launch_gcp_spot.sh && chmod +x launch_gcp_spot.sh && ./launch_gcp_spot.sh | |
| ``` | |
| 3. Seguir instruções | |
| 4. Ver resultados | |
| 5. Deletar instância | |
| **Pronto!** 🎉 | |
| Custo total: **menos de 1 centavo** 💰 | |