From 055d0722df17b8baf6a75a65bd2ac0f8793b3837 Mon Sep 17 00:00:00 2001 From: mehfuz Date: Mon, 16 Nov 2026 11:34:35 -0800 Subject: [PATCH] List H100 as a premium plan; show plans as a table with availability - h100 (a3-highgpu-1g, 1x H100 80 GB): priced and listed, but not creatable until GCP grants on-demand H100 quota (it's 0; only Spot quota exists). - Plans at $10/hour or more are premium and need $100 in the balance to create or start a box; cheaper plans still need an hour of use. - /plans returns status, premium, min_balance_usd and regions per plan; gpushed plans prints them as a table. - Install python3-venv so python3 -m venv works on the system Python too. --- README.md | 6 ++++- api/scripts/gcp-prices.mjs | 1 + api/scripts/gcp-zones.mjs | 1 + api/src/index.ts | 34 +++++++++++++++++++------- api/src/pricing.ts | 33 +++++++++++++++++++++++++ api/src/regions.generated.ts | 17 ++++++++----- api/src/zones.generated.ts | 22 ++++++++++++++++- api/test/pricing.test.ts | 17 ++++++++++++- client/gpushed-cli | 22 ++++++++++++++--- provisioner/terraform/scripts/setup.sh | 3 ++- 10 files changed, 134 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index e0341c6..21f25dd 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,9 @@ gpushed plans | `t4` | 1x Tesla T4 16 GB | n1-standard-8 | $0.91 | | `l4` (default) | 1x L4 24 GB | g2-standard-4 | $0.88 | | `a100` | 1x A100 40 GB | a2-highgpu-1g | $4.44 | +| `h100` (coming soon) | 1x H100 80 GB | a3-highgpu-1g | $13.21 | + +`h100` is listed but can't be created yet: it's waiting on GCP H100 quota. Prices are GCP's on-demand cost of the machine, its 100 GB SSD and IP, plus 20%. A box is billed per second from when it's created until it's deleted. A @@ -64,7 +67,8 @@ for your region, `gpushed plans --region asia-southeast1` for another, and **Balance.** Credit is prepaid: the minimum top-up is $10, and you can top up any amount above that at any time with `gpushed topup 25`. To create or start a -box you need at least one hour of its price in your balance. +box you need at least one hour of its price in your balance. Premium plans, +those at $10/hour or more (`h100`), need $100. **Running out.** When your balance falls below $2 you get an email. When it's nearly used up, your box is **stopped** (its disk is kept) and you get another diff --git a/api/scripts/gcp-prices.mjs b/api/scripts/gcp-prices.mjs index 03db639..61c3300 100644 --- a/api/scripts/gcp-prices.mjs +++ b/api/scripts/gcp-prices.mjs @@ -20,6 +20,7 @@ const PLANS = { l4: { family: "G2 Instance", vcpu: 4, ramGb: 16, gpu: "Nvidia L4 GPU" }, a100: { family: "A2 Instance", vcpu: 12, ramGb: 85, gpu: "Nvidia Tesla A100 GPU" }, "a100-80": { family: "A2 Instance", vcpu: 12, ramGb: 170, gpu: "Nvidia Tesla A100 80GB GPU" }, + h100: { family: "A3 Instance", vcpu: 26, ramGb: 234, gpu: "Nvidia H100 80GB GPU" }, }; const COMPUTE = "6F81-5844-456A"; // Compute Engine's service id in the catalog diff --git a/api/scripts/gcp-zones.mjs b/api/scripts/gcp-zones.mjs index 9045eb2..8df163f 100644 --- a/api/scripts/gcp-zones.mjs +++ b/api/scripts/gcp-zones.mjs @@ -23,6 +23,7 @@ const PLANS = { l4: { machineType: "g2-standard-4", gpuType: "" }, a100: { machineType: "a2-highgpu-1g", gpuType: "" }, "a100-80": { machineType: "a2-ultragpu-1g", gpuType: "" }, + h100: { machineType: "a3-highgpu-1g", gpuType: "" }, }; const project = process.argv[2]; diff --git a/api/src/index.ts b/api/src/index.ts index 20e1dc1..0f6f639 100644 --- a/api/src/index.ts +++ b/api/src/index.ts @@ -1,7 +1,7 @@ import { type Box, type User, credit, getBox, meterBox, runMetering, updateBox, welcomeOnFirstTopup } from "./billing"; import { type Env, numVar } from "./env"; import { type ProvisionAction, dispatchProvision } from "./external"; -import { DEFAULT_PLAN, PLANS, planPrice } from "./pricing"; +import { DEFAULT_PLAN, PLANS, isPremium, planPrice, requiredBalanceMicros } from "./pricing"; import { REGIONS, byDistance, enabledRegions, regionOfZone, requestLocation } from "./regions"; import { PLAN_ZONES } from "./zones.generated"; import { type CheckoutSession, createCheckoutSession, topupCents, verifyStripeSignature } from "./stripe"; @@ -280,6 +280,9 @@ route("GET", "/plans", async (req, env) => { plans: Object.values(PLANS).flatMap((p) => { const price = planPrice(p, region.id, premium); if (!price) return []; + // Enabled regions with a price and at least one zone offering the machine. + const where = enabledRegions(env.REGIONS, p.id).filter((r) => (PLAN_ZONES[p.id]?.[r.id] ?? []).length > 0); + const offered = where.some((r) => r.id === region.id); return [ { id: p.id, @@ -287,6 +290,12 @@ route("GET", "/plans", async (req, env) => { machine_type: p.machineType, hourly_usd: usd(price.hourlyMicros), stopped_hourly_usd: usd(price.stoppedHourlyMicros), + premium: isPremium(price.hourlyMicros), + min_balance_usd: usd(requiredBalanceMicros(price.hourlyMicros)), + // available: can be created now; unavailable: not offered yet (no GCP + // quota); elsewhere: offered, but not in this region. + status: !p.available || where.length === 0 ? "unavailable" : offered ? "available" : "elsewhere", + regions: p.available ? where.map((r) => r.id) : [], }, ]; }), @@ -393,11 +402,19 @@ route("POST", "/stripe/webhook", async (req, env) => { // ---------------------------------------------------------------- boxes +function balanceShortMessage(balanceMicros: number, planId: string, hourlyMicros: number, neededMicros: number): string { + const why = isPremium(hourlyMicros) + ? `the $${usd(neededMicros)} minimum for ${planId}, a premium plan ($${usd(hourlyMicros)}/h)` + : `one hour of ${planId} ($${usd(neededMicros)})`; + return `balance $${usd(balanceMicros)} is less than ${why}; run gpushed topup`; +} + route("POST", "/box", async (req, env) => { const user = await authUser(req, env); const body = await readJson<{ plan?: string; ssh_public_key?: string; region?: string }>(req); const plan = PLANS[body.plan ?? DEFAULT_PLAN]; if (!plan) throw new HttpError(400, `unknown plan; choose one of: ${Object.keys(PLANS).join(", ")}`); + if (!plan.available) throw new HttpError(503, `${plan.id} isn't available yet; see gpushed plans`); // Drop the key's comment: it ends up in GCE metadata as "user:type key". const key = String(body.ssh_public_key ?? "").trim().split(/\s+/).slice(0, 2).join(" "); if (!SSH_KEY_RE.test(key) || key.length > 4096) throw new HttpError(400, "invalid SSH public key"); @@ -417,14 +434,12 @@ route("POST", "/box", async (req, env) => { } if (candidates.length === 0) throw new HttpError(503, `${plan.id} isn't available right now`); const premium = numVar(env.PREMIUM_PCT, 20); - // At least an hour at the price shown for the first region (what plans shows). + // At least an hour at the price shown for the first region (what plans + // shows), or $100 for a premium plan. const price = planPrice(plan, candidates[0].id, premium)!; - const needed = price.hourlyMicros; + const needed = requiredBalanceMicros(price.hourlyMicros); if (user.balance_micros < needed) { - throw new HttpError( - 402, - `balance $${usd(user.balance_micros)} is less than one hour of ${plan.id} ($${usd(needed)}); run gpushed topup`, - ); + throw new HttpError(402, balanceShortMessage(user.balance_micros, plan.id, price.hourlyMicros, needed)); } const now = nowSec(); const box: Box = { @@ -479,8 +494,9 @@ route("POST", "/box/start", async (req, env) => { const box = await activeBox(env, user.id); if (!box) throw new HttpError(404, "you have no box"); if (box.status !== "stopped") throw new HttpError(409, `box is ${box.status}; only a stopped box can be started`); - if (user.balance_micros < box.hourly_micros) { - throw new HttpError(402, `balance $${usd(user.balance_micros)} is less than one hour of use; run gpushed topup`); + const needed = requiredBalanceMicros(box.hourly_micros); + if (user.balance_micros < needed) { + throw new HttpError(402, balanceShortMessage(user.balance_micros, box.plan, box.hourly_micros, needed)); } const now = nowSec(); const updated = await updateBox(env, box, { status: "starting" }, now); diff --git a/api/src/pricing.ts b/api/src/pricing.ts index 30bcfd9..8fd23c1 100644 --- a/api/src/pricing.ts +++ b/api/src/pricing.ts @@ -12,6 +12,9 @@ export interface Plan { machineType: string; gpuType: string; // "" when the machine type has the GPU built in (A2, G2) gpuCount: number; + // False while GCP hasn't granted us quota for it: listed in `gpushed plans` + // with its price, but a box can't be created on it yet. + available: boolean; } // The machine each plan runs on. scripts/gcp-prices.mjs has the same plans @@ -23,6 +26,7 @@ export const PLANS: Record = { machineType: "n1-standard-8", gpuType: "nvidia-tesla-t4", gpuCount: 1, + available: true, }, l4: { id: "l4", @@ -30,6 +34,7 @@ export const PLANS: Record = { machineType: "g2-standard-4", gpuType: "", gpuCount: 0, + available: true, }, a100: { id: "a100", @@ -37,6 +42,18 @@ export const PLANS: Record = { machineType: "a2-highgpu-1g", gpuType: "", gpuCount: 0, + available: true, + }, + // GCP's on-demand H100 quota (GPUS_PER_GPU_FAMILY, NVIDIA_H100) is 0 in our + // project; flip `available` once it's granted. Spot quota doesn't count: + // boxes run on-demand. + h100: { + id: "h100", + label: "1x NVIDIA H100 80 GB, 26 vCPU, 234 GB RAM", + machineType: "a3-highgpu-1g", + gpuType: "", + gpuCount: 0, + available: false, }, }; @@ -49,6 +66,7 @@ export const PLANS: Record = { // machineType: "a2-ultragpu-1g", // gpuType: "", // gpuCount: 0, +// available: true, // }, export const DEFAULT_PLAN = "l4"; @@ -84,6 +102,21 @@ export function planPrice(plan: Plan, region: string, premiumPct: number) { }; } +// Premium plans (H100 today) cost $10/hour or more, and need $100 in the +// balance to create or start a box, so a box isn't stopped for lack of credit +// a few minutes in. Every other plan needs an hour of use. +export const PREMIUM_HOURLY_USD = 10; +export const PREMIUM_MIN_BALANCE_USD = 100; + +export function isPremium(hourlyMicros: number): boolean { + return hourlyMicros >= PREMIUM_HOURLY_USD * 1e6; +} + +// Balance, in micro-dollars, needed to create or start a box at this rate. +export function requiredBalanceMicros(hourlyMicros: number): number { + return isPremium(hourlyMicros) ? Math.max(hourlyMicros, PREMIUM_MIN_BALANCE_USD * 1e6) : hourlyMicros; +} + // Charge for `seconds` at an hourly rate, rounded down to the micro-dollar. export function chargeMicros(hourlyMicros: number, seconds: number): number { if (seconds <= 0 || hourlyMicros <= 0) return 0; diff --git a/api/src/regions.generated.ts b/api/src/regions.generated.ts index 8edf366..0b7725d 100644 --- a/api/src/regions.generated.ts +++ b/api/src/regions.generated.ts @@ -1,4 +1,4 @@ -// Generated by scripts/gcp-prices.mjs from the Cloud Billing Catalog on 2026-11-14. +// Generated by scripts/gcp-prices.mjs from the Cloud Billing Catalog on 2026-11-16. // Do not edit by hand. GCP on-demand list prices in USD: plans are per hour // (cores + RAM + GPU), ssdGbMonth is pd-ssd per GB-month. @@ -8,7 +8,8 @@ export const REGION_PRICES: Record; ssdG "t4": 0.729998, "l4": 0.706832, "a100": 3.673385, - "a100-80": 5.027702 + "a100-80": 5.027702, + "h100": 10.979058 }, "ssdGbMonth": 0.17 }, @@ -17,7 +18,8 @@ export const REGION_PRICES: Record; ssdG "t4": 0.729998, "l4": 0.706832, "a100": 3.673385, - "a100-80": 5.027702 + "a100-80": 5.027702, + "h100": 10.979058 }, "ssdGbMonth": 0.17 }, @@ -26,7 +28,8 @@ export const REGION_PRICES: Record; ssdG "t4": 0.729998, "l4": 0.706832, "a100": 3.673385, - "a100-80": 5.027702 + "a100-80": 5.027702, + "h100": 10.979058 }, "ssdGbMonth": 0.17 }, @@ -35,7 +38,8 @@ export const REGION_PRICES: Record; ssdG "t4": 0.768336, "l4": 0.742916, "a100": 3.747972, - "a100-80": 5.535713 + "a100-80": 5.535713, + "h100": 13.977149 }, "ssdGbMonth": 0.187 }, @@ -44,7 +48,8 @@ export const REGION_PRICES: Record; ssdG "t4": 0.838772, "l4": 0.872019, "a100": 4.013758, - "a100-80": 6.20248 + "a100-80": 6.20248, + "h100": 14.194376 }, "ssdGbMonth": 0.187 } diff --git a/api/src/zones.generated.ts b/api/src/zones.generated.ts index cc9ac1c..2efa4e6 100644 --- a/api/src/zones.generated.ts +++ b/api/src/zones.generated.ts @@ -1,4 +1,4 @@ -// Generated by scripts/gcp-zones.mjs on 2026-11-14. Do not edit by hand. +// Generated by scripts/gcp-zones.mjs on 2026-11-16. Do not edit by hand. // Zones in each region offering each plan's machine type (and GPU). export const PLAN_ZONES: Record> = { @@ -93,5 +93,25 @@ export const PLAN_ZONES: Record> = { "asia-southeast1": [ "asia-southeast1-c" ] + }, + "h100": { + "us-central1": [ + "us-central1-a", + "us-central1-b", + "us-central1-c" + ], + "us-east1": [], + "us-west1": [ + "us-west1-a", + "us-west1-b" + ], + "europe-west4": [ + "europe-west4-b", + "europe-west4-c" + ], + "asia-southeast1": [ + "asia-southeast1-b", + "asia-southeast1-c" + ] } }; diff --git a/api/test/pricing.test.ts b/api/test/pricing.test.ts index a42cd54..9118674 100644 --- a/api/test/pricing.test.ts +++ b/api/test/pricing.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; import { meterRate } from "../src/billing"; -import { IP_HOURLY_USD, PLANS, chargeMicros, diskHourlyUsd, gcpHourlyUsd, planPrice, withPremium } from "../src/pricing"; +import { IP_HOURLY_USD, PLANS, chargeMicros, diskHourlyUsd, gcpHourlyUsd, isPremium, planPrice, requiredBalanceMicros, withPremium } from "../src/pricing"; import { REGIONS, byDistance, enabledRegions, regionOfZone } from "../src/regions"; describe("pricing", () => { @@ -36,6 +36,21 @@ describe("pricing", () => { expect(chargeMicros(1_000_000, -5)).toBe(0); }); + it("makes plans of $10/h or more premium, needing $100 to create", () => { + const h100 = planPrice(PLANS.h100, "us-central1", 20)!.hourlyMicros; + const a100 = planPrice(PLANS.a100, "us-central1", 20)!.hourlyMicros; + expect(isPremium(h100)).toBe(true); + expect(isPremium(a100)).toBe(false); + expect(requiredBalanceMicros(h100)).toBe(100_000_000); + expect(requiredBalanceMicros(a100)).toBe(a100); // just an hour of use + expect(requiredBalanceMicros(150_000_000)).toBe(150_000_000); // never less than an hour + }); + + it("lists H100 but doesn't offer it until GCP grants quota", () => { + expect(PLANS.h100.available).toBe(false); + expect(Object.values(PLANS).filter((p) => p.id !== "h100").every((p) => p.available)).toBe(true); + }); + it("$10 buys about two hours of A100", () => { const hours = 10e6 / planPrice(PLANS.a100, "us-central1", 20)!.hourlyMicros; expect(hours).toBeGreaterThan(2); diff --git a/client/gpushed-cli b/client/gpushed-cli index 0e5bf7a..5f6e1ad 100755 --- a/client/gpushed-cli +++ b/client/gpushed-cli @@ -343,10 +343,26 @@ case "$cmd" in region="" if [ "${1:-}" = --region ]; then region="${2:-}"; [ -n "$region" ] || die "Usage: gpushed plans [--region REGION]"; fi NO_AUTH=1 api GET "/plans${region:+?region=$region}" - jq -r '"Prices in \(.region_name) (\(.region))\(if .nearest then ", the region nearest you" else "" end). Default plan: \(.default)\n", - (.plans[] | " \(.id | . + " " | .[0:8]) $\(.hourly_usd)/h \(.label)"), - "\nRegions: \([.regions[] | .id] | join(", "))"' <<<"$API_BODY" + jq -r '"Prices in \(.region_name) (\(.region))\(if .nearest then ", the region nearest you" else "" end). Default plan: \(.default)\n"' <<<"$API_BODY" + # One row per plan: id, GPU and machine, price, stopped price, minimum + # balance, status. Older APIs send no status: treat the plan as available. + jq -r '.plans[] | [ + .id, + (.label | split(", ")[0] | sub("^1x NVIDIA "; "")), + "$\(.hourly_usd)", + "$\(.stopped_hourly_usd)", + "$\(.min_balance_usd // .hourly_usd)", + ((.status // "available") as $s + | if $s == "unavailable" then "coming soon (no GPU quota yet)" + elif $s == "elsewhere" then "not here; in \(.regions | join(", "))" + else "available" end + + (if .premium then ", premium" else "" end)) + ] | @tsv' <<<"$API_BODY" | + awk -F'\t' 'BEGIN { printf " %-8s %-18s %9s %9s %11s %s\n", "PLAN", "GPU", "PER HOUR", "STOPPED", "MIN BALANCE", "STATUS" } + { printf " %-8s %-18s %9s %9s %11s %s\n", $1, $2, $3, $4, $5, $6 }' + jq -r '"\nRegions: \([.regions[] | .id] | join(", "))"' <<<"$API_BODY" say "Prices include disk and IP, and differ a little by region. A stopped box costs only its disk." + say "Min balance is what you need to create or start a box: an hour of use, or \$100 for premium plans (\$10/h or more)." say "Your box goes to the nearest region with free GPUs; pick one with: gpushed up [plan] --region REGION" ;; diff --git a/provisioner/terraform/scripts/setup.sh b/provisioner/terraform/scripts/setup.sh index 99b7c65..299b42a 100755 --- a/provisioner/terraform/scripts/setup.sh +++ b/provisioner/terraform/scripts/setup.sh @@ -129,7 +129,8 @@ apt_install build-essential git git-lfs cmake ninja-build pkg-config \ echo "Installing Python 3.11..." add-apt-repository -y ppa:deadsnakes/ppa apt_retry update -y -apt_install python3.11 python3.11-venv python3.11-dev +# python3-venv too, so `python3 -m venv` (system 3.10) works as well as `python -m venv`. +apt_install python3.11 python3.11-venv python3.11-dev python3-venv python3.11 -m ensurepip --upgrade python3.11 -m pip install --no-cache-dir --upgrade pip update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1