| """ |
| Busca de Clusters Multi-GPU e GPUs Flagship no Vast.ai. |
| """ |
|
|
| import subprocess |
| import json |
|
|
| def search_clusters(): |
| cmd = [ |
| '/home/j/.local/bin/vastai', |
| 'search', |
| 'offers', |
| 'reliability > 0.95 inet_down > 150 (num_gpus >= 2 or gpu_name = H100 or gpu_name = H100_SXM or gpu_name = H200)', |
| '-o', |
| 'dph', |
| '--raw' |
| ] |
| res = subprocess.run(cmd, capture_output=True, text=True) |
| if res.returncode != 0: |
| print("Erro:", res.stderr) |
| return |
|
|
| offers = json.loads(res.stdout) |
| categories = {} |
|
|
| for o in offers: |
| gpu_name = o.get('gpu_name', 'Unknown') |
| num_gpus = o.get('num_gpus', 1) |
| dph = o.get('dph_total', 999.0) |
| total_vram = (o.get('gpu_ram', 0)) / 1024.0 |
| dlperf = o.get('dlperf', 0) |
| inet_down = o.get('inet_down', 0) |
| reliability = (o.get('reliability2') or o.get('reliability') or 0.98) * 100 |
| offer_id = o.get('id') |
|
|
| key = f"{num_gpus}x {gpu_name}" if num_gpus > 1 else gpu_name |
|
|
| if key not in categories or dph < categories[key]['dph']: |
| categories[key] = { |
| 'id': offer_id, |
| 'name': key, |
| 'num_gpus': num_gpus, |
| 'total_vram_gb': round(total_vram, 1), |
| 'dph': round(dph, 3), |
| 'dlperf': round(dlperf, 1), |
| 'inet_down_mbps': round(inet_down, 0), |
| 'reliability_pct': round(reliability, 1) |
| } |
|
|
| print(json.dumps(categories, indent=2)) |
|
|
| if __name__ == "__main__": |
| search_clusters() |
|
|