页面简介
正文摘录
Most readers run the notebooks of this book on a laptop, a desktop GPU, or a hosted service such as Colab (Section 27.2). Sooner or later a project outgrows all three: preprocessing runs longer than a hosted session lasts, a model needs 80 GB of accelerator memory, or an experiment needs several GPUs at once. The usual answer is to rent a machine by the hour, which raises two questions. Which machine should we rent, and what will a finished result cost? And how do we work on a machine that can disappear at any moment? Prices change monthly, so the numbers below are dated examples, not a catalog. Two ideas outlast them. A machine is chosen by its cost per completed result rather than its hourly price, and a rented instance is treated as disposable, with everything that matters copied to durable storage before the instance is deleted. The book’s own notebooks need modest hardware: they are executed on 24 GB RTX 4090 cards and most use less than 8 GB, so a 24 GB rental runs every single-GPU notebook. Only the multi-GPU sections of Chapter 13 need more than one card. 27.3.1 The Rental Market 27.3.1.1 Three Tiers of Provider GPU rental is sold by three kinds of company, which differ less in the hardware than in what surrounds it and who operates it (Figure 27.3.1). Figure 27.3.1: Cloud options trade managed integration and governance for price dispersion and operational responsibility. Hyperscalers such as AWS, Google Cloud and Microsoft Azure sell GPUs inside a full cloud: identity management, virtual networks, managed storage, and every adjacent service. Their on-demand GPU prices are the highest, and the largest instances often require a quota request or sales contact. They suit work whose data already lives in that cloud, work under compliance requirements, and training that is part of a larger managed system. Google also rents TPUs, which run the JAX code of this book; a v5e chip costs $1.20 per hour as of November 2026. GPU specialists such as Lambda, Nebius, Voltage Park and CoreWeave rent accelerators with fast interconnect and machine-learning images, and little else. As of November 2026 an H100 costs about $2–6 per GPU-hour in this tier, and Lambda, Nebius and Voltage Park let a new account launch one without contacting sales. This tier suits substantial training runs that do not need a hyperscaler’s other services. Marketplaces such as Vast.ai and RunPod aggregate machines from many independent operators, including consumer GPUs that the large clouds do not carry. They list the lowest hourly prices: as of November 2026 an RTX 4090 for $0.30–0.50 per hour and an H100 from about $1.80. Quality varies with the listing. Host reliability, disk speed and network quality differ from host to host, and the code runs on a stranger’s machine. That is fine for coursework and public data, and inappropriate for anything sensitive unless the job runs on a vetted datacenter tier such as RunPod’s Secure Cloud. 27.3.1.2 A Dated Price Snapshot Prices vary by region, availability, commitment and host. Table 27.3.1 illustrates the spread between tiers; check current quotes before buying. Table 27.3.1: GPU rental snapshot, on-demand, per GPU (November 2026) Provider (tier) Cheap GPU option ≈ $/hr 1× H100 80 GB ≈ $/hr Vast.ai (marketplace) RTX 4090 24 GB 0.30–0.50 1.80–2.40 RunPod (marketplace) RTX 4090 24 GB 0.34–0.89 1.99–3.99 Lambda (specialist) A100 40 GB 1.99 3.29–4.29 Nebius (specialist) RTX PRO 6000 96 GB 1.80 4.50 Voltage Park (specialist) H100 80 GB (only listed price) 1.99 1.99 AWS (hyperscaler) L4 24 GB (g6.xlarge) 0.80 6.88 (p5) Azure (hyperscaler) T4 16 GB (NC4as T4 v3) 0.53 6.98 (NC40ads H100 v5, 94 GB) Google Cloud (hyperscaler) L4 24 GB (g2-standard-4) 0.71 ≈ 11 (8-GPU A3) RunPod’s ranges run from community hosts to its datacenter tier. Azure’s single-GPU H100 instance carries the 94 GB H100 NVL. Google Cloud sells the H100 on demand only as an 8-GPU machine, quoted per GPU. Two qualifications matter. First, multi-GPU nodes are priced roughly linearly per GPU, but the interconnect is not: an 8×H100 machine with NVLink is a different tool from eight PCIe cards, and communication-heavy training (Section 27.6) shows the difference. Second, newer is not always cheaper per unit of work. B200 instances cost about $7–14 per GPU-hour as of November 2026, and they pay off only when a job uses their larger memory and FP8/FP4 throughput. 27.3.1.3 Cost per Completed Result The hourly price is the most visible term of a larger sum that also includes setup time, idle time while you debug, storage that keeps billing after the run, data egress, and engineering time. A faster, more expensive GPU can therefore reduce the cost of a completed experiment. The model below asks which of three marketplace GPUs completes a job most cheaply when the job takes eight hours on the slowest. Rerun it with your own assumptions: import numpy as np gpu = ["RTX 4090", "A100 80GB", "H100"] gpu_per_hour = np.array([0.40, 1.20, 2.50]) # marketplace, November 2026 relative_speed = np.array([1.0, 1.6, 3.0]) # measure for your workload! setup_hours = np.array([0.5, 0.5, 0.5]) storage_and_egress = np.array([2.0, 2.0, 2.0]) engineer_per_hour = 60.0 wall_hours = 8.0 / relative_speed invoice = (wall_hours + setup_hours) * gpu_per_hour + storage_and_egress complete = invoice + setup_hours * engineer_per_hour for row in zip(gpu, np.round(wall_hours, 1), np.round(invoice, 2), np.round(complete, 2)): print(row) ('RTX 4090', np.float64(8.0), np.float64(5.4), np.float64(35.4)) ('A100 80GB', np.float64(5.0), np.float64(8.6), np.float64(38.6)) ('H100', np.float64(2.7), np.float64(9.92), np.float64(39.92)) The invoices come to $5.40, $8.60 and $9.92, so the invoice favors the inexpensive card. Half an hour of the engineer’s time brings the totals to $35.40, $38.60 and $39.92, much closer but in the same order. If the slow card needs one more half-hour debugging round than the fast one, its total rises above $65 and the order reverses, so the number of rounds belongs in the cost model as much as the hourly price. The size of the workload matters more still: a LoRA fine-tune of a 7B model may take hours on one consumer GPU, whereas pretraining a small language model can take thousands of GPU-hours. Estimate the workload before comparing small differences in hourly price. Two costs are easy to overlook: Spot and interruptible capacity is often discounted by half or more and suits jobs that checkpoint and resume cleanly (Section 27.6), not interactive sessions or uncheckpointed runs. AWS warns two minutes ahead, Google Cloud by default allows a shutdown period of at most 30 seconds, and a Vast.ai interruptible instance stops, killing its processes, as soon as it is outbid. Test recovery before the long run, not during it. Egress fees. As of November 2026 AWS and Azure charge about $0.09 per GB for data sent to the internet beyond the first 100 GB a month. Downloading a 140 GB checkpoint daily for a month costs about $370, more than running a marketplace RTX 4090 around the clock (720 hours at $0.44, about $320). Keep data and compute in the same region, and prefer providers that do not charge for egress, RunPod among them, when a workflow moves large artifacts around. 27.3.2 Working on a Rented Machine 27.3.2.1 Instance Setup and Checks A new instance is an unknown machine, and the first minutes on it decide whether a long run can be trusted. Start from the provider’s current deep-learning image, with drivers, CUDA and the container runtime preinstalled; a bare OS image needs setup that must also be reproduced later. Connect with the SSH tunnel of Section 27.1, which works the same way on every provider, or with VS Code Remote SSH. Run long jobs under tmux so that an SSH disconnect does not kill training, and check the machine first: nvidia-smi # driver ok? expected GPU? memory free? df -h # scratch disk has room for data + checkpoints? python -c "import torch; print(torch.cuda.get_device_name(0))" A short smoke test, one batch through the model and one checkpoint written and read back, detects problems that the provider’s health indicators miss: broken drivers, full disks, read-only mounts, and datasets that stream too slowly to keep the GPU busy. 27.3.2.2 Disposable Instances, Durable Results A rented instance can be preempted, crash, or be deleted by mistake, and the work on it must survive all three. Figure 27.3.2: Provision compute, connect securely, checkpoint to durable storage, and delete the VM; resume from that storage on a replacement machine. The workflow in Figure 27.3.2 separates the lifetime of the machine from the lifetime of the work. Code is stored in Git and cloned onto the instance. Data and checkpoints are copied to durable object storage (S3, GCS, or the provider’s volume product) on a schedule the job controls. Losing the instance then costs at most the work since the last checkpoint, and a replacement machine resumes from storage. When the experiment ends, delete everything that bills: the instance, its disks and snapshots, reserved IP addresses, and stale buckets. Set a billing alert on the first day. An idle GPU bills at the same rate as a busy one. Alerts lag behind usage, so the account’s GPU quota is what bounds the loss from a leaked credential. We can now choose a rented machine by the cost of a completed result and keep the work safe when the machine fails. A GPU that is busy on most days of the year eventually costs more to rent than to buy, and Section 27.4 asks which hardware to buy. 27.3.3 Summary Most of the book’s notebooks require less than 8 GB of GPU memory and every single-GPU notebook fits on a 24 GB card, so substantial rental bills arise primarily at language-model scale. The cloud GPU market spans hyperscalers, GPU specialists, and marketplaces, offering a several-fold price spread for identical silicon alongside very different levels of managed integration, reliability, and operational trust. Always compare machines by t