Using GPU Acceleration in Kaggle Notebooks with Attached Datasets
Learn how to enable GPU/TPU in Kaggle Notebooks, attach datasets, save work to /kaggle/working/, and avoid common pitfalls like session timeouts and read‑only input errors.
03 May 2026, 09:35 UTC

To run machine‑learning experiments without buying hardware, enable a GPU or TPU in a Kaggle Notebook, attach a dataset, and save all outputs to the writable /kaggle/working/ directory. This ensures your model checkpoints survive when you save a version of the notebook.
Enable GPU/TPU Accelerator
- Open or create a notebook.
- In the right‑hand panel click Settings.
- Select Accelerator.
- Choose GPU T4 x2, GPU P100, or TPU v3‑8.
- Note that usage is subject to weekly GPU quotas (historically ~30 hours) and may vary.
Attach a Dataset and Locate Paths
- From a dataset page click New Notebook to have it pre‑attached, or use Add‑on → Data inside an existing notebook.
- The dataset appears read‑only under
/kaggle/input//. - All files you want to keep must be written to
/kaggle/working/, the only persistent writable path.
Worked Example: Load Data, Verify GPU, Save Checkpoint
import pandas as pd
import os
import torch
# List attached datasets (read‑only)
print("Datasets in /kaggle/input:")
for root, dirs, files in os.walk('/kaggle/input'):
for f in files:
print(os.path.join(root, f))
# Load a CSV from the attached dataset – replace and file name as needed
data_path = '/kaggle/input//train.csv'
df = pd.read_csv(data_path)
print(f"Loaded data shape: {df.shape}")
# Verify that the accelerator is active
if torch.cuda.is_available():
print(f"GPU detected: {torch.cuda.get_device_name(0)}")
else:
print("No GPU detected – check the Accelerator setting or your weekly quota.")
# Save a simple checkpoint to the writable directory
checkpoint_path = '/kaggle/working/checkpoint.txt'
with open(checkpoint_path, 'w') as f:
f.write('example_weight=0.42')
print(f"Checkpoint written to {checkpoint_path}")
Managing Session Limits and Persistence
- Kaggle notebooks timeout after roughly 9‑12 hours of inactivity; any unsaved state in memory is lost.
- To persist work, periodically save model weights or intermediate results to
/kaggle/working/. - Use Save & Run All (Commit) instead of Quick Save. The former executes the notebook from top to bottom and stores the contents of
/kaggle/working/as the notebook output.
Common Pitfalls and Limitations
Internet Access
By default, outbound internet is disabled. If you need to pip install a package not already present, toggle Internet on in the Settings panel. Some competitions prohibit internet access, so enable it only when allowed.
Read‑Only Input
Attempting to write to /kaggle/input/ raises an error and wastes debugging time. Always write to /kaggle/working/.
Session Quotas
GPU/TPU availability is not guaranteed; if you exceed the weekly quota the accelerator will be unavailable until the quota resets. Check the Settings panel for the current status.
Memory Constraints
RAM varies with the accelerator (approximately 13‑29 GB). Large data loads may cause out‑of‑memory errors; consider sampling or using data loaders that stream from disk.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.