# Lab 00 — Provider Setup & Cost Discipline (read before any GPU lab)

**Purpose:** Get accounts on the three GPU-rental providers, understand the free-tier-first strategy, and lock in the teardown habit so a forgotten instance never bills you overnight. Do this once; it unblocks every other lab.

---

## The three providers (and when to use each)

| Provider | Model | Best for | Rough cost |
|---|---|---|---|
| **Modal** (modal.com) | Serverless GPU, per-second billing, scale-to-zero | Cheapest entry; free monthly credits; bursty/experimental | Free credits, then per-second |
| **RunPod** (runpod.io) | Hourly GPU pods (Community + Secure Cloud) | Full-box work: MIG, Kubernetes, monitoring | ~$0.3-2/hr per GPU |
| **Vast.ai** (vast.ai) | Hourly GPU marketplace (cheapest spot) | Cheapest raw A100/H100 hours | ~$0.5-2/hr per GPU |

**Strategy — free-tier-first, then pay:**
1. **Start on Modal** for anything that fits serverless (Lab 01). Its free monthly credits cover a lot of experimentation at zero out-of-pocket. Verify the current free amount at modal.com/pricing.
2. **Use RunPod/Vast hourly boxes** for the labs that need a full machine with root: MIG (Lab 04), Kubernetes (Lab 06), monitoring (Lab 03), NIM/Triton (Lab 05), SGLang (Lab 02), and the vLLM core build.
3. **Budget:** a whole weekend of labs is roughly **$10-40** if you tear boxes down promptly. A single A100 is ~$1-2/hr; you only need it for the minutes you are actively running a lab.

---

## Account setup (do all three once)

1. **Modal:** sign up at modal.com, then `pip install modal` and `modal token new` (browser auth). Check the free-credit amount.
2. **RunPod:** sign up at runpod.io, add a small amount of credit ($10 is plenty to start), add your SSH public key in Settings so you can SSH into pods. For MIG you need **Secure Cloud / bare-metal** (Community Cloud containers often lack the privileges MIG needs).
3. **Vast.ai:** sign up at vast.ai, add credit, add your SSH key. Filter the marketplace for **CUDA 12.x** images with the NVIDIA Container Toolkit preinstalled, and for verified hosts.
4. **NVIDIA NGC** (for the NIM/Triton lab): sign up at ngc.nvidia.com, generate an API key (shown once — save it).
5. **Hugging Face** (optional): a token at huggingface.co lets you pull gated models (Llama). The labs default to **Qwen2.5**, which needs no token — skip this unless you specifically want a gated model.

---

## The golden rules (non-negotiable, this is real money)

1. **Pick the smallest GPU that fits the model.** A 7B model fits a 24GB card. You do not need an A100 80GB unless the lab specifically exercises MIG or tensor parallelism.
2. **Rent, run, tear down — same sitting.** Never leave a box up "to come back to." Do a lab start-to-finish, capture the artifact, destroy the box.
3. **STOP is not enough — DESTROY.** A stopped instance can still bill for storage. When you are done with a box for good, destroy/terminate it and confirm in the console that billing stopped.
4. **Verify the meter is off.** After teardown, check the provider console shows no running instances. This one habit prevents 100% of surprise bills.
5. **Capture the artifact before you tear down.** Screenshots of `nvidia-smi`, dashboards, and curl responses are the whole point — they are what make your resume claims interview-proof. Losing the box means re-renting to redo it.

---

## Quick sanity check on any fresh box

Before running a lab, confirm the GPU + Docker + NVIDIA runtime work:

```bash
nvidia-smi                                                   # GPU + driver visible
docker run --rm --gpus all nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smi   # --gpus all works
```

If the second command fails, the NVIDIA Container Toolkit is not wired into Docker — pick a different provider image rather than debugging it by hand on a rented box.

---

## What you'll be able to say in the interview

- "I run GPU work across serverless (Modal) and hourly full-box providers (RunPod, Vast), and I pick by workload: serverless scale-to-zero for bursty, a dedicated box for MIG/K8s/driver-level work."
- "I am disciplined about GPU cost — smallest GPU that fits, rent-run-teardown in one sitting, and I verify the meter is off, because idle GPUs are the fastest way to burn a budget."
