Notebook rendering
The <NotebookRenderer /> component reads a .ipynb file from public/
and renders it as a static, read-only Jupyter-style document. Code is
highlighted with shiki , markdown cells are rendered
with react-markdown, and outputs (stdout, dataframes, plots, errors) are
shown inline.
Usage
import { NotebookRenderer } from '@/components/notebook/NotebookRenderer'
<NotebookRenderer src="/example.ipynb" />Live example
Below is public/example.ipynb rendered with the component:
pwd'/workspace/workdisk3/rudhra/Desktop/experiments/deep_learning_practice/docs/docs/public'
!pwd/workspace/workdisk3/rudhra/Desktop/experiments/deep_learning_practice/docs/docs/public
import numpy as np
import matplotlib.pyplot as plt
# Generate x values from 0 to 4π
x = np.linspace(0, 4 * np.pi, 1000)
y = np.sin(x)
# Plot
plt.figure(figsize=(10, 4))
plt.plot(x, y, color='royalblue', linewidth=2)
plt.title('Sine Wave')
plt.xlabel('x (radians)')
plt.ylabel('sin(x)')
plt.axhline(0, color='gray', linewidth=0.8, linestyle='--') # zero line
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()import pandas as pd
# --- 1. Create a DataFrame from a dictionary ---
data = {
'Name': ['Alice', 'Bob', 'Charlie', 'Diana'],
'Age': [25, 30, 35, 28],
'City': ['New York', 'London', 'Paris', 'Toronto'],
'Score': [88.5, 92.0, 79.3, 95.1]
}
df = pd.DataFrame(data)
print(df)Name Age City Score 0 Alice 25 New York 88.5 1 Bob 30 London 92.0 2 Charlie 35 Paris 79.3 3 Diana 28 Toronto 95.1
Making the Most of your Colab Subscription
Google Colab is available in VS Code!
Try the new Google Colab extension for Visual Studio Code. You can get up and running in just a few clicks:
- In VS Code, open the Extensions view and search for 'Google Colab' to install.
- Open the kernel selector by creating or opening any
.ipynbnotebook file in your local workspace and either running a cell or clicking the Select Kernel button in the top right. - Click Colab and then select your desired runtime, sign in with your Google account, and you're all set!
See more details in our announcement blog here.
Access Popular LLMs via Google-Colab-AI Without an API Key
Users with Colab's paid plans have free access to most popular LLMs via google-colab-ai Python library. For more details, refer to the getting started with google colab ai.
from google.colab import ai
response = ai.generate_text("What is the capital of France?")
print(response)Faster GPUs
Users who have purchased one of Colab's paid plans have access to faster GPUs and more memory. You can upgrade your notebook's GPU settings in Runtime > Change runtime type in the menu to select from several accelerator options, subject to availability.
The free of charge version of Colab grants access to Nvidia's T4 GPUs subject to quota restrictions and availability.
You can see what GPU you've been assigned at any time by executing the following cell. If the execution result of running the code cell below is "Not connected to a GPU", you can change the runtime by going to Runtime > Change runtime type in the menu to enable a GPU accelerator, and then re-execute the code cell.
gpu_info = !nvidia-smi
gpu_info = '\n'.join(gpu_info)
if gpu_info.find('failed') >= 0:
print('Not connected to a GPU')
else:
print(gpu_info)In order to use a GPU with your notebook, select the Runtime > Change runtime type menu, and then set the hardware accelerator to the desired option.
More memory
Users who have purchased one of Colab's paid plans have access to high-memory VMs when they are available. More powerful GPUs are always offered with high-memory VMs.
You can see how much memory you have available at any time by running the following code cell. If the execution result of running the code cell below is "Not using a high-RAM runtime", then you can enable a high-RAM runtime via Runtime > Change runtime type in the menu. Then select High-RAM in the Runtime shape toggle button. After, re-execute the code cell.
import psutil
ram_gb = psutil.virtual_memory().total / 1e9
print('Your runtime has {:.1f} gigabytes of available RAM\n'.format(ram_gb))
if ram_gb < 20:
print('Not using a high-RAM runtime')
else:
print('You are using a high-RAM runtime!')Longer runtimes
All Colab runtimes are reset after some period of time (which is faster if the runtime isn't executing code). Colab Pro and Pro+ users have access to longer runtimes than those who use Colab free of charge.
Background execution
Colab Pro+ users have access to background execution, where notebooks will continue executing even after you've closed a browser tab. This is always enabled in Pro+ runtimes as long as you have compute units available.
Relaxing resource limits in Colab Pro
Your resources are not unlimited in Colab. To make the most of Colab, avoid using resources when you don't need them. For example, only use a GPU when required and close Colab tabs when finished.
If you encounter limitations, you can relax those limitations by purchasing more compute units via Pay As You Go. Anyone can purchase compute units via Pay As You Go; no subscription is required.
Send us feedback!
If you have any feedback for us, please let us know. The best way to send feedback is by using the Help > 'Send feedback...' menu. If you encounter usage limits in Colab Pro consider subscribing to Pro+.
If you encounter errors or other issues with billing (payments) for Colab Pro, Pro+, or Pay As You Go, please email colab-billing@google.com.
More Resources
Working with Notebooks in Colab
- Overview of Colab
- Guide to Markdown
- Importing libraries and installing dependencies
- Saving and loading notebooks in GitHub
- Interactive forms
- Interactive widgets
Working with Data
- Loading data: Drive, Sheets, and Google Cloud Storage
- Charts: visualizing data
- Getting started with BigQuery
Machine Learning Crash Course
These are a few of the notebooks from Google's online Machine Learning course. See the full course website for more.
- Intro to Pandas DataFrame
- Intro to RAPIDS cuDF to accelerate pandas
- Getting Started with cuML's accelerator mode
Using Accelerated Hardware
Machine Learning Examples
A few featured examples:
- Train a miniGPT language model with JAX AI Stack
- LoRA/QLoRA finetuning for LLM using Tunix
- Parameter-efficient fine-tuning of Gemma with LoRA and QLoRA
- Loading Hugging Face Transformers Checkpoints
- 8-bit Integer Quantization in Keras
- Float8 training and inference with a simple Transformer model
- Pretraining a Transformer from scratch with KerasHub
- Simple MNIST convnet
- Image classification from scratch using Keras 3
- Image Classification with KerasHub
Supported outputs
stream—stdoutandstderrtextexecute_result/display_datafor:image/pngandimage/jpeg(base64)image/svg+xmltext/html(e.g. pandas DataFrames)application/jsontext/plainfallback
error— ANSI codes are stripped from tracebacks
Notes
- Static renderer — cells are never executed.
- Light and dark color schemes are applied automatically via
prefers-color-scheme.