kaggle-free-gpu
MCP Server, CLI, and Agent Skill for Zero-Cost Tesla T4 x2 GPU Execution via the Kaggle REST API.
kaggle-free-gpu provides coding agents (Claude Code, Cursor, Antigravity) and ML engineers with programmatic access to Kaggle's dual NVIDIA Tesla T4 GPUs (2 x 15,360 MiB VRAM, Python 3.13, PyTorch 2.11+cu130) over direct REST and RPC calls to https://www.kaggle.com/api/v1.
Overview & Engineering Rationale
Coding agents can author PyTorch training loops, QLoRA fine-tuning pipelines, and CUDA/GGUF inference harnesses, but local agent execution environments rarely have dedicated GPU hardware. Kaggle provides up to 30 GPU-hours per rolling 7-day window on dual Tesla T4 accelerators at zero cost. However, automating Kaggle kernel execution from an autonomous agent fails with standard tooling due to undocumented API invariants:
- Broken Official CLI Host: Kaggle CLI 1.8 routes requests to
api.kaggle.com, which fails for kernel session operations. All requests must targethttps://www.kaggle.com/api/v1directly. - Title-Derived Slug Resolution: Kaggle derives the canonical URL slug of a kernel from
newTitle, ignoring the slug portion ofidinkernel-metadata.json. Calling status or output endpoints with anid-based slug that diverges from the title-derived slug returnsHTTP 403 Forbidden. Attempting to update an existing kernel wheniddoes not match the title-derived slug is interpreted as a new kernel creation and fails withHTTP 409 Conflict. - Undocumented Service Endpoints: Standard REST paths such as
/kernels/status/{owner}/{slug}and/kernels/output/{owner}/{slug}do not exist. Session status, output retrieval, and kernel deletion require JSON POST requests tokernels.KernelsApiServiceRPC endpoints. - Working Directory Output Saturation:
ListKernelSessionOutputreturns signed URLs for every file left in/kaggle/working. Leaving multi-gigabyte model checkpoints or GGUF weights in/kaggle/workingcauses output retrieval to fail withIncompleteRead. - Silent CPU Fallback in
llama.cppCUDA Releases: Prebuiltllama.cppUbuntu CUDA tarballs do not bundlelibcudart.so.12,libcublas.so.12, orlibcublasLt.so.12. Unless the companioncudart-llama-*archive from the same release is extracted into the same directory and added toLD_LIBRARY_PATH, the CUDA backend fails to register without emitting an error and executes on CPU (~2.7 tok/s vs ~37.7 tok/s on Tesla T4).
kaggle-free-gpu encodes these invariants into pre-push static validation, HEAD Content-Length output guards, a local rolling 7-day GPU quota ledger, a Model Context Protocol (MCP) server, and a terminal CLI (kfg).
Hardware & Runtime Specifications
Verified live on Kaggle GPU sessions (machineShape: NvidiaTeslaT4):
| Parameter | Specification |
|---|---|
| Accelerators | 2 x NVIDIA Tesla T4 (Compute Capability 7.5, 40 SMs per GPU) |
| VRAM | 2 x 15,360 MiB (30,720 MiB total / 29.12 GiB usable) |
| NVIDIA Driver / CUDA | Driver 580.178.04 / CUDA 13.0 |
| Python / PyTorch | Python 3.13.16 / torch 2.11.0+cu130 |
| Weekly Quota | ~30 GPU-hours per rolling 7-day window (~15 wall-clock hours on T4 x2) |
| Maximum Session Duration | 12 hours per execution |
Installation
Using uv (Recommended)
# Install CLI (`kaggle-free-gpu` / `kfg`) and MCP server (`kaggle-free-gpu-mcp`) globally:
uv tool install git+https://github.com/ericmaddox/kaggle-free-gpu.git
# Or install in a local development checkout:
git clone https://github.com/ericmaddox/kaggle-free-gpu.git
cd kaggle-free-gpu
uv sync --extra dev
Using pip
pip install git+https://github.com/ericmaddox/kaggle-free-gpu.git
Authentication
Generate a Kaggle API token at https://www.kaggle.com/settings. Credentials are resolved in the following order and are never logged or written to repository files:
KAGGLE_API_TOKENenvironment variable (Bearer KGAT_...)~/.kaggle/access_tokenfile (Bearer KGAT_...)KAGGLE_USERNAMEandKAGGLE_KEYenvironment variables (Basicauth)~/.kaggle/kaggle.jsonfile (Basicauth)
mkdir -p ~/.kaggle
echo "KGAT_your_token_here" > ~/.kaggle/access_token
chmod 600 ~/.kaggle/access_token
MCP Server Configuration
Register kaggle-free-gpu-mcp in your agent's MCP configuration (mcp_config.json, .mcp.json, or claude_desktop_config.json):
{
"mcpServers": {
"kaggle-free-gpu": {
"command": "kaggle-free-gpu-mcp",
"env": {
"KAGGLE_API_TOKEN": "KGAT_your_token_here"
}
}
}
}
MCP Tools Reference
| Tool | Signature | Description |
|---|---|---|
push_kernel |
(dir: str, allow_mismatch: bool = False) |
Validates kernel-metadata.json (id slug vs title-derived slug, code file existence, privacy flag), pushes via POST /api/v1/kernels/push (application/json), reports rejected taxonomy tags (invalid_tags), and records the run in the local quota ledger. |
kernel_status |
(owner_slug: str) |
Queries POST /api/v1/kernels.KernelsApiService/GetKernelSessionStatus and returns QUEUED, RUNNING, COMPLETE, or ERROR. |
kernel_output |
(owner_slug: str, out_dir: str, max_size_mb: int = 500, force_large: bool = False) |
Queries POST /api/v1/kernels.KernelsApiService/ListKernelSessionOutput, inspects Content-Length via HEAD before downloading files from /kaggle/working, writes kernel.log, and updates the quota ledger with measured runtime from the execution log. |
list_kernels |
(mine: bool = True, user: str | None = None, search: str | None = None, page_size: int = 20) |
Lists kernels via GET /api/v1/kernels/list (uses group=profile when mine=True). |
delete_kernel |
(owner_slug: str, confirm: bool = False) |
Permanently deletes a kernel via POST /api/v1/kernels.KernelsApiService/DeleteKernel. Refuses execution unless confirm=True is explicitly passed after user confirmation. |
quota_estimate |
() |
Estimates rolling 7-day GPU-hours and T4 x2 wall-hours remaining from ~/.kaggle-free-gpu/usage.json. Note: Kaggle provides no API endpoint for live quota; check Settings -> GPU Quota on the Kaggle web UI for the exact balance. |
CLI Usage (kfg / kaggle-free-gpu)
# 1. Estimate remaining rolling 7-day GPU quota
uv run kfg quota
# 2. Validate and push a kernel directory, poll until COMPLETE, and download outputs
uv run kfg push examples/01_gpu_smoke_test --wait --out-dir outputs/smoke
# 3. Check execution status of a kernel
uv run kfg status <owner>/kfg-gpu-smoke-test
# 4. Pull output files and execution logs with a 500 MB per-file safety guard
uv run kfg output <owner>/kfg-gpu-smoke-test --out-dir outputs/smoke --max-size-mb 500
# 5. List your own kernels
uv run kfg list --mine
# 6. Permanently delete a kernel (interactive confirmation or --yes)
uv run kfg delete <owner>/kfg-gpu-smoke-test
Note on
<owner>placeholder resolution: Allkernel-metadata.jsonfiles inexamples/use"id": "<owner>/<slug>".kaggle-free-gpuautomatically resolves<owner>from your authenticated Kaggle account at push time.
Benchmarks: CPU vs. Kaggle Tesla T4 x2
Measured live on Kaggle (2 x Tesla T4, Python 3.13.16, torch 2.11.0+cu130) across the repository's reference workflows:
| Workload | CPU Baseline | Kaggle Tesla T4 ($0) | Speedup / Outcome |
|---|---|---|---|
Autoregressive Transformer Decoding (examples/03_inference_bench) |
4.99 tok/s (6.42s for 32 tokens, FP32) |
456.07 tok/s (0.84s for 384 tokens, FP16) |
91.4x speedup |
9B Q4_K_M GGUF Inference (llama.cpp) (Rule #6 verification) |
2.70 tok/s (without cudart companion libs) |
37.70 tok/s (with cudart + LD_LIBRARY_PATH) |
14.0x speedup |
QLoRA 4-Bit Base + LoRA Fine-Tuning (examples/02_qlora_finetune) |
Impractical on CPU | 19,092.1 tok/s (6.44s for 60 steps; loss 8.9066 -> 0.0005) |
60 steps in 6.44s |
Batch 32K x 768 Cosine Top-K + SVD (examples/04_data_processing) |
11,806.2 docs/s (2.71s) |
58,595.5 docs/s (0.55s for 256M cosine pairs + PCA) |
4.96x speedup |
CLI Execution Transcript
$ uv run kfg push examples/02_qlora_finetune --wait --out-dir outputs/qlora
+--------------------------- Kaggle Free-GPU Push ----------------------------+
| Pushed successfully! |
| Ref: <owner>/kfg-qlora-finetune-demo |
| Title: KFG QLoRA Finetune Demo |
| Version: 3 |
| GPU Enabled: True | Private: True |
| URL: https://www.kaggle.com/code/<owner>/kfg-qlora-finetune-demo |
+-----------------------------------------------------------------------------+
[0s] <owner>/kfg-qlora-finetune-demo -> QUEUED
[10s] <owner>/kfg-qlora-finetune-demo -> RUNNING
[50s] <owner>/kfg-qlora-finetune-demo -> COMPLETE
Output downloaded to: outputs/qlora (runtime: 32.99s)
+---------------------------------- Stdout -----------------------------------+
| { |
| "workflow": "qlora_finetune", |
| "gpu_name": "Tesla T4", |
| "gpu_count": 2, |
| "trainable_lora_params": 1878016, |
| "frozen_4bit_packed_mb": 38.0, |
| "steps": 60, |
| "initial_loss": 8.9066, |
| "final_loss": 0.0005, |
| "gpu_train_seconds": 6.436, |
| "tokens_per_second": 19092.1, |
| "saved_adapter_file": "lora_adapter.pt" |
| } |
| CLEANUP DONE |
+-----------------------------------------------------------------------------+
Reference Workflows (examples/)
examples/01_gpu_smoke_test: Queriestorch.cudadevice properties andnvidia-smi, executes an FP164096 x 4096GEMM across all attached GPUs, and writesgpu_smoke_report.json.examples/02_qlora_finetune: Quantizes base transformer linear layers into packed 4-bituint8buffers with per-block FP16 scales, attaches trainable FP32/FP16 LoRA adapters (lora_A,lora_B), runs 60 optimization steps with gradient clipping, exports only the compact adapter (lora_adapter.pt) andqlora_metrics.json, and cleans up/tmp.examples/03_inference_bench: Benchmarks autoregressive transformer token generation across Tesla T4 (float16) and CPU (float32), and providessetup_llamacpp_cuda()for downloading and configuring both thellama.cppCUDA binary tarball and its requiredcudart-companion runtime archive.examples/04_data_processing: Executes L2 normalization, 256M-pair exact cosine similarity top-k retrieval, and 32-component low-rank SVD (torch.pca_lowrank) over 32,000 x 768 document embeddings on Tesla T4 vs CPU.
Repository Structure
kaggle-free-gpu/
├── SKILL.md # Agent skill specification, workflow, and operational rules
├── pyproject.toml # Hatchling build config, dependencies, and entrypoints
├── src/
│ └── kaggle_free_gpu/
│ ├── __init__.py
│ ├── client.py # Direct REST & KernelsApiService RPC client
│ ├── models.py # Pydantic schemas and pre-push metadata validator
│ ├── quota.py # Local rolling 7-day GPU quota ledger
│ ├── server.py # FastMCP server exposing the 6 Kaggle GPU tools
│ └── cli.py # Terminal CLI (`kaggle-free-gpu` / `kfg`)
├── examples/
│ ├── 01_gpu_smoke_test/
│ ├── 02_qlora_finetune/
│ ├── 03_inference_bench/
│ └── 04_data_processing/
├── scripts/
│ └── validate_live.py # End-to-end live validation suite against Kaggle REST API
└── tests/
└── test_client_and_rules.py # Unit tests for slug rules, quota math, and safety guards
Development & Verification
# Run unit tests
uv run pytest -v
# Run linter
uv run ruff check src tests scripts examples
# Run live end-to-end GPU validation against Kaggle REST API (requires KAGGLE_API_TOKEN)
uv run python scripts/validate_live.py
License
MIT License. See LICENSE.
Metadata
Release files for kaggle-free-gpu 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kaggle_free_gpu-0.1.2.tar.gz | 855.9 kB | With provenance | Details for kaggle_free_gpu-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kaggle_free_gpu-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for kaggle_free_gpu-0.1.2-py3-none-any.whl |
Total release size: 885.5 kB
Release files / kaggle_free_gpu-0.1.2.tar.gz
| Download URL | kaggle_free_gpu-0.1.2.tar.gz |
|---|---|
| Size | 855.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1149551086095c8980cdfe8bf4747c4d9eb70cd7fa4931161c78164b6f99bf89
|
|
BLAKE2b-256 checksum How to use checksums |
0cbfe3cc6623a857b90ab37d8903b88232062f7b2b3e8aa3e5157805c6572aa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.
Transparency logRelease files / kaggle_free_gpu-0.1.2-py3-none-any.whl
| Download URL | kaggle_free_gpu-0.1.2-py3-none-any.whl |
|---|---|
| Size | 29.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e279eb02bb6fcede9ff3fcb76c65039481f28b51b9e80fbd48fdc458e90670d
|
|
BLAKE2b-256 checksum How to use checksums |
0b87fb8c1ace4f6e427e59a720eab6453673009932ff9c185a315a442dba69b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.
Transparency logSecurity for kaggle-free-gpu 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for kaggle_free_gpu-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.