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 -e .

Or with PyTorch:

pip install -e ".[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.0.tar.gz (38.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.0-py3-none-any.whl (38.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: crusoe_estimator-0.1.0.tar.gz
  • Upload date:
  • Size: 38.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.0.tar.gz
Algorithm Hash digest
SHA256 37753fc0e281dda8393a25a405c64cb49cea4ee12559368722ddf9bcac8566b6
MD5 54f7b350c649c2bcc31ceab09acab79d
BLAKE2b-256 90249bc81aa1cbcccb1d7889ca352323c7e39403857b2ff4be69428baab70516

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for crusoe_estimator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93694c3607d48b67f639646791951fdded5072157cf4b2a0f7aeef20e860d8ec
MD5 6c3bc9164553d1c6f8d129356121975f
BLAKE2b-256 5d9c2cd40fff2d573f6040385b2240c92b00a2875d3c31fcf2992be652869728

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