Reserving CPU and memory
Modal jobs are reserved 100 MiB of memory and 0.1 CPU cores by default. However, if there is free memory or CPU capacity on a worker, containers are free to go above the limit.
If you have code that you want to ensure receives a larger minimum number of
cores, you can request it using the
cpu argument. This expects a float number
of CPU cores:
import modal stub = modal.Stub() def my_function(): # code here will have access to at least 2.0 cores ...
If you have code that needs more guaranteed memory, you can request it using the
memory argument. This expects an integer number of megabytes:
import modal stub = modal.Stub() def my_function(): # code here will have access to at least 2048 MiB ...
How much can I request?
For both CPU and memory, a maximum is enforced at function creation time to
ensure your application can be scheduled for execution. Requests exceeding the
maximum will be rejected with an
plan to support large larger requests in the future.
We currently don’t support setting a hard limit on the resource usage of a function. But we do plan to add this feature so that users have more control over the resource consumption of their Modal applications.