@resources decorator specifies the compute resources needed for a step, independent of the execution backend (AWS Batch, Kubernetes, etc.).
Basic Usage
Description
The@resources decorator allows you to specify compute requirements separately from the execution backend. This makes it easy to switch between AWS Batch, Kubernetes, or other compute layers without changing your resource specifications.
When combined with @batch or @kubernetes, the maximum value from all decorators is used for each resource.
Parameters
Number of CPUs required for this step.
Memory size (in MB) required for this step.
Number of GPUs required for this step.
Disk size (in MB) required for this step. Only applies on Kubernetes.
The value for the size (in MiB) of the /dev/shm volume for this step. This parameter maps to the
--shm-size option in Docker.Examples
Basic Resource Specification
GPU-Accelerated Step
With Shared Memory
Backend-Agnostic Workflow
Combining with @batch or @kubernetes
When used with@batch or @kubernetes, the maximum value wins:
Runtime Override
Override resource values at runtime:Best Practices
- Start small: Begin with conservative resource allocations and scale up as needed
- Monitor usage: Use cloud provider dashboards to see actual resource utilization
- Backend agnostic: Use
@resourcesfor portability across compute platforms - GPU considerations: Only request GPUs when you have GPU-accelerated code
