Quick Start: Rent Your First GPU

What We're Building

A Python script that finds an available GPU server, rents it, connects via SSH, runs a CUDA test, and releases the resources — all in under 5 minutes.

Prerequisites

Step 1: Set Up the Clore Client

📦 Using the standard Clore API client. See Clore API Client Reference for the full implementation and setup instructions. Save it as clore_client.py in your project.

from clore_client import CloreClient

client = CloreClient(api_key="your-api-key")

Step 2: Find an Available GPU

# find_gpu.py
from clore_client import CloreClient

def find_cheapest_gpu(client: CloreClient, gpu_type: str = "RTX 4090", 
                       max_price_usd: float = 0.50) -> dict:
    """Find the cheapest available GPU of specified type."""
    
    servers = client.get_marketplace()
    
    # Filter: available, matches GPU type, within price range
    candidates = []
    for server in servers:
        if server.get("rented"):
            continue
        
        gpu_array = server.get("gpu_array", [])
        if not any(gpu_type in gpu for gpu in gpu_array):
            continue
        
        # Get USD price (on-demand)
        price_usd = server.get("price", {}).get("usd", {}).get("on_demand_clore")
        if price_usd and price_usd <= max_price_usd:
            candidates.append({
                "id": server["id"],
                "gpus": gpu_array,
                "price_usd": price_usd,
                "reliability": server.get("reliability", 0),
                "specs": server.get("specs", {})
            })
    
    if not candidates:
        raise Exception(f"No {gpu_type} available under ${max_price_usd}/hr")
    
    # Sort by price, then reliability
    candidates.sort(key=lambda x: (x["price_usd"], -x["reliability"]))
    
    return candidates[0]

if __name__ == "__main__":
    client = CloreClient("YOUR_API_KEY")
    
    gpu = find_cheapest_gpu(client, "RTX 4090", max_price_usd=0.50)
    print(f"Found: Server {gpu['id']}")
    print(f"GPUs: {gpu['gpus']}")
    print(f"Price: ${gpu['price_usd']:.2f}/hr")
    print(f"Reliability: {gpu['reliability']}%")

Step 3: Rent the GPU

Step 4: Connect and Run CUDA Test

Step 5: Clean Up

Full Script: End-to-End GPU Rental

Running the Script

Last updated

Was this helpful?