本文へスキップ
Skillpedia
デプロイとクラウド(DevOps)33k · #8981

modal

できること

このスキルは、あなたのエージェントにModalの使い方を教えます。Modalは、クラウドのマシンでPythonのコードを実行するサーバーレスのプラットフォームです。サーバーを管理せずにGPUや大規模なバッチ処理を必要とする開発者とデータチームが対象です。

使う場面

  • ✓クラウドのGPUで機械学習モデルを動かす必要があるとき。
  • ✓大規模なデータセットを、多数のコンテナで並列に処理したいとき。
  • ✓定期的な計算ジョブを予約したり、簡単なAPIをデプロイしたりしたいとき。

スキルのリンク

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/scientific/modal/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/scientific/modal/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“このPython関数をGPU付きのModalにデプロイし、画像を送ると予測結果を受け取れるようにしてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、あなたのPythonコードにModalのデコレーターを追加し、ハードウェアとコンテナの設定を行って、実行またはデプロイします。Modalは必要に応じてマシンを起動し、需要に合わせて拡張します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Modal

Overview

Modal is a serverless platform for running Python code in the cloud with minimal configuration. Execute functions on powerful GPUs, scale automatically to thousands of containers, and pay only for compute used.

Modal is particularly suited for AI/ML workloads, high-performance batch processing, scheduled jobs, GPU inference, and serverless APIs. Sign up for free at https://modal.com and receive $30/month in credits.

When to Use This Skill

Use Modal for:

  • Deploying and serving ML models (LLMs, image generation, embedding models)
  • Running GPU-accelerated computation (training, inference, rendering)
  • Batch processing large datasets in parallel
  • Scheduling compute-intensive jobs (daily data processing, model training)
  • Building serverless APIs that need automatic scaling
  • Scientific computing requiring distributed compute or specialized hardware

Authentication and Setup

Modal requires authentication via API token.

Initial Setup

# Install Modal
uv uv pip install modal

# Authenticate (opens browser for login)
modal token new

This creates a token stored in ~/.modal.toml. The token authenticates all Modal operations.

Verify Setup

import modal

app = modal.App("test-app")

@app.function()
def hello():
    print("Modal is working!")

Run with: modal run script.py

Core Capabilities

Modal provides serverless Python execution through Functions that run in containers. Define compute requirements, dependencies, and scaling behavior declaratively.

1. Define Container Images

Specify dependencies and environment for functions using Modal Images.

import modal

# Basic image with Python packages
image = (
    modal.Image.debian_slim(python_version="3.12")
    .uv_pip_install("torch", "transformers", "numpy")
)

app = modal.App("ml-app", image=image)

Common patterns:

  • Install Python packages: .uv_pip_install("pandas", "scikit-learn")
  • Install system packages: .apt_install("ffmpeg", "git")
  • Use existing Docker images: modal.Image.from_registry("nvidia/cuda:12.1.0-base")
  • Add local code: .add_local_python_source("my_module")

See references/images.md for comprehensive image building documentation.

2. Create Functions

Define functions that run in the cloud with the @app.function() decorator.

@app.function()
def process_data(file_path: str):
    import pandas as pd
    df = pd.read_csv(file_path)
    return df.describe()

Call functions:

# From local entrypoint
@app.local_entrypoint()
def main():
    result = process_data.remote("data.csv")
    print(result)

Run with: modal run script.py

See references/functions.md for function patterns, deployment, and parameter handling.

3. Request GPUs

Attach GPUs to functions for accelerated computation.

@app.function(gpu="H100")
def train_model():
    import torch
    assert torch.cuda.is_available()
    # GPU-accelerated code here

Available GPU types:

  • T4, L4 - Cost-effective inference
  • A10, A100, A100-80GB - Standard training/inference
  • L40S - Excellent cost/performance balance (48GB)
  • H100, H200 - High-performance training
  • B200 - Flagship performance (most powerful)

Request multiple GPUs:

@app.function(gpu="H100:8")  # 8x H100 GPUs
def train_large_model():
    pass

See references/gpu.md for GPU selection guidance, CUDA setup, and multi-GPU configuration.

4. Configure Resources

Request CPU cores, memory, and disk for functions.

@app.function(
    cpu=8.0,           # 8 physical cores
    memory=32768,      # 32 GiB RAM
    ephemeral_disk=10240  # 10 GiB disk
)
def memory_intensive_task():
    pass

Default allocation: 0.125 CPU cores, 128 MiB memory. Billing based on reservation or actual usage, whichever is higher.

See references/resources.md for resource limits and billing details.

5. Scale Automatically

Modal autoscales functions from zero to thousands of containers based on demand.

Process inputs in parallel:

@app.function()
def analyze_sample(sample_id: int):
    # Process single sample
    return result

@app.local_entrypoint()
def main():
    sample_ids = range(1000)
    # Automatically parallelized across containers
    results = list(analyze_sample.map(sample_ids))

Configure autoscaling:

@app.function(
    max_containers=100,      # Upper limit
    min_containers=2,        # Keep warm
  
よくある質問

アカウントの設定は必要ですか?

はい。スキルでは、modal tokenコマンドで作成したModal APIトークンで認証すると説明されています。

使っていない時間にも料金がかかりますか?

いいえ。スキルでは、使用した計算リソースの分だけ支払うと説明されています。

GPUを使えますか?

はい。スキルは、学習や推論などのGPUを活用する作業向けに設計されています。

詳細

作者による元の説明

Run Python code in the cloud with serverless containers, GPUs, and autoscaling. Use when deploying ML models, running batch processing jobs, scheduling compute-intensive tasks, or serving APIs that require GPU acceleration or dynamic scaling.

repo: davila7/claude-code-templates

人気

GitHubのスター
33k
ランキング
#8981
ライセンス
MIT
更新日
2026/11/2

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル