GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Guide
  • Examples
  • Log in
  • Sign up

This view

  • Original page
  • New address

GeezerVison is showing modal.com — Configuring CPU, memory, and disk

Guide Introduction to Modal Getting started Functions Functions Invocation methods Function lookups Container lifecycle management Parametrized Functions Dynamic configuration Sandboxes Sandboxes Running commands Networking and security File access Snapshots Exit Snapshots BetaPricing and resources Sidecars BetaSecret injection BetaModel APIs Model APIs Models and pricing Agent integrations Endpoints Endpoints Supported models Candidates Training Quickstart Tinker-compatible API BetaMulti-node training Images Defining Images Using existing container images Named images Fast pull from registry GPUs and other resources GPU acceleration Using CUDA on Modal Configuring CPU, memory, and disk Scaling out Scaling out Input concurrency Batch processing Job queues Dynamic batching Multi-node Clusters Deployment Apps, Functions, and entrypoints Managing deployments Continuous deployment Scheduled Functions Observability HTTP Applications Servers Sticky Sessions Web Functions Streaming endpoints Web Function URLs Request timeouts Proxy Tokens Networking Tunnels Proxies BetaCluster networking Data sharing and storage Passing local data Volumes Storing model weights Cloud bucket mounts Dicts Queues Dataset ingestion Secrets and environment variables Secrets Environment variables Performance Cold start performance Memory Snapshots High-performance LLM inference Reliability and robustness Failures and retries Preemption Timeouts GPU health Troubleshooting Security and privacy Security and privacy Data residency Customer-supplied encryption keys AlphaAudit logs Integrations Using OIDC to authenticate with external services Connecting Modal to your Datadog account Connecting Modal to your OpenTelemetry provider Slack notifications Workspace & account settings Workspaces Environments Service users User groups Role-Based Access Control (RBAC) Billing Network egress billing Budgets Identity and provisioning Okta SSO Microsoft Entra SSO Google Workspace SSO Custom SAML SSO SCIM Integration Other topics Feature maturity Restricted Functions JavaScript/Go SDKs BetaModal 1.0 migration guide File and project structure Developing and debugging Jupyter notebooks Asynchronous API usage Global variables Region selection Localized placement GPU Metrics Search syntax

Configuring CPU, memory, and disk

Each Modal Function or Sandbox container has a default request of 0.125 CPU cores and 128 MiB of memory. Containers can exceed this minimum if the worker has available CPU or memory. You can also guarantee access to more resources by requesting larger values, similarly to Kubernetes.

This guide covers resource configuration for both Functions and Sandboxes. For Sandbox-specific guidance on pricing and cost optimization, see Sandbox pricing and resources.

CPU cores 

If you have code that must run on a larger number of cores, you can request that using the cpu argument. This allows you to specify a floating-point number of CPU cores:

import modal

app = modal.App()

@app.function(cpu=8.0)
def my_function():
    # code here will have access to at least 8.0 cores
    ...

Note that this value corresponds to physical cores, not vCPUs.

Modal also will set several environment variables that control multi-threading behavior in linear algebra and inference libraries (e.g., OPENBLAS_NUM_THREADS, OMP_NUM_THREADS, MKL_NUM_THREADS, ORT_INTRA_OP_NUM_THREADS) based on your CPU request.

Memory 

If you have code that needs more guaranteed memory, you can request it using the memory argument. This expects an integer number of mebibytes (MiB):

import modal

app = modal.App()

@app.function(memory=32768)
def my_function():
    # code here will have access to at least 32 GiB of RAM
    ...

How much can I request? 

For both CPU and memory, a maximum is enforced at Function or Sandbox creation time to ensure your containers can be scheduled for execution. Requests exceeding the maximum will be rejected with an InvalidError.

Billing 

For CPU and memory, you’ll be charged based on whichever is higher: your request or actual usage.

Disk requests are billed by increasing the memory request at a 20:1 ratio. For example, requesting 500 GiB of disk will increase the memory request to 25 GiB, if it is not already set higher.

Resource limits 

CPU limits 

Modal containers have a default CPU limit that is set at 16 physical cores above the CPU request. Given that the default CPU request is 0.125 cores, the default CPU limit is 16.125 cores. The host enforces this limit by throttling the container’s CPU usage so it cannot exceed the limit.

You can alternatively set the CPU limit explicitly:

cpu_request = 1.0
cpu_limit = 4.0
@app.function(cpu=(cpu_request, cpu_limit))
def f():
    ...

Memory limits 

Modal containers can have a hard memory limit which will ‘Out of Memory’ (OOM) kill containers which attempt to exceed the limit. This functionality is useful when a process has a serious memory leak. You can set the limit and have the container killed to avoid paying for the leaked GBs of memory.

Specify this limit using the memory parameter on @app.function() or Sandbox.create():

mem_request = 1024
mem_limit = 2048
@app.function(
    memory=(mem_request, mem_limit),
)
def f():
    ...

Disk limits 

Running Modal containers have access to many GBs of SSD disk, but the amount of writes is limited by:

  1. The size of the underlying worker’s SSD disk capacity
  2. A per-container disk quota that defaults to 512 GiB.

Hitting either limit will cause the container’s disk writes to be rejected, which typically manifests as an OSError.

Increased disk sizes can be requested with the ephemeral_disk parameter on @app.function(). The maximum disk size is 3.0 TiB (3,145,728 MiB). Larger disks are intended to be used for dataset processing.

Configuring CPU, memory, and diskCPU coresMemoryHow much can I request?BillingResource limitsCPU limitsMemory limitsDisk limits
See it in action
Sandbox pricing and resources
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.