본문으로 건너뛰기
Skillpedia
배포 및 클라우드 (DevOps)33k · #8981

modal

하는 일

이 스킬은 에이전트에게 클라우드 머신에서 Python 코드를 실행하는 서버리스 플랫폼 Modal 사용법을 가르칩니다. 서버를 직접 관리하지 않고 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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/scientific/modal/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 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

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬