File size: 1,173 Bytes
28d5f26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""
Busca de instâncias ativas de 4x RTX 4090 e 2x RTX 5090 no Vast.ai.
"""
import subprocess
import json

def get_offers():
    cmd = ['/home/j/.local/bin/vastai', 'search', 'offers', 'reliability > 0.94 inet_down > 150 (num_gpus = 4 and gpu_name = RTX_4090) or (num_gpus = 2 and gpu_name = RTX_5090) or (num_gpus = 1 and gpu_name = RTX_5090)', '-o', 'dph', '--raw']
    res = subprocess.run(cmd, capture_output=True, text=True)
    if res.returncode != 0:
        # Tentar busca simples
        cmd = ['/home/j/.local/bin/vastai', 'search', 'offers', 'reliability > 0.94 inet_down > 150 dlperf > 150', '-o', 'dph', '--raw']
        res = subprocess.run(cmd, capture_output=True, text=True)

    offers = json.loads(res.stdout)
    print(f"Total de ofertas encontradas: {len(offers)}")
    for o in offers[:8]:
        name = f"{o.get('num_gpus')}x {o.get('gpu_name')}"
        dph = round(o.get('dph_total', 0), 3)
        dlperf = round(o.get('dlperf', 0), 1)
        net = round(o.get('inet_down', 0))
        offer_id = o.get('id')
        print(f"ID: {offer_id} | {name} | DLPerf: {dlperf} | ${dph}/h | Net: {net} Mbps")

if __name__ == "__main__":
    get_offers()