VA

vastai-cost-tuning

Reduce Vast.ai cloud costs by optimizing instance selection and automating usage monitoring.

Install

mkdir -p .claude/skills/vastai-cost-tuning && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/6640" && unzip -o skill.zip -d .claude/skills/vastai-cost-tuning && rm skill.zip

Installs to .claude/skills/vastai-cost-tuning

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Optimize Vast.ai GPU cloud costs through smart instance selection and
69 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Select GPUs based on cost-per-TFLOP analysis
  • Compare interruptible and on-demand instance pricing
  • Implement auto-destroy safeguards for instances
  • Detect and destroy idle GPU instances
  • Generate daily cost burn rate reports
  • Pre-install dependencies in Docker images

How it works

The skill analyzes GPU specifications and pricing to recommend cost-efficient instances, then implements scripts to manage instance lifecycles and monitor utilization. It uses `vastai` CLI commands and Python scripts to automate these tasks.

Inputs & outputs

You give it
Vast.ai instance data, GPU specifications, desired maximum hours
You get back
GPU cost-efficiency analysis, spot vs on-demand comparison, auto-destroy watchdog, idle instance detection script, daily cost burn rate report

When to use vastai-cost-tuning

  • Compare cost-per-TFLOP across different GPU models
  • Automate instance lifecycle management
  • Implement auto-destroy safeguards for idle instances
  • Analyze Vast.ai billing and usage history

About this skill

Vast.ai Cost Tuning

Overview

Minimize Vast.ai GPU cloud costs by choosing the right GPU for your workload, leveraging interruptible (spot) instances, eliminating idle compute, and implementing auto-destroy safeguards. Vast.ai pricing is dynamic and varies significantly: RTX 4090 ($0.15-0.30/hr), A100 80GB ($1.00-2.00/hr), H100 SXM ($2.50-4.00/hr).

Prerequisites

  • Vast.ai account with billing history
  • Understanding of your workload's GPU requirements
  • vastai CLI installed

Instructions

Step 1: GPU Selection by Cost-Efficiency

# Compare cost-per-TFLOP across GPU types
GPU_SPECS = {
    "RTX_4090":  {"fp16_tflops": 82.6,  "vram": 24},
    "A100":      {"fp16_tflops": 77.97, "vram": 80},
    "H100_SXM":  {"fp16_tflops": 267,   "vram": 80},
    "RTX_3090":  {"fp16_tflops": 35.6,  "vram": 24},
    "A6000":     {"fp16_tflops": 38.7,  "vram": 48},
}

def cost_per_tflop(gpu_name, dph):
    specs = GPU_SPECS.get(gpu_name, {"fp16_tflops": 1})
    return dph / specs["fp16_tflops"]

# Often RTX 4090 is the best value for inference
# A100 is best for training large models needing >24GB VRAM
# H100 is best only when wall-clock time justifies 10x price premium

Step 2: Spot vs On-Demand Analysis

# Interruptible (spot) instances are 30-60% cheaper
vastai search offers 'num_gpus=1 gpu_name=RTX_4090 rentable=true' \
  --order dph_total --limit 5
# Compare interruptible vs on-demand pricing
# Use interruptible for: batch inference, checkpointed training
# Use on-demand for: final training epochs, production inference

Step 3: Auto-Destroy Safeguards

import time, subprocess, json

def auto_destroy_after(instance_id, max_hours=4):
    """Destroy instance after max_hours to prevent cost overruns."""
    max_seconds = max_hours * 3600
    time.sleep(max_seconds)
    subprocess.run(["vastai", "destroy", "instance", str(instance_id)], check=True)
    print(f"Instance {instance_id} auto-destroyed after {max_hours}h")

# Run in background thread when provisioning
import threading
watchdog = threading.Thread(target=auto_destroy_after, args=(inst_id, 4), daemon=True)
watchdog.start()

Step 4: Idle Instance Detection

#!/bin/bash
# Find and destroy idle instances (GPU util < 10% for >10 min)
vastai show instances --raw | python3 -c "
import sys, json
for inst in json.load(sys.stdin):
    if inst.get('actual_status') == 'running':
        gpu_util = inst.get('gpu_util', 0)
        if gpu_util < 10:
            print(f'IDLE: Instance {inst[\"id\"]} GPU util={gpu_util}% '
                  f'(\${inst.get(\"dph_total\", 0):.3f}/hr)')
"

Step 5: Cost Reporting

def daily_cost_report():
    """Calculate current daily burn rate from running instances."""
    result = subprocess.run(
        ["vastai", "show", "instances", "--raw"],
        capture_output=True, text=True)
    instances = json.loads(result.stdout)

    total_hourly = 0
    for inst in instances:
        if inst.get("actual_status") == "running":
            dph = inst.get("dph_total", 0)
            total_hourly += dph
            print(f"  {inst['id']}: {inst.get('gpu_name')} ${dph:.3f}/hr")

    print(f"\nTotal: ${total_hourly:.3f}/hr = ${total_hourly * 24:.2f}/day")

Cost Optimization Checklist

  • Always search with --order dph_total to find cheapest offers
  • Use interruptible instances for checkpointed workloads
  • Implement auto-destroy timeout on all instances
  • Monitor GPU utilization; destroy idle instances
  • Use RTX 4090 for workloads that fit in 24GB VRAM
  • Only use H100 when wall-clock time savings justify cost premium
  • Pre-install dependencies in Docker images (avoid paying for pip install)

Output

  • GPU cost-efficiency analysis by model
  • Spot vs on-demand comparison
  • Auto-destroy watchdog for cost protection
  • Idle instance detection script
  • Daily cost burn rate report

Error Handling

ErrorCauseSolution
Unexpected $50+ billForgot to destroy instancesImplement auto-destroy watchdog
GPU idle at $2/hrWaiting for data downloadPre-stage data before provisioning GPU
Spot preemption mid-jobCheapest instance reclaimedCheckpoint frequently; auto-recover

Resources

Next Steps

For reference architecture, see vastai-reference-architecture.

Examples

Budget cap: Set dph_total<=0.25 in search queries and auto_destroy_after(inst_id, 4) to cap any single job at $1.00.

GPU comparison: Run the same workload on RTX 4090 ($0.20/hr) vs A100 ($1.50/hr). If the A100 finishes in less than 1/7th the time, it's cheaper overall.

When not to use it

  • When wall-clock time savings do not justify a 10x price premium for H100 GPUs
  • When GPU idle at $2/hr is acceptable due to waiting for data download

Prerequisites

Vast.ai account with billing historyUnderstanding of your workload's GPU requirementsvastai CLI installed

Limitations

  • H100 GPUs are only cost-effective when wall-clock time justifies a 10x price premium
  • Pre-staging data is required to avoid idle GPU costs during data downloads

How it compares

This skill automates the selection and management of Vast.ai GPU instances based on cost and utilization, unlike manual provisioning that might overlook dynamic pricing and idle resource waste.

Compared to similar skills

vastai-cost-tuning side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
vastai-cost-tuning (this skill)127dReviewIntermediate
home-assistant-manager98moReviewAdvanced
observability-engineer124moNo flagsAdvanced
prometheus-configuration62moReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

home-assistant-manager

komal-SkyNET

Expert-level Home Assistant configuration management with efficient deployment workflows (git and rapid scp iteration), remote CLI access via SSH and hass-cli, automation verification protocols, log analysis, reload vs restart optimization, and comprehensive Lovelace dashboard management for tablet-optimized UIs. Includes template patterns, card types, debugging strategies, and real-world examples.

9110

observability-engineer

sickn33

Build production-ready monitoring, logging, and tracing systems. Implements comprehensive observability strategies, SLI/SLO management, and incident response workflows. Use PROACTIVELY for monitoring infrastructure, performance optimization, or production reliability.

1242

prometheus-configuration

wshobson

Set up Prometheus for comprehensive metric collection, storage, and monitoring of infrastructure and applications. Use when implementing metrics collection, setting up monitoring infrastructure, or configuring alerting systems.

645

mlops-engineer

sickn33

Build comprehensive ML pipelines, experiment tracking, and model registries with MLflow, Kubeflow, and modern MLOps tools. Implements automated training, deployment, and monitoring across cloud platforms. Use PROACTIVELY for ML infrastructure, experiment management, or pipeline automation.

333

network-info

UKGovernmentBEIS

Gather network configuration and connectivity information including interfaces, routes, and DNS

329

senior-devops

davila7

Comprehensive DevOps skill for CI/CD, infrastructure automation, containerization, and cloud platforms (AWS, GCP, Azure). Includes pipeline setup, infrastructure as code, deployment automation, and monitoring. Use when setting up pipelines, deploying applications, managing infrastructure, implementing monitoring, or optimizing deployment processes.

720

Search skills

Search the agent skills registry