Skip to content

Google Colab — Introduction

Google Colaboratory (Colab) is a free, cloud-hosted Jupyter notebook environment provided by Google. It requires no setup, runs entirely in the browser, and provides free access to GPUs and TPUs — making it the most popular platform for ML experimentation and learning.

Key facts:

  • Built on Jupyter Notebook (.ipynb compatible)
  • Runs on Google’s infrastructure
  • Free tier includes GPU/TPU access
  • Notebooks stored in Google Drive
  • Collaborative editing (like Google Docs)
FeatureGoogle ColabLocal Jupyter
SetupNoneInstall Python + packages
GPU/TPUFree (with limits)Requires hardware
StorageGoogle DriveLocal disk
RAM12–52 GB (tier dependent)Your machine’s RAM
Session timeout12h (free), longer (paid)No timeout
CollaborationReal-timeManual sharing
Internet accessYesYes
Custom packagesYes (per session)Persistent
CostFree / Pro / Pro+Free (hardware cost)
TierGPURAMSession LengthPrice
FreeT4 (shared, limited)~12 GB12h maxFree
Colab ProT4/V100 (priority)~25 GB24h~$10/mo
Colab Pro+A100/V100 (priority)~52 GB24h+ background~$50/mo
  1. Go to colab.research.google.com
  2. Sign in with Google account
  3. File → New notebook or open from Drive
  4. Start coding — Python environment is pre-configured

Colab comes with most data science libraries pre-installed:

# These work out of the box
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import sklearn
import tensorflow as tf
import torch
import cv2
import PIL
import platform
print(platform.python_version()) # Python version
# Check GPU
import torch
print(torch.cuda.is_available())
print(torch.cuda.get_device_name(0))
# TensorFlow GPU
import tensorflow as tf
print(tf.config.list_physical_devices('GPU'))
# System info
!nvidia-smi # GPU details
!cat /proc/cpuinfo # CPU info
!cat /proc/meminfo # Memory info
!df -h # Disk space
from google.colab import drive
drive.mount('/content/drive')
# Access files
import pandas as pd
df = pd.read_csv('/content/drive/MyDrive/data/myfile.csv')
# Save files
df.to_csv('/content/drive/MyDrive/output/results.csv', index=False)
from google.colab import files
# Upload from local machine
uploaded = files.upload()
# Returns dict: {filename: bytes}
import io
df = pd.read_csv(io.BytesIO(uploaded['data.csv']))
# Download a file
files.download('output.csv')

Change via Runtime → Change runtime type:

RuntimeUse Case
CPUGeneral Python, light ML
GPU (T4/V100/A100)Deep learning, PyTorch, TensorFlow
TPULarge-scale TensorFlow training
# Verify GPU is active
import tensorflow as tf
print("GPU available:", tf.test.is_gpu_available())
# PyTorch
device = 'cuda' if torch.cuda.is_available() else 'cpu'
model = model.to(device)