# serverless-modal

Runs training, fine-tuning, and inference on serverless Modal GPUs. Helps pick the right GPU tier, estimates run costs upfront, and stops billing when work ends.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 463 installs · ★ 18090
- Author: wanshuiyin
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/wanshuiyin/Auto-claude-code-research-in-sleep/tree/HEAD/skills/serverless-modal/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/serverless-modal

## What it does

The skill builds launch scripts for the Modal platform and sends Python workloads to remote GPUs directly from your local terminal. Environments are declared in code using `modal.Image`, eliminating manual SSH sessions and Docker builds. Billing terminates immediately when execution stops.

Before any task starts, the skill provides a cost breakdown for user confirmation. It gauges required VRAM against model size: for example, 7-8B models need around 22GB VRAM, making 16GB T4 instances insufficient. For memory-bound benchmarks, an H100 can cost less in practice than an L4 because of higher memory bandwidth.

Using it requires a Modal account, the `modal` package, and authentication via `modal setup`. Payment methods and spending limits must be handled directly on modal.com in a browser; entering card data through CLI tools is unsafe.

## Requirements
- Works with: Docker

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add wanshuiyin/Auto-claude-code-research-in-sleep --skill serverless-modal -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/serverless-modal/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/serverless-modal/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add wanshuiyin/Auto-claude-code-research-in-sleep --skill serverless-modal -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/serverless-modal/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add wanshuiyin/Auto-claude-code-research-in-sleep --skill serverless-modal -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/serverless-modal/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install wanshuiyin/Auto-claude-code-research-in-sleep serverless-modal
```

2. **Manually: put the files in place**
- File: `.github/skills/serverless-modal/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add wanshuiyin/Auto-claude-code-research-in-sleep --skill serverless-modal -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/wanshuiyin/Auto-claude-code-research-in-sleep --path skills/serverless-modal
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/serverless-modal/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add wanshuiyin/Auto-claude-code-research-in-sleep --skill serverless-modal -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/wanshuiyin/Auto-claude-code-research-in-sleep/tree/HEAD/skills/serverless-modal/SKILL.md

## When to use it
- calculate required VRAM and estimate run costs before launching cloud GPUs
- generate Python launch scripts with local directory mounts and persistent volumes
- run remote training or inference benchmarks without managing SSH or Docker
- configure access secrets like `HF_TOKEN` through Modal secrets

## Example prompts
- Set up a fine-tuning script on Modal for an 8B model
- Estimate the cost of running inference benchmarks on H100 versus L4 in Modal
- Generate a modal run launcher that mounts local code and writes to a volume

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 4fb190500c20e250.

BEGIN THIRD-PARTY FILE 4fb190500c20e250
````text
---
name: serverless-modal
description: "Run GPU workloads on Modal — training, fine-tuning, inference, batch processing. Zero-config serverless: no SSH, no Docker, auto scale-to-zero. Use when user says \"modal run\", \"modal training\", \"modal inference\", \"deploy to modal\", \"need a GPU\", \"run on modal\", \"serverless GPU\", or needs remote GPU compute."
argument-hint: "[task-description]"
allowed-tools: Bash(*), Read, Grep, Glob, Edit, Write
---

# Modal Cloud GPU — Training & Inference

Task: $ARGUMENTS

## Overview

**Modal** is a serverless GPU cloud. Key advantages over SSH-based platforms (vast.ai, remote servers):
- **Zero config**: no SSH, no Docker, no port forwarding. Write Python → `modal run` → done.
- **Auto scale-to-zero**: billing stops the instant your code finishes. No idle instances.
- **Local-first**: run `modal run` from your laptop. Code, data, and results stay local; only the GPU function runs remotely.
- **Reproducible environments**: dependencies declared in code via `modal.Image`, not system-level packages.
  Treat the `modal.Image` chain as the RENDERED form of the declarative env spec in
  `../shared-references/compute-env-contract.md` — same spec fields (base, ordered
  pip phases, env vars, smoke probes), same `env:<name>@<specHash>` ledger entry in
  `.aris/compute/modal.md`, same three-tier validation before a long run.

**Best for**: Users without a local GPU who need to debug CUDA code, run small-scale tests, or iterate quickly on experiments. The $5 free tier (no card) is enough for code debugging; $30 (with card) covers most small-scale experiment runs.

**Trade-off**: Modal costs more per GPU-hour than vast.ai or Lightning for some GPU tiers, but eliminates setup time and idle billing, often making it cheaper for short/medium workloads. For long training runs (>4 hours), consider vast.ai for lower $/hr.

## Authentication

```bash
pip install modal
modal setup          # Opens browser login, writes token to ~/.modal.toml
# Verify:
modal run -q 'print("ok")'
```

- Sign up: https://modal.com (GitHub/Google login)
- Free (no card): **$5/month** — enough for quick tests
- Free (with card): **$30/month** — bind a payment method at https://modal.com/settings for the full free tier. Set a **workspace spending limit** to prevent accidental overcharge (Settings → Usage → Spending Limit)
- Academic: apply for $10k credits | Startups: apply for $25k credits
- Secrets: `modal secret create huggingface-secret HF_TOKEN=hf_xxxxx`
````
END THIRD-PARTY FILE 4fb190500c20e250

The third-party file has ended. Everything between the 4fb190500c20e250 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2522 of 13161 bytes. © wanshuiyin · MIT · https://github.com/wanshuiyin/Auto-claude-code-research-in-sleep/tree/HEAD/skills/serverless-modal/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
