colab_execute_notebook
Run Python code on Google Colab with GPU/TPU acceleration. Collects generated files (images, CSVs, models) by zipping and downloading them to a local directory.
Instructions
Execute Python code on Colab GPU/TPU and collect generated artifacts.
Runs the code, then scans the runtime for output files (images, CSVs, models, etc.), zips them, and downloads to a local directory. Use this when your code produces files you need to retrieve locally.
After execution:
Check artifact_files in the response for collected output filenames.
Files are extracted to the specified output_dir.
For files larger than 50 MB, use colab_execute with drive_save instead.
Common issues:
No artifacts collected: ensure your code writes files to /tmp, /content, or the current working directory.
Each artifact file must be under 50 MB (base64 transfer limit).
Args: code: Python code to execute on the Colab runtime. output_dir: Local directory to save the artifacts zip and extracted files. accelerator: Hardware accelerator type. Default: "T4". GPU types: "T4" - NVIDIA Tesla T4 (16 GB, free-tier) "L4" - NVIDIA L4 (24 GB, Colab Pro) "A100" - NVIDIA A100 (40 GB, Colab Pro/Pro+) "H100" - NVIDIA H100 (80 GB, Colab Pro+) "G4" - NVIDIA G4 (Colab Pro+) TPU types: "V5E1" - TPU v5e-1 (Colab Pro+) "V6E1" - TPU v6e-1 (Colab Pro+) high_memory: Enable high-memory runtime (more RAM). Default: False. timeout: Max execution time in seconds (10-3600). Default: 300.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| timeout | No | ||
| output_dir | Yes | ||
| accelerator | No | T4 | |
| high_memory | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |