Modal: deploy a serverless GPU function

domain: modal.com/docs · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Install the modal package and authenticate with modal setup or by setting the MODAL_TOKEN_ID and MODAL_TOKEN_SECRET environment variables.
  2. Define a Modal App and an Image with the required packages: app = modal.App(); image = modal.Image.debian_slim().pip_install('torch', ...).
  3. Decorate your function with @app.function(gpu='A10G', image=image, timeout=300) to request a GPU instance and specify runtime dependencies.
  4. Inside the function body, write standard Python code; Modal handles containerization, scheduling, and GPU attachment automatically.
  5. Deploy the app with modal deploy script.py for a persistent deployment, or run it ephemerally with modal run script.py during development.
  6. Call the deployed function from any Python environment using the Modal client with the .remote() method on the function handle.

Known gotchas

Related routes

Deploy a serverless GPU inference endpoint on Modal with auto-scaling to zero
modal.com/docs · 6 steps · unrated
Run serverless GPU inference on Modal with auto-scaling to zero for an LLM
modal.com/docs · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans