Skip to main content

PyTorch Training Cost & Carbon Estimator for Crusoe Cloud

Project description

⚡ crusoe-estimator

PyTorch Training Cost & Carbon Estimator for Crusoe Cloud

Benchmark your PyTorch training loop locally on a small sample, then get instant estimates for:

  • ⏱️ Training time on every Crusoe Cloud GPU (A100, H100, H200, MI300X)
  • 💰 Cost on Crusoe Cloud
  • 🌍 CO₂ savings — your local emissions vs Crusoe's near-zero carbon footprint

Installation

pip install crusoe-estimator

Or with PyTorch (if not already installed):

pip install "crusoe-estimator[torch]"

Quick Start

Pattern 1: Training Loop Wrapper (Recommended)

from crusoe_estimator import CrusoeEstimator

estimator = CrusoeEstimator(total_epochs=100, location="HR")

for epoch in estimator.epochs(sample=3):
    # Your normal training code — runs only 3 epochs
    for batch_x, batch_y in train_loader:
        optimizer.zero_grad()
        output = model(batch_x)
        loss = criterion(output, batch_y)
        loss.backward()
        optimizer.step()

# Generate a beautiful HTML report
estimator.generate_report("training_report.html")

# Or print a text summary
print(estimator.summary())

Pattern 2: Decorator

estimator = CrusoeEstimator(total_epochs=100, location="DE")

@estimator.watch(sample_epochs=3)
def train_epoch(model, dataloader, optimizer, criterion):
    for x, y in dataloader:
        optimizer.zero_grad()
        loss = criterion(model(x), y)
        loss.backward()
        optimizer.step()

# Calling the decorated function runs 3 epochs and benchmarks
train_epoch(model, train_loader, optimizer, criterion)
estimator.generate_report("report.html")

Pattern 3: Context Manager

estimator = CrusoeEstimator(total_epochs=100, sample_epochs=5, location="US")

with estimator.track():
    for epoch in range(5):
        train_one_epoch(model, train_loader, optimizer, criterion)

estimator.generate_report("report.html")

Pattern 4: Function Wrapper

estimator = CrusoeEstimator(total_epochs=100, location="HR")

result = estimator.estimate(
    train_fn=lambda: train_one_epoch(model, loader, optimizer, criterion),
    sample_epochs=3,
)

estimator.generate_report("report.html")

Dataset Scaling

If you benchmark with a smaller dataset:

estimator = CrusoeEstimator(
    total_epochs=100,
    total_dataset_size=50000,
    sample_dataset_size=5000,  # Using 10% of data
    location="HR",
)

Supported GPUs

Crusoe Cloud

GPU FP16 TFLOPS Memory Price/hr
A100 80GB 312 80 GB $1.47
H100 SXM 989 80 GB $2.25
H200 SXM 989 141 GB $3.25
MI300X 1307 192 GB $2.49

Local GPU Detection

Automatically detects 50+ GPUs:

  • NVIDIA: RTX 20/30/40 series, A100, H100, V100, T4
  • AMD: MI300X, MI250X
  • Apple Silicon: M1–M4 (all variants)

How It Works

  1. Detect local GPU and its specifications (FLOPS, memory, TDP)
  2. Benchmark your training loop for N sample epochs
  3. Extrapolate total training time using average epoch time
  4. Scale to Crusoe GPUs using FLOPS ratio (70% compute + 30% memory bandwidth weighting)
  5. Calculate cost based on Crusoe pricing
  6. Estimate CO₂ using regional carbon intensity (local) vs near-zero (Crusoe)
  7. Generate an HTML report with tables, charts, and recommendations

Carbon Intensity

Uses real-world carbon intensity data (kg CO₂/kWh):

  • 🇭🇷 Croatia: 0.170
  • 🇩🇪 Germany: 0.340
  • 🇫🇷 France: 0.056
  • 🇺🇸 USA: 0.390
  • 🇨🇳 China: 0.560
  • ☁️ Crusoe: ≈ 0.000 (renewable energy)

API Reference

CrusoeEstimator

Main class. Constructor parameters:

  • total_epochs — how many epochs the full training would run
  • sample_epochs — how many epochs to actually benchmark (default: 3)
  • total_dataset_size — full dataset size (optional, for scaling)
  • sample_dataset_size — dataset size used in sample (optional)
  • location — country code for CO₂ calculation (e.g., "HR", "US", "DE")
  • power_watts_override — override auto-detected GPU power draw

Reports

  • estimator.generate_report("report.html") — HTML report
  • estimator.summary() — text summary

Built with 💚 at HackEurope 2026 • Powered by Crusoe Cloud

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crusoe_estimator-0.1.1.tar.gz (40.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crusoe_estimator-0.1.1-py3-none-any.whl (41.2 kB view details)

Uploaded Python 3

File details

Details for the file crusoe_estimator-0.1.1.tar.gz.

File metadata

  • Download URL: crusoe_estimator-0.1.1.tar.gz
  • Upload date:
  • Size: 40.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for crusoe_estimator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bf26d7b11ca55b9c5e8f02ec9b9b233fb0bf8734110d9844b448f6e010cf1c51
MD5 42c7bb8f1617827e7730fa5d332af8d8
BLAKE2b-256 748fb496fcd6dd6b11a21000feadaaffabbccd8d1cf47313b4fb88ed1c0b642a

See more details on using hashes here.

File details

Details for the file crusoe_estimator-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for crusoe_estimator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 af11ea3fd19029def30c2bbea4ce15d9b045fac7fdd3b65d7d27c86c48819259
MD5 2762a81e7f06925250744fb4a4f49280
BLAKE2b-256 6b728bb7bf0f1f4b2ce4443025d8a1ceed090f025b74fa61c46a42856102c855

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page