Title: Lab 3 — CPU vs. GPU Speed Test in Google Colab
Course: AIINFRA 100: AI Systems & Development Environments > Section: Week 03 — Computational Resources: CPUs, GPUs, TPUs, and VRAM

🛠️ Lab 3 — CPU vs. GPU Speed Test in Google Colab (50 pts)

Goal: Get hands-on evidence of the CPU-vs-GPU speed difference by running the same small task twice in Google Colab — once on a CPU and once on a free T4 GPU — and by reading a real GPU's specs off a live dashboard. Steps:

1. Go to Google Colab and sign in with any free Google account. Create a new notebook (File \> New notebook).
2. Set your first runtime to CPU only: click Runtime \> Change runtime type, choose CPU as the hardware accelerator, and save.
3. In a code cell, write a small PyTorch (or NumPy, if you haven't installed PyTorch) script that multiplies two large matrices together — for example, two 5000x5000 matrices of random numbers — and use Python's time module to record how long the multiplication takes. (If you'd rather use the MNIST logistic regression idea instead of matrix multiplication, that works too — just make sure it's a task that runs multiple times so you can time it consistently.)
4. Run the cell 2–3 times and record the average time. Write this number down — this is your CPU time.
5. Now switch runtimes: go to Runtime \> Change runtime type again, choose T4 GPU, and save. Colab will restart your session.
6. Re-run the exact same code (making sure any tensors are explicitly moved to the GPU, e.g. .to("cuda") in PyTorch, so it's a fair test). Time it the same way, 2–3 runs, and record the average. This is your GPU time.
7. Calculate your speedup: CPU time ÷ GPU time. Write one paragraph explaining, in your own words, why the GPU was faster (or, if it wasn't, why it might not have been — small tasks sometimes don't show a GPU advantage because of data-transfer overhead).
8. In the same GPU-enabled notebook, run !nvidia-smi in a new code cell. Take a screenshot of the output and identify three things from it: the GPU model name, the driver version, and how much VRAM is being used versus the total VRAM available.
9. Write a short paragraph connecting what you saw in nvidia-smi back to this week's lecture: how does the VRAM number you observed relate to the "2 GB of VRAM per billion parameters" rule of thumb for inference?

Deliverables: Submit your Colab notebook (shared link or downloaded .ipynb) showing both timed runs, your nvidia-smi screenshot, and your two short written paragraphs (speedup explanation + VRAM connection), either pasted as text or included in the notebook itself.