100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Google Colab Cheat Sheet

Google Colab Cheat Sheet

A quick reference for running Python notebooks in Google Colab, covering GPU/TPU setup, mounting Drive, installing packages, and useful keyboard shortcuts.

1 PageBeginnerMar 20, 2026

GPU/TPU Setup

Enable and verify hardware acceleration.

python
# Check GPU availabilityimport torchprint(torch.cuda.is_available())!nvidia-smi# Runtime > Change runtime type > GPU/TPU (UI action)

Mounting Google Drive

Access files stored in your Drive from a notebook.

python
from google.colab import drivedrive.mount('/content/drive')# Access files directly from your Driveimport pandas as pddf = pd.read_csv('/content/drive/MyDrive/data.csv')

Installing Packages

Add libraries not preinstalled in the Colab runtime.

bash
!pip install -q transformers          # Install a package quietly!apt-get install -y graphviz          # Install a system package%pip install pandas==2.2.0            # Magic pip: installs into the active kernel

Magic Commands & Shortcuts

Notebook productivity commands and keybindings.

  • %%time- Measures and prints the execution time of a cell
  • %%writefile file.py- Writes the cell's contents to a file instead of executing it
  • %matplotlib inline- Renders matplotlib plots directly below the cell
  • Ctrl+M B / Ctrl+M A- Insert a new cell below / above the current one
  • Shift+Enter- Runs the current cell and moves focus to the next
  • Ctrl+M D D- Deletes the currently selected cell
Pro Tip

Colab disconnects idle runtimes after roughly 90 minutes and enforces a hard 12-hour session limit even if active — periodically checkpoint models and outputs to Google Drive so long training runs survive a disconnect.

Was this cheat sheet helpful?

Explore Topics

#GoogleColab#GoogleColabCheatSheet#DataScience#Beginner#GPUTPUSetup#MountingGoogleDrive#InstallingPackages#MagicCommandsShortcuts#MachineLearning#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet