Using Kaggle Notebooks for Free GPU‑Accelerated ML Prototyping
Learn how to use Kaggle Notebooks for free GPU‑accelerated ML prototyping, including enabling accelerators, attaching datasets, a short training example, and the key trade‑offs to consider.
11 Sept 2026, 02:42 UTC

Why reach for Kaggle when you need a quick experiment?
Setting up a local GPU environment or spinning up a paid cloud instance can take time and incur costs, especially when you just want to test a model idea or share a reproducible notebook with colleagues. Kaggle Notebooks (formerly Kernels) give you a hosted Jupyter‑style environment with a pre‑installed data‑science stack, free access to GPU/TPU accelerators, and direct mounting of public datasets. The trade‑off is that compute is quota‑limited and sessions are ephemeral, making the platform best suited for prototyping, learning, and sharing rather than production workloads.
Getting ready: enable accelerator and attach data
- Log in to Kaggle and create a free account if you don’t have one.
- Open a new Notebook (
New Notebookbutton). - In the right‑hand sidebar, click
Settings→Acceleratorand selectGPU(orTPUif available). Note that your weekly GPU quota is shown here; it varies over time. - Still in
Settings, enableInternetif you need to pip‑install packages not already present. This requires phone‑verified accounts. - To attach a dataset, go to the
Datapanel, search for a public dataset (e.g.,ashishsaxena12345/mnist), and clickAdd to Notebook. The dataset will be mounted read‑only at/kaggle/input/. - Your writable workspace is
/kaggle/working. Any files you save here persist for the duration of the session and are included when you create a notebook version.
Worked example: train a tiny MNIST model on GPU and save a version
The following cells can be copied into a Kaggle Notebook. They assume you have added the MNIST dataset as described above.
# Cell 1: Imports and device setup
import torch, torchvision
from torch import nn, optim
from torchvision import transforms, datasets
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print(f'Using device: {device}')
# Cell 2: Load data
transform = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize((0.1307,), (0.3081,))
])
train_set = datasets.MNIST(root='/kaggle/input/mnist', train=True, download=False, transform=transform)
train_loader = torch.utils.data.DataLoader(train_set, batch_size=64, shuffle=True, num_workers=2)
# Cell 3: Define a simple CNN
class SimpleCNN(nn.Module):
def __init__(self):
super().__init__()
self.net = nn.Sequential(
nn.Conv2d(1, 16, 3, padding=1), nn.ReLU(),
nn.MaxPool2d(2),
nn.Conv2d(16, 32, 3, padding=1), nn.ReLU(),
nn.MaxPool2d(2),
nn.Flatten(),
nn.Linear(32 * 7 * 7, 128), nn.ReLU(),
nn.Linear(128, 10)
)
def forward(self, x):
return self.net(x)
model = SimpleCNN().to(device)
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=0.001)
# Cell 4: Training loop (2 epochs for demo)
for epoch in range(2):
model.train()
running_loss = 0.0
for images, labels in train_loader:
images, labels = images.to(device), labels.to(device)
optimizer.zero_grad()
outputs = model(images)
loss = criterion(outputs, labels)
loss.backward()
optimizer.step()
running_loss += loss.item() * images.size(0)
epoch_loss = running_loss / len(train_loader.dataset)
print(f'Epoch {epoch+1}: loss = {epoch_loss:.4f}')
# Cell 5: Save a version (click the UI button after running)
# In the notebook UI, choose File → Save Version.
# This creates a reproducible snapshot that includes the code and any files in /kaggle/working.
After running the cells, you should see loss values decreasing, confirming that the GPU is being used. To verify that outputs persisted, open the Outputs tab of the notebook version you just saved; you will find any files you manually saved to /kaggle/working (e.g., a model checkpoint if you added one).
Trade‑offs and practical limits
- GPU/TPU quota: Each account receives a limited amount of accelerator time per week (exact hours change). Long training jobs may be cut off; you must checkpoint to
/kaggle/workingand resume later. - Session length: Continuous execution is capped at roughly 9–12 hours depending on the accelerator type and current load. After the limit, the container stops and you lose in‑memory state.
- Storage: Only
/kaggle/workingis writable and is not guaranteed beyond the session unless you create a version. Datasets themselves are read‑only. - Network access: Disabled by default; enabling it requires phone verification and can be toggled per‑notebook. Some corporate environments block outbound traffic even when enabled.
- No guaranteed availability: The free tier is best‑effort; during high demand you may see slower GPU allocation or temporary unavailability.
You can check your current quota and session limits at any time by opening Settings → Accelerator in the notebook UI. The displayed numbers are the authoritative source for your account.
When to move beyond Kaggle
If you need:
- Training runs that exceed your weekly GPU quota,
- Persistent storage larger than a few gigabytes,
- Fixed‑uptime guarantees or specialized hardware (e.g., multi‑GPU, high‑memory instances),
- Access to internal data stores or private APIs that require outbound networking not allowed on Kaggle,
consider provisioning a paid cloud instance (AWS EC2, GCP AI Platform, Azure ML) or using a local workstation with a dedicated GPU. For quick idea validation, sharing reproducible experiments, or learning new libraries, Kaggle Notebooks remain a low‑friction, cost‑free choice.
Actionable checklist
- Verify your GPU quota and enable internet access if needed.
- Attach the desired dataset(s) to
/kaggle/input. - Develop your experiment, saving intermediate artifacts to
/kaggle/working. - When satisfied, use
File → Save Versionto create a reproducible snapshot. - Review the version’s outputs to confirm persistence.
- If you hit quota or session limits, plan to checkpoint and resume, or migrate to a more robust compute environment.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.