/vastai-pack:vastai-core-workflow-afrom vastai-pack
Provisions GPU instances on Vast.ai: search offers by price/specs, create instances, transfer data, execute training jobs, and teardown to stop billing.
Ships in vastai-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Primary workflow for Vast.ai: search for GPU offers, provision an instance, transfer data, execute a training or inference job, collect artifacts, and destroy the instance to stop billing. This is the money-path operation for every Vast.ai user.
vastai-install-auth setupimport subprocess, json
def search_offers(gpu_name="RTX_4090", min_vram=24, min_reliability=0.95,
max_price=0.50, num_gpus=1):
"""Search Vast.ai marketplace with specific filters."""
query = (
f"num_gpus={num_gpus} gpu_name={gpu_name} "
f"gpu_ram>={min_vram} reliability>{min_reliability} "
f"inet_down>200 dph_total<={max_price} rentable=true"
)
result = subprocess.run(
["vastai", "search", "offers", query, "--order", "dph_total", "--raw"],
capture_output=True, text=True, check=True,
)
offers = json.loads(result.stdout)
print(f"Found {len(offers)} offers matching criteria")
for o in offers[:5]:
print(f" ID {o['id']}: {o['gpu_name']} {o['gpu_ram']}GB "
f"${o['dph_total']:.3f}/hr reliability={o['reliability2']:.3f}")
return offers
def provision_instance(offer_id, image, disk_gb=50, onstart_cmd=""):
"""Create an instance from the best offer."""
cmd = [
"vastai", "create", "instance", str(offer_id),
"--image", image,
"--disk", str(disk_gb),
]
if onstart_cmd:
cmd.extend(["--onstart-cmd", onstart_cmd])
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
instance_info = json.loads(result.stdout)
instance_id = instance_info.get("new_contract")
print(f"Instance {instance_id} provisioning...")
return instance_id
import time
def wait_for_instance(instance_id, timeout=300):
"""Poll until instance status is 'running'."""
start = time.time()
while time.time() - start < timeout:
result = subprocess.run(
["vastai", "show", "instance", str(instance_id), "--raw"],
capture_output=True, text=True,
)
info = json.loads(result.stdout)
status = info.get("actual_status", "unknown")
print(f" Status: {status}")
if status == "running":
ssh_host = info.get("ssh_host")
ssh_port = info.get("ssh_port")
print(f" SSH: ssh -p {ssh_port} root@{ssh_host}")
return info
time.sleep(15)
raise TimeoutError(f"Instance {instance_id} did not start within {timeout}s")
# Upload training data to instance
scp -P $SSH_PORT ./data/training.tar.gz root@$SSH_HOST:/workspace/
# Execute training job remotely
ssh -p $SSH_PORT root@$SSH_HOST << 'REMOTE'
cd /workspace
tar xzf training.tar.gz
python train.py --epochs 10 --batch-size 32 --output /workspace/checkpoints/
REMOTE
def cleanup_instance(instance_id, ssh_host, ssh_port, output_dir="./results"):
"""Download results and destroy instance."""
import os
os.makedirs(output_dir, exist_ok=True)
# Download model checkpoints
subprocess.run([
"scp", "-P", str(ssh_port), "-r",
f"root@{ssh_host}:/workspace/checkpoints/",
output_dir,
], check=True)
print(f"Artifacts saved to {output_dir}")
# CRITICAL: Destroy instance to stop billing
subprocess.run(["vastai", "destroy", "instance", str(instance_id)], check=True)
print(f"Instance {instance_id} destroyed — billing stopped")
# End-to-end: search → provision → run → collect → destroy
offers = search_offers(gpu_name="RTX_4090", max_price=0.30)
if not offers:
raise RuntimeError("No offers available")
instance_id = provision_instance(
offer_id=offers[0]["id"],
image="pytorch/pytorch:2.2.0-cuda12.1-cudnn8-runtime",
disk_gb=50,
onstart_cmd="pip install transformers datasets",
)
info = wait_for_instance(instance_id)
# ... transfer data, run job, collect results ...
cleanup_instance(instance_id, info["ssh_host"], info["ssh_port"])
| Error | Cause | Solution |
|---|---|---|
| No offers match filters | GPU type or price too restrictive | Relax dph_total or try different gpu_name |
Instance stuck in loading | Docker image is very large | Use a smaller base image or pre-cached template |
| SSH timeout after creation | Firewall or key mismatch | Verify SSH key is uploaded at cloud.vast.ai |
| Job OOM killed | Insufficient GPU VRAM | Reduce batch size or search for more VRAM |
| Instance preempted (spot) | Host reclaimed interruptible instance | Use on-demand or implement checkpoint recovery |
For multi-instance orchestration and cost optimization, see vastai-core-workflow-b.
Fine-tune LLM: Search for A100 80GB offers, provision with the huggingface/transformers image, upload a LoRA config, run fine-tuning for 3 epochs, download the adapter weights, destroy the instance.
Batch inference: Provision 4 cheap RTX 4090 instances in parallel, distribute an inference dataset across them, collect results, and destroy all instances in a loop.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
vast-ai, gpu-provisioning, instance-lifecycle, training-jobs
24 skills in this plugin
/vastai-ci-integrationConfigure Vast.ai CI/CD integration with GitHub Actions and automated GPU testing.
Use when setting up automated testing on GPU instances,
or integrating Vast.ai provisioning into CI/CD pipelines.
Trigger with phrases like "vastai CI", "vastai github actions",
"vastai automated testing", "vastai pipeline".
/vastai-common-errorsDiagnose and fix Vast.ai common errors and exceptions.
Use when encountering Vast.ai errors, debugging failed instances,
or troubleshooting GPU rental issues.
Trigger with phrases like "vastai error", "fix vastai",
"vastai not working", "debug vastai", "vastai instance failed".
/vastai-core-workflow-bExecute Vast.ai secondary workflow: multi-instance orchestration, spot recovery, and cost optimization.
Use when running distributed training, handling spot preemption,
or optimizing GPU spend across multiple instances.
Trigger with phrases like "vastai distributed training", "vastai spot recovery",
"vastai multi-gpu", "vastai cost optimization".
/vastai-cost-tuningOptimize Vast.ai GPU cloud costs through smart instance selection and lifecycle management.
Use when analyzing GPU spending, reducing training costs,
or implementing budget controls for Vast.ai workloads.
Trigger with phrases like "vastai cost", "vastai billing",
"reduce vastai costs", "vastai pricing", "vastai budget".
/vastai-data-handlingManage training data and model artifacts securely on Vast.ai GPU instances.
Use when transferring data to instances, managing checkpoints,
or implementing secure data lifecycle on rented hardware.
Trigger with phrases like "vastai data", "vastai upload data",
"vastai checkpoints", "vastai data security", "vastai artifacts".
/vastai-debug-bundleCollect Vast.ai debug evidence for support tickets and troubleshooting.
Use when encountering persistent issues, preparing support tickets,
or collecting diagnostic information for Vast.ai problems.
Trigger with phrases like "vastai debug", "vastai support bundle",
"collect vastai logs", "vastai diagnostic".
npx claudepluginhub flight505/skill-forge --plugin vastai-packOther plugins' skills for the same job