| |
| """ |
| Script para verificar la configuración de ZeroGPU en el Space NTIA |
| """ |
|
|
| import os |
| import torch |
|
|
| def check_zero_gpu_config(): |
| """Verificar la configuración de ZeroGPU""" |
| print("🔍 Verificando configuración de ZeroGPU...") |
| print("=" * 60) |
| |
| |
| print("📋 Variables de entorno:") |
| print(f" SPACES_GPU_TIMEOUT: {os.getenv('SPACES_GPU_TIMEOUT', 'No configurado')}") |
| print(f" SPACES_GPU_MEMORY: {os.getenv('SPACES_GPU_MEMORY', 'No configurado')}") |
| print(f" HF_TOKEN: {'Configurado' if os.getenv('HF_TOKEN') else 'No configurado'}") |
| |
| |
| print("\n🎮 Información de GPU:") |
| if torch.cuda.is_available(): |
| print(f" ✅ CUDA disponible: {torch.cuda.is_available()}") |
| print(f" 🎮 GPU: {torch.cuda.get_device_name(0)}") |
| print(f" 💾 Memoria total: {torch.cuda.get_device_properties(0).total_memory / 1024**3:.1f} GB") |
| print(f" 🔥 Capacidad CUDA: {torch.cuda.get_device_capability()}") |
| |
| |
| gpu_name = torch.cuda.get_device_name(0) |
| if "H200" in gpu_name: |
| print(" ✅ ZeroGPU H200 detectado - Plan Pro activo") |
| else: |
| print(f" ⚠️ GPU detectada: {gpu_name}") |
| print(" 💡 Considera actualizar al plan Pro") |
| else: |
| print(" ❌ CUDA no disponible") |
| |
| |
| print("\n🔧 Configuración de Spaces:") |
| print(" 📊 Decoradores configurados:") |
| print(" - @spaces.GPU(compute_unit='gpu.h200.micro', timeout=30)") |
| print(" - @spaces.GPU(compute_unit='gpu.h200.micro', timeout=60)") |
| |
| |
| print("\n⚡ Optimizaciones CUDA:") |
| print(f" 🔧 torch.backends.cudnn.benchmark: {torch.backends.cudnn.benchmark}") |
| print(f" 🔧 torch.backends.cuda.matmul.allow_tf32: {torch.backends.cuda.matmul.allow_tf32}") |
| print(f" 🔧 torch.backends.cudnn.allow_tf32: {torch.backends.cudnn.allow_tf32}") |
| |
| |
| print("\n📊 Configuración de tipos de datos:") |
| if torch.cuda.is_available(): |
| torch_dtype = torch.float16 |
| print(" ⚡ Usando torch.float16 para H200") |
| else: |
| torch_dtype = torch.float32 |
| print(" 🐌 Usando torch.float32 para CPU") |
| |
| |
| print("\n💡 Recomendaciones:") |
| if torch.cuda.is_available(): |
| gpu_name = torch.cuda.get_device_name(0) |
| if "H200" in gpu_name: |
| print(" ✅ Configuración correcta para Plan Pro") |
| print(" 🚀 El Space está usando ZeroGPU H200") |
| else: |
| print(" ⚠️ Considera actualizar al plan Pro") |
| print(" 💡 Plan Pro incluye H200 con 25 minutos/día") |
| else: |
| print(" ❌ No se detectó GPU") |
| print(" 💡 Verifica la configuración del Space") |
| |
| |
| print("\n📁 Verificación de archivo app.py:") |
| try: |
| with open('app.py', 'r', encoding='utf-8') as f: |
| content = f.read() |
| |
| |
| if "gpu.h200.micro" in content: |
| print(" ✅ Decoradores H200 configurados correctamente") |
| else: |
| print(" ❌ Decoradores H200 no encontrados") |
| |
| |
| if "ZeroGPU H200 detectado" in content: |
| print(" ✅ Configuración H200 detectada") |
| else: |
| print(" ⚠️ Configuración H200 no encontrada") |
| |
| except FileNotFoundError: |
| print(" ❌ Archivo app.py no encontrado") |
| |
| print("\n" + "=" * 60) |
| print("✅ Verificación completada") |
|
|
| if __name__ == "__main__": |
| check_zero_gpu_config() |