Resources
Resources such as CPU, Memory, and GPU that can be allocated to a task.
Attributes
| Attribute | Type | Description |
|---|---|---|
| cpu | Union[CPUBaseType, Tuple[CPUBaseType, CPUBaseType], None] = null | CPU allocation which accepts integer/float cores, Kubernetes-style strings like "500m", or a request/limit tuple. |
| memory | Union[str, Tuple[str, str], None] = null | Memory allocation using Kubernetes unit conventions such as binary units ("1Gi"), decimal units ("1G"), or a request/limit tuple. |
| gpu | Union[Accelerators, int, [Device](device.md?sid=flyte__resources_device), None] = null | GPU, TPU, or other accelerator allocation specified as a count, a type/quantity string, or a Device configuration object. |
| disk | Union[str, None] = null | Ephemeral disk storage as a string with Kubernetes units that is automatically cleaned up when the task completes. |
| shm | Union[str, Literal["auto"], None] = null | Shared memory (/dev/shm) allocation for ML data loading, accepting specific unit strings or "auto" for maximum available node memory. |
Constructor
Signature
def Resources(
cpu: Union[int, float, str, tuple] = None,
memory: Union[str, tuple] = None,
gpu: Union[int, str, [Device](device.md?sid=flyte__resources_device)] = None,
disk: str = None,
shm: Union[str, Literal['auto']] = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| cpu | Union[int, float, str, tuple] = None | CPU allocation. Supports cores as int/float, Kubernetes-style strings (e.g., '500m'), or a (request, limit) tuple. |
| memory | Union[str, tuple] = None | Memory allocation using Kubernetes units (e.g., '1Gi', '512Mi') or a (request, limit) tuple. |
| gpu | Union[int, str, [Device](device.md?sid=flyte__resources_device)] = None | Accelerator allocation. Supports GPU count (int), type and quantity strings (e.g., 'T4:1'), or advanced Device/TPU objects. |
| disk | str = None | Ephemeral disk storage size with Kubernetes units (e.g., '10Gi'). |
| shm | Union[str, Literal['auto']] = None | Shared memory allocation size or 'auto' to use maximum available node memory. |
Methods
get_device()
@classmethod
def get_device() - > Optional[[Device](device.md?sid=flyte__resources_device)]
Get the accelerator string for the task.
Returns
| Type | Description |
|---|---|
Optional[[Device](device.md?sid=flyte__resources_device)] | If GPUs are requested, return a tuple of the device name, and potentially a partition string. |
get_shared_memory()
@classmethod
def get_shared_memory() - > Optional[str]
Get the shared memory string for the task.
Returns
| Type | Description |
|---|---|
Optional[str] | The shared memory string. |