kaggle-free-gpu 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kaggle_free_gpu-0.1.0/.env.example +9 -0
- kaggle_free_gpu-0.1.0/.github/workflows/ci.yml +38 -0
- kaggle_free_gpu-0.1.0/.github/workflows/publish.yml +28 -0
- kaggle_free_gpu-0.1.0/.gitignore +53 -0
- kaggle_free_gpu-0.1.0/LICENSE +22 -0
- kaggle_free_gpu-0.1.0/PKG-INFO +266 -0
- kaggle_free_gpu-0.1.0/README.md +233 -0
- kaggle_free_gpu-0.1.0/SKILL.md +264 -0
- kaggle_free_gpu-0.1.0/examples/01_gpu_smoke_test/gpu_smoke_test.py +67 -0
- kaggle_free_gpu-0.1.0/examples/01_gpu_smoke_test/kernel-metadata.json +12 -0
- kaggle_free_gpu-0.1.0/examples/02_qlora_finetune/kernel-metadata.json +12 -0
- kaggle_free_gpu-0.1.0/examples/02_qlora_finetune/qlora_finetune.py +188 -0
- kaggle_free_gpu-0.1.0/examples/03_inference_bench/inference_bench.py +168 -0
- kaggle_free_gpu-0.1.0/examples/03_inference_bench/kernel-metadata.json +13 -0
- kaggle_free_gpu-0.1.0/examples/04_data_processing/data_processing.py +81 -0
- kaggle_free_gpu-0.1.0/examples/04_data_processing/kernel-metadata.json +12 -0
- kaggle_free_gpu-0.1.0/pyproject.toml +81 -0
- kaggle_free_gpu-0.1.0/scripts/validate_live.py +152 -0
- kaggle_free_gpu-0.1.0/src/kaggle_free_gpu/__init__.py +4 -0
- kaggle_free_gpu-0.1.0/src/kaggle_free_gpu/cli.py +308 -0
- kaggle_free_gpu-0.1.0/src/kaggle_free_gpu/client.py +843 -0
- kaggle_free_gpu-0.1.0/src/kaggle_free_gpu/models.py +230 -0
- kaggle_free_gpu-0.1.0/src/kaggle_free_gpu/quota.py +227 -0
- kaggle_free_gpu-0.1.0/src/kaggle_free_gpu/server.py +168 -0
- kaggle_free_gpu-0.1.0/tests/test_client_and_rules.py +276 -0
- kaggle_free_gpu-0.1.0/uv.lock +1600 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Option 1 (Recommended): Kaggle API Token (KGAT_...)
|
|
2
|
+
# Or save raw token to ~/.kaggle/access_token
|
|
3
|
+
KAGGLE_API_TOKEN=KGAT_your_token_here
|
|
4
|
+
|
|
5
|
+
# Option 2: Legacy Kaggle Username + Key
|
|
6
|
+
# Or save {"username": "...", "key": "..."} to ~/.kaggle/kaggle.json
|
|
7
|
+
# KAGGLE_USERNAME=your_kaggle_username
|
|
8
|
+
# KAGGLE_KEY=your_kaggle_hex_key
|
|
9
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
23
|
+
uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: ${{ matrix.python-version }}
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: |
|
|
29
|
+
python -m pip install --upgrade pip
|
|
30
|
+
pip install ".[dev]"
|
|
31
|
+
|
|
32
|
+
- name: Lint with Ruff
|
|
33
|
+
run: |
|
|
34
|
+
ruff check src tests scripts examples
|
|
35
|
+
|
|
36
|
+
- name: Test with Pytest
|
|
37
|
+
run: |
|
|
38
|
+
pytest -v --cov=kaggle_free_gpu
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
pypi-publish:
|
|
10
|
+
name: Build and publish Python distributions to PyPI
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout source
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up uv
|
|
20
|
+
uses: astral-sh/setup-uv@v5
|
|
21
|
+
with:
|
|
22
|
+
version: "latest"
|
|
23
|
+
|
|
24
|
+
- name: Build distributions
|
|
25
|
+
run: uv build
|
|
26
|
+
|
|
27
|
+
- name: Publish package distributions to PyPI
|
|
28
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Virtual environments & build artifacts
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
ENV/
|
|
10
|
+
dist/
|
|
11
|
+
build/
|
|
12
|
+
*.egg-info/
|
|
13
|
+
|
|
14
|
+
# Test, coverage & linter caches
|
|
15
|
+
.pytest_cache/
|
|
16
|
+
.ruff_cache/
|
|
17
|
+
.mypy_cache/
|
|
18
|
+
.coverage
|
|
19
|
+
coverage.xml
|
|
20
|
+
htmlcov/
|
|
21
|
+
|
|
22
|
+
# Secrets & credentials — NEVER commit
|
|
23
|
+
.env
|
|
24
|
+
.env.*
|
|
25
|
+
!.env.example
|
|
26
|
+
kaggle.json
|
|
27
|
+
access_token
|
|
28
|
+
*token*
|
|
29
|
+
*.pem
|
|
30
|
+
*.key
|
|
31
|
+
|
|
32
|
+
# Internal design briefs & local scratch notes
|
|
33
|
+
Kaggle Free-GPU Skill - Brief for Gemini Argon.md
|
|
34
|
+
*Brief*.md
|
|
35
|
+
scratch/
|
|
36
|
+
|
|
37
|
+
# Downloaded kernel outputs, model weights & scratch dirs
|
|
38
|
+
outputs/
|
|
39
|
+
tmp_*/
|
|
40
|
+
.kaggle-free-gpu/
|
|
41
|
+
*.pt
|
|
42
|
+
*.pth
|
|
43
|
+
*.bin
|
|
44
|
+
*.safetensors
|
|
45
|
+
*.gguf
|
|
46
|
+
*.tar.gz
|
|
47
|
+
*.zip
|
|
48
|
+
|
|
49
|
+
# OS & IDE files
|
|
50
|
+
.DS_Store
|
|
51
|
+
Thumbs.db
|
|
52
|
+
.idea/
|
|
53
|
+
.vscode/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Eric Maddox
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: kaggle-free-gpu
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Give any coding agent free Tesla T4 x2 GPUs via Kaggle's REST API -- MCP server, CLI, and skill.
|
|
5
|
+
Project-URL: Homepage, https://github.com/ericmaddox/kaggle-free-gpu
|
|
6
|
+
Project-URL: Repository, https://github.com/ericmaddox/kaggle-free-gpu.git
|
|
7
|
+
Project-URL: Issues, https://github.com/ericmaddox/kaggle-free-gpu/issues
|
|
8
|
+
Author-email: Eric Maddox <eric.maddox@outlook.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai-agents,antigravity,claude-code,cursor,free-gpu,gpu,kaggle,llama-cpp,mcp,mcp-server,qlora,tesla-t4
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: httpx<1.0.0,>=0.28.0
|
|
24
|
+
Requires-Dist: mcp<2.0.0,>=1.3.0
|
|
25
|
+
Requires-Dist: pydantic<3.0.0,>=2.10.0
|
|
26
|
+
Requires-Dist: rich<14.0.0,>=13.9.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.8.0; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# kaggle-free-gpu
|
|
35
|
+
|
|
36
|
+
**MCP Server, CLI, and Agent Skill for Zero-Cost Tesla T4 x2 GPU Execution via the Kaggle REST API.**
|
|
37
|
+
|
|
38
|
+
`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`.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Overview & Engineering Rationale
|
|
43
|
+
|
|
44
|
+
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:
|
|
45
|
+
|
|
46
|
+
1. **Broken Official CLI Host:** Kaggle CLI 1.8 routes requests to `api.kaggle.com`, which fails for kernel session operations. All requests must target `https://www.kaggle.com/api/v1` directly.
|
|
47
|
+
2. **Title-Derived Slug Resolution:** Kaggle derives the canonical URL slug of a kernel from `newTitle`, ignoring the slug portion of `id` in `kernel-metadata.json`. Calling status or output endpoints with an `id`-based slug that diverges from the title-derived slug returns `HTTP 403 Forbidden`. Attempting to update an existing kernel when `id` does not match the title-derived slug is interpreted as a new kernel creation and fails with `HTTP 409 Conflict`.
|
|
48
|
+
3. **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 to `kernels.KernelsApiService` RPC endpoints.
|
|
49
|
+
4. **Working Directory Output Saturation:** `ListKernelSessionOutput` returns signed URLs for every file left in `/kaggle/working`. Leaving multi-gigabyte model checkpoints or GGUF weights in `/kaggle/working` causes output retrieval to fail with `IncompleteRead`.
|
|
50
|
+
5. **Silent CPU Fallback in `llama.cpp` CUDA Releases:** Prebuilt `llama.cpp` Ubuntu CUDA tarballs do not bundle `libcudart.so.12`, `libcublas.so.12`, or `libcublasLt.so.12`. Unless the companion `cudart-llama-*` archive from the same release is extracted into the same directory and added to `LD_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).
|
|
51
|
+
|
|
52
|
+
`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`).
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Hardware & Runtime Specifications
|
|
57
|
+
|
|
58
|
+
Verified live on Kaggle GPU sessions (`machineShape: NvidiaTeslaT4`):
|
|
59
|
+
|
|
60
|
+
| Parameter | Specification |
|
|
61
|
+
| :--- | :--- |
|
|
62
|
+
| **Accelerators** | 2 x NVIDIA Tesla T4 (Compute Capability 7.5, 40 SMs per GPU) |
|
|
63
|
+
| **VRAM** | 2 x 15,360 MiB (30,720 MiB total / 29.12 GiB usable) |
|
|
64
|
+
| **NVIDIA Driver / CUDA** | Driver `580.178.04` / CUDA `13.0` |
|
|
65
|
+
| **Python / PyTorch** | Python `3.13.16` / `torch 2.11.0+cu130` |
|
|
66
|
+
| **Weekly Quota** | ~30 GPU-hours per rolling 7-day window (~15 wall-clock hours on T4 x2) |
|
|
67
|
+
| **Maximum Session Duration** | 12 hours per execution |
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
### Using `uv` (Recommended)
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Install CLI (`kaggle-free-gpu` / `kfg`) and MCP server (`kaggle-free-gpu-mcp`) globally:
|
|
77
|
+
uv tool install git+https://github.com/ericmaddox/kaggle-free-gpu.git
|
|
78
|
+
|
|
79
|
+
# Or install in a local development checkout:
|
|
80
|
+
git clone https://github.com/ericmaddox/kaggle-free-gpu.git
|
|
81
|
+
cd kaggle-free-gpu
|
|
82
|
+
uv sync --extra dev
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Using `pip`
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pip install git+https://github.com/ericmaddox/kaggle-free-gpu.git
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Authentication
|
|
94
|
+
|
|
95
|
+
Generate a Kaggle API token at [https://www.kaggle.com/settings](https://www.kaggle.com/settings). Credentials are resolved in the following order and are never logged or written to repository files:
|
|
96
|
+
|
|
97
|
+
1. `KAGGLE_API_TOKEN` environment variable (`Bearer KGAT_...`)
|
|
98
|
+
2. `~/.kaggle/access_token` file (`Bearer KGAT_...`)
|
|
99
|
+
3. `KAGGLE_USERNAME` and `KAGGLE_KEY` environment variables (`Basic` auth)
|
|
100
|
+
4. `~/.kaggle/kaggle.json` file (`Basic` auth)
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
mkdir -p ~/.kaggle
|
|
104
|
+
echo "KGAT_your_token_here" > ~/.kaggle/access_token
|
|
105
|
+
chmod 600 ~/.kaggle/access_token
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## MCP Server Configuration
|
|
111
|
+
|
|
112
|
+
Register `kaggle-free-gpu-mcp` in your agent's MCP configuration (`mcp_config.json`, `.mcp.json`, or `claude_desktop_config.json`):
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"mcpServers": {
|
|
117
|
+
"kaggle-free-gpu": {
|
|
118
|
+
"command": "kaggle-free-gpu-mcp",
|
|
119
|
+
"env": {
|
|
120
|
+
"KAGGLE_API_TOKEN": "KGAT_your_token_here"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### MCP Tools Reference
|
|
128
|
+
|
|
129
|
+
| Tool | Signature | Description |
|
|
130
|
+
| :--- | :--- | :--- |
|
|
131
|
+
| `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. |
|
|
132
|
+
| `kernel_status` | `(owner_slug: str)` | Queries `POST /api/v1/kernels.KernelsApiService/GetKernelSessionStatus` and returns `QUEUED`, `RUNNING`, `COMPLETE`, or `ERROR`. |
|
|
133
|
+
| `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. |
|
|
134
|
+
| `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`). |
|
|
135
|
+
| `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. |
|
|
136
|
+
| `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. |
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## CLI Usage (`kfg` / `kaggle-free-gpu`)
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# 1. Estimate remaining rolling 7-day GPU quota
|
|
144
|
+
uv run kfg quota
|
|
145
|
+
|
|
146
|
+
# 2. Validate and push a kernel directory, poll until COMPLETE, and download outputs
|
|
147
|
+
uv run kfg push examples/01_gpu_smoke_test --wait --out-dir outputs/smoke
|
|
148
|
+
|
|
149
|
+
# 3. Check execution status of a kernel
|
|
150
|
+
uv run kfg status <owner>/kfg-gpu-smoke-test
|
|
151
|
+
|
|
152
|
+
# 4. Pull output files and execution logs with a 500 MB per-file safety guard
|
|
153
|
+
uv run kfg output <owner>/kfg-gpu-smoke-test --out-dir outputs/smoke --max-size-mb 500
|
|
154
|
+
|
|
155
|
+
# 5. List your own kernels
|
|
156
|
+
uv run kfg list --mine
|
|
157
|
+
|
|
158
|
+
# 6. Permanently delete a kernel (interactive confirmation or --yes)
|
|
159
|
+
uv run kfg delete <owner>/kfg-gpu-smoke-test
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
> **Note on `<owner>` placeholder resolution:** All `kernel-metadata.json` files in `examples/` use `"id": "<owner>/<slug>"`. `kaggle-free-gpu` automatically resolves `<owner>` from your authenticated Kaggle account at push time.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Benchmarks: CPU vs. Kaggle Tesla T4 x2
|
|
167
|
+
|
|
168
|
+
Measured live on Kaggle (`2 x Tesla T4`, Python `3.13.16`, `torch 2.11.0+cu130`) across the repository's reference workflows:
|
|
169
|
+
|
|
170
|
+
| Workload | CPU Baseline | Kaggle Tesla T4 ($0) | Speedup / Outcome |
|
|
171
|
+
| :--- | :--- | :--- | :--- |
|
|
172
|
+
| **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** |
|
|
173
|
+
| **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** |
|
|
174
|
+
| **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** |
|
|
175
|
+
| **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** |
|
|
176
|
+
|
|
177
|
+
### CLI Execution Transcript
|
|
178
|
+
|
|
179
|
+
```text
|
|
180
|
+
$ uv run kfg push examples/02_qlora_finetune --wait --out-dir outputs/qlora
|
|
181
|
+
+--------------------------- Kaggle Free-GPU Push ----------------------------+
|
|
182
|
+
| Pushed successfully! |
|
|
183
|
+
| Ref: <owner>/kfg-qlora-finetune-demo |
|
|
184
|
+
| Title: KFG QLoRA Finetune Demo |
|
|
185
|
+
| Version: 3 |
|
|
186
|
+
| GPU Enabled: True | Private: True |
|
|
187
|
+
| URL: https://www.kaggle.com/code/<owner>/kfg-qlora-finetune-demo |
|
|
188
|
+
+-----------------------------------------------------------------------------+
|
|
189
|
+
[0s] <owner>/kfg-qlora-finetune-demo -> QUEUED
|
|
190
|
+
[10s] <owner>/kfg-qlora-finetune-demo -> RUNNING
|
|
191
|
+
[50s] <owner>/kfg-qlora-finetune-demo -> COMPLETE
|
|
192
|
+
Output downloaded to: outputs/qlora (runtime: 32.99s)
|
|
193
|
+
+---------------------------------- Stdout -----------------------------------+
|
|
194
|
+
| { |
|
|
195
|
+
| "workflow": "qlora_finetune", |
|
|
196
|
+
| "gpu_name": "Tesla T4", |
|
|
197
|
+
| "gpu_count": 2, |
|
|
198
|
+
| "trainable_lora_params": 1878016, |
|
|
199
|
+
| "frozen_4bit_packed_mb": 38.0, |
|
|
200
|
+
| "steps": 60, |
|
|
201
|
+
| "initial_loss": 8.9066, |
|
|
202
|
+
| "final_loss": 0.0005, |
|
|
203
|
+
| "gpu_train_seconds": 6.436, |
|
|
204
|
+
| "tokens_per_second": 19092.1, |
|
|
205
|
+
| "saved_adapter_file": "lora_adapter.pt" |
|
|
206
|
+
| } |
|
|
207
|
+
| CLEANUP DONE |
|
|
208
|
+
+-----------------------------------------------------------------------------+
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Reference Workflows (`examples/`)
|
|
214
|
+
|
|
215
|
+
- **[`examples/01_gpu_smoke_test`](examples/01_gpu_smoke_test):** Queries `torch.cuda` device properties and `nvidia-smi`, executes an FP16 `4096 x 4096` GEMM across all attached GPUs, and writes `gpu_smoke_report.json`.
|
|
216
|
+
- **[`examples/02_qlora_finetune`](examples/02_qlora_finetune):** Quantizes base transformer linear layers into packed 4-bit `uint8` buffers 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`) and `qlora_metrics.json`, and cleans up `/tmp`.
|
|
217
|
+
- **[`examples/03_inference_bench`](examples/03_inference_bench):** Benchmarks autoregressive transformer token generation across Tesla T4 (`float16`) and CPU (`float32`), and provides `setup_llamacpp_cuda()` for downloading and configuring both the `llama.cpp` CUDA binary tarball and its required `cudart-` companion runtime archive.
|
|
218
|
+
- **[`examples/04_data_processing`](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.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Repository Structure
|
|
223
|
+
|
|
224
|
+
```text
|
|
225
|
+
kaggle-free-gpu/
|
|
226
|
+
├── SKILL.md # Agent skill specification, workflow, and operational rules
|
|
227
|
+
├── pyproject.toml # Hatchling build config, dependencies, and entrypoints
|
|
228
|
+
├── src/
|
|
229
|
+
│ └── kaggle_free_gpu/
|
|
230
|
+
│ ├── __init__.py
|
|
231
|
+
│ ├── client.py # Direct REST & KernelsApiService RPC client
|
|
232
|
+
│ ├── models.py # Pydantic schemas and pre-push metadata validator
|
|
233
|
+
│ ├── quota.py # Local rolling 7-day GPU quota ledger
|
|
234
|
+
│ ├── server.py # FastMCP server exposing the 6 Kaggle GPU tools
|
|
235
|
+
│ └── cli.py # Terminal CLI (`kaggle-free-gpu` / `kfg`)
|
|
236
|
+
├── examples/
|
|
237
|
+
│ ├── 01_gpu_smoke_test/
|
|
238
|
+
│ ├── 02_qlora_finetune/
|
|
239
|
+
│ ├── 03_inference_bench/
|
|
240
|
+
│ └── 04_data_processing/
|
|
241
|
+
├── scripts/
|
|
242
|
+
│ └── validate_live.py # End-to-end live validation suite against Kaggle REST API
|
|
243
|
+
└── tests/
|
|
244
|
+
└── test_client_and_rules.py # Unit tests for slug rules, quota math, and safety guards
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Development & Verification
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
# Run unit tests
|
|
253
|
+
uv run pytest -v
|
|
254
|
+
|
|
255
|
+
# Run linter
|
|
256
|
+
uv run ruff check src tests scripts examples
|
|
257
|
+
|
|
258
|
+
# Run live end-to-end GPU validation against Kaggle REST API (requires KAGGLE_API_TOKEN)
|
|
259
|
+
uv run python scripts/validate_live.py
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
MIT License. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# kaggle-free-gpu
|
|
2
|
+
|
|
3
|
+
**MCP Server, CLI, and Agent Skill for Zero-Cost Tesla T4 x2 GPU Execution via the Kaggle REST API.**
|
|
4
|
+
|
|
5
|
+
`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`.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Overview & Engineering Rationale
|
|
10
|
+
|
|
11
|
+
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:
|
|
12
|
+
|
|
13
|
+
1. **Broken Official CLI Host:** Kaggle CLI 1.8 routes requests to `api.kaggle.com`, which fails for kernel session operations. All requests must target `https://www.kaggle.com/api/v1` directly.
|
|
14
|
+
2. **Title-Derived Slug Resolution:** Kaggle derives the canonical URL slug of a kernel from `newTitle`, ignoring the slug portion of `id` in `kernel-metadata.json`. Calling status or output endpoints with an `id`-based slug that diverges from the title-derived slug returns `HTTP 403 Forbidden`. Attempting to update an existing kernel when `id` does not match the title-derived slug is interpreted as a new kernel creation and fails with `HTTP 409 Conflict`.
|
|
15
|
+
3. **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 to `kernels.KernelsApiService` RPC endpoints.
|
|
16
|
+
4. **Working Directory Output Saturation:** `ListKernelSessionOutput` returns signed URLs for every file left in `/kaggle/working`. Leaving multi-gigabyte model checkpoints or GGUF weights in `/kaggle/working` causes output retrieval to fail with `IncompleteRead`.
|
|
17
|
+
5. **Silent CPU Fallback in `llama.cpp` CUDA Releases:** Prebuilt `llama.cpp` Ubuntu CUDA tarballs do not bundle `libcudart.so.12`, `libcublas.so.12`, or `libcublasLt.so.12`. Unless the companion `cudart-llama-*` archive from the same release is extracted into the same directory and added to `LD_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).
|
|
18
|
+
|
|
19
|
+
`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`).
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Hardware & Runtime Specifications
|
|
24
|
+
|
|
25
|
+
Verified live on Kaggle GPU sessions (`machineShape: NvidiaTeslaT4`):
|
|
26
|
+
|
|
27
|
+
| Parameter | Specification |
|
|
28
|
+
| :--- | :--- |
|
|
29
|
+
| **Accelerators** | 2 x NVIDIA Tesla T4 (Compute Capability 7.5, 40 SMs per GPU) |
|
|
30
|
+
| **VRAM** | 2 x 15,360 MiB (30,720 MiB total / 29.12 GiB usable) |
|
|
31
|
+
| **NVIDIA Driver / CUDA** | Driver `580.178.04` / CUDA `13.0` |
|
|
32
|
+
| **Python / PyTorch** | Python `3.13.16` / `torch 2.11.0+cu130` |
|
|
33
|
+
| **Weekly Quota** | ~30 GPU-hours per rolling 7-day window (~15 wall-clock hours on T4 x2) |
|
|
34
|
+
| **Maximum Session Duration** | 12 hours per execution |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
### Using `uv` (Recommended)
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Install CLI (`kaggle-free-gpu` / `kfg`) and MCP server (`kaggle-free-gpu-mcp`) globally:
|
|
44
|
+
uv tool install git+https://github.com/ericmaddox/kaggle-free-gpu.git
|
|
45
|
+
|
|
46
|
+
# Or install in a local development checkout:
|
|
47
|
+
git clone https://github.com/ericmaddox/kaggle-free-gpu.git
|
|
48
|
+
cd kaggle-free-gpu
|
|
49
|
+
uv sync --extra dev
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Using `pip`
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install git+https://github.com/ericmaddox/kaggle-free-gpu.git
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Authentication
|
|
61
|
+
|
|
62
|
+
Generate a Kaggle API token at [https://www.kaggle.com/settings](https://www.kaggle.com/settings). Credentials are resolved in the following order and are never logged or written to repository files:
|
|
63
|
+
|
|
64
|
+
1. `KAGGLE_API_TOKEN` environment variable (`Bearer KGAT_...`)
|
|
65
|
+
2. `~/.kaggle/access_token` file (`Bearer KGAT_...`)
|
|
66
|
+
3. `KAGGLE_USERNAME` and `KAGGLE_KEY` environment variables (`Basic` auth)
|
|
67
|
+
4. `~/.kaggle/kaggle.json` file (`Basic` auth)
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
mkdir -p ~/.kaggle
|
|
71
|
+
echo "KGAT_your_token_here" > ~/.kaggle/access_token
|
|
72
|
+
chmod 600 ~/.kaggle/access_token
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## MCP Server Configuration
|
|
78
|
+
|
|
79
|
+
Register `kaggle-free-gpu-mcp` in your agent's MCP configuration (`mcp_config.json`, `.mcp.json`, or `claude_desktop_config.json`):
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"mcpServers": {
|
|
84
|
+
"kaggle-free-gpu": {
|
|
85
|
+
"command": "kaggle-free-gpu-mcp",
|
|
86
|
+
"env": {
|
|
87
|
+
"KAGGLE_API_TOKEN": "KGAT_your_token_here"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### MCP Tools Reference
|
|
95
|
+
|
|
96
|
+
| Tool | Signature | Description |
|
|
97
|
+
| :--- | :--- | :--- |
|
|
98
|
+
| `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. |
|
|
99
|
+
| `kernel_status` | `(owner_slug: str)` | Queries `POST /api/v1/kernels.KernelsApiService/GetKernelSessionStatus` and returns `QUEUED`, `RUNNING`, `COMPLETE`, or `ERROR`. |
|
|
100
|
+
| `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. |
|
|
101
|
+
| `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`). |
|
|
102
|
+
| `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. |
|
|
103
|
+
| `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. |
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## CLI Usage (`kfg` / `kaggle-free-gpu`)
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# 1. Estimate remaining rolling 7-day GPU quota
|
|
111
|
+
uv run kfg quota
|
|
112
|
+
|
|
113
|
+
# 2. Validate and push a kernel directory, poll until COMPLETE, and download outputs
|
|
114
|
+
uv run kfg push examples/01_gpu_smoke_test --wait --out-dir outputs/smoke
|
|
115
|
+
|
|
116
|
+
# 3. Check execution status of a kernel
|
|
117
|
+
uv run kfg status <owner>/kfg-gpu-smoke-test
|
|
118
|
+
|
|
119
|
+
# 4. Pull output files and execution logs with a 500 MB per-file safety guard
|
|
120
|
+
uv run kfg output <owner>/kfg-gpu-smoke-test --out-dir outputs/smoke --max-size-mb 500
|
|
121
|
+
|
|
122
|
+
# 5. List your own kernels
|
|
123
|
+
uv run kfg list --mine
|
|
124
|
+
|
|
125
|
+
# 6. Permanently delete a kernel (interactive confirmation or --yes)
|
|
126
|
+
uv run kfg delete <owner>/kfg-gpu-smoke-test
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
> **Note on `<owner>` placeholder resolution:** All `kernel-metadata.json` files in `examples/` use `"id": "<owner>/<slug>"`. `kaggle-free-gpu` automatically resolves `<owner>` from your authenticated Kaggle account at push time.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Benchmarks: CPU vs. Kaggle Tesla T4 x2
|
|
134
|
+
|
|
135
|
+
Measured live on Kaggle (`2 x Tesla T4`, Python `3.13.16`, `torch 2.11.0+cu130`) across the repository's reference workflows:
|
|
136
|
+
|
|
137
|
+
| Workload | CPU Baseline | Kaggle Tesla T4 ($0) | Speedup / Outcome |
|
|
138
|
+
| :--- | :--- | :--- | :--- |
|
|
139
|
+
| **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** |
|
|
140
|
+
| **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** |
|
|
141
|
+
| **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** |
|
|
142
|
+
| **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** |
|
|
143
|
+
|
|
144
|
+
### CLI Execution Transcript
|
|
145
|
+
|
|
146
|
+
```text
|
|
147
|
+
$ uv run kfg push examples/02_qlora_finetune --wait --out-dir outputs/qlora
|
|
148
|
+
+--------------------------- Kaggle Free-GPU Push ----------------------------+
|
|
149
|
+
| Pushed successfully! |
|
|
150
|
+
| Ref: <owner>/kfg-qlora-finetune-demo |
|
|
151
|
+
| Title: KFG QLoRA Finetune Demo |
|
|
152
|
+
| Version: 3 |
|
|
153
|
+
| GPU Enabled: True | Private: True |
|
|
154
|
+
| URL: https://www.kaggle.com/code/<owner>/kfg-qlora-finetune-demo |
|
|
155
|
+
+-----------------------------------------------------------------------------+
|
|
156
|
+
[0s] <owner>/kfg-qlora-finetune-demo -> QUEUED
|
|
157
|
+
[10s] <owner>/kfg-qlora-finetune-demo -> RUNNING
|
|
158
|
+
[50s] <owner>/kfg-qlora-finetune-demo -> COMPLETE
|
|
159
|
+
Output downloaded to: outputs/qlora (runtime: 32.99s)
|
|
160
|
+
+---------------------------------- Stdout -----------------------------------+
|
|
161
|
+
| { |
|
|
162
|
+
| "workflow": "qlora_finetune", |
|
|
163
|
+
| "gpu_name": "Tesla T4", |
|
|
164
|
+
| "gpu_count": 2, |
|
|
165
|
+
| "trainable_lora_params": 1878016, |
|
|
166
|
+
| "frozen_4bit_packed_mb": 38.0, |
|
|
167
|
+
| "steps": 60, |
|
|
168
|
+
| "initial_loss": 8.9066, |
|
|
169
|
+
| "final_loss": 0.0005, |
|
|
170
|
+
| "gpu_train_seconds": 6.436, |
|
|
171
|
+
| "tokens_per_second": 19092.1, |
|
|
172
|
+
| "saved_adapter_file": "lora_adapter.pt" |
|
|
173
|
+
| } |
|
|
174
|
+
| CLEANUP DONE |
|
|
175
|
+
+-----------------------------------------------------------------------------+
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Reference Workflows (`examples/`)
|
|
181
|
+
|
|
182
|
+
- **[`examples/01_gpu_smoke_test`](examples/01_gpu_smoke_test):** Queries `torch.cuda` device properties and `nvidia-smi`, executes an FP16 `4096 x 4096` GEMM across all attached GPUs, and writes `gpu_smoke_report.json`.
|
|
183
|
+
- **[`examples/02_qlora_finetune`](examples/02_qlora_finetune):** Quantizes base transformer linear layers into packed 4-bit `uint8` buffers 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`) and `qlora_metrics.json`, and cleans up `/tmp`.
|
|
184
|
+
- **[`examples/03_inference_bench`](examples/03_inference_bench):** Benchmarks autoregressive transformer token generation across Tesla T4 (`float16`) and CPU (`float32`), and provides `setup_llamacpp_cuda()` for downloading and configuring both the `llama.cpp` CUDA binary tarball and its required `cudart-` companion runtime archive.
|
|
185
|
+
- **[`examples/04_data_processing`](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.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Repository Structure
|
|
190
|
+
|
|
191
|
+
```text
|
|
192
|
+
kaggle-free-gpu/
|
|
193
|
+
├── SKILL.md # Agent skill specification, workflow, and operational rules
|
|
194
|
+
├── pyproject.toml # Hatchling build config, dependencies, and entrypoints
|
|
195
|
+
├── src/
|
|
196
|
+
│ └── kaggle_free_gpu/
|
|
197
|
+
│ ├── __init__.py
|
|
198
|
+
│ ├── client.py # Direct REST & KernelsApiService RPC client
|
|
199
|
+
│ ├── models.py # Pydantic schemas and pre-push metadata validator
|
|
200
|
+
│ ├── quota.py # Local rolling 7-day GPU quota ledger
|
|
201
|
+
│ ├── server.py # FastMCP server exposing the 6 Kaggle GPU tools
|
|
202
|
+
│ └── cli.py # Terminal CLI (`kaggle-free-gpu` / `kfg`)
|
|
203
|
+
├── examples/
|
|
204
|
+
│ ├── 01_gpu_smoke_test/
|
|
205
|
+
│ ├── 02_qlora_finetune/
|
|
206
|
+
│ ├── 03_inference_bench/
|
|
207
|
+
│ └── 04_data_processing/
|
|
208
|
+
├── scripts/
|
|
209
|
+
│ └── validate_live.py # End-to-end live validation suite against Kaggle REST API
|
|
210
|
+
└── tests/
|
|
211
|
+
└── test_client_and_rules.py # Unit tests for slug rules, quota math, and safety guards
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Development & Verification
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# Run unit tests
|
|
220
|
+
uv run pytest -v
|
|
221
|
+
|
|
222
|
+
# Run linter
|
|
223
|
+
uv run ruff check src tests scripts examples
|
|
224
|
+
|
|
225
|
+
# Run live end-to-end GPU validation against Kaggle REST API (requires KAGGLE_API_TOKEN)
|
|
226
|
+
uv run python scripts/validate_live.py
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
MIT License. See [LICENSE](LICENSE).
|