Requesting more CPU (beta)

Modal jobs are guaranteed 0.25 CPU cores by default. However, if there is free CPU capacity on a worker, containers can use more than their allocated amount.

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 2.0 cores, at least

How many CPU cores can I request?

CPU requests are a beta feature. 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 InvalidError. We plan to support large CPU requests in the future.