Skip to main content

Resources

Resources such as CPU, Memory, and GPU that can be allocated to a task.

Attributes

AttributeTypeDescription
cpuUnion[CPUBaseType, Tuple[CPUBaseType, CPUBaseType], None] = nullCPU allocation which accepts integer/float cores, Kubernetes-style strings like "500m", or a request/limit tuple.
memoryUnion[str, Tuple[str, str], None] = nullMemory allocation using Kubernetes unit conventions such as binary units ("1Gi"), decimal units ("1G"), or a request/limit tuple.
gpuUnion[Accelerators, int, [Device](device.md?sid=flyte__resources_device), None] = nullGPU, TPU, or other accelerator allocation specified as a count, a type/quantity string, or a Device configuration object.
diskUnion[str, None] = nullEphemeral disk storage as a string with Kubernetes units that is automatically cleaned up when the task completes.
shmUnion[str, Literal["auto"], None] = nullShared 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

NameTypeDescription
cpuUnion[int, float, str, tuple] = NoneCPU allocation. Supports cores as int/float, Kubernetes-style strings (e.g., '500m'), or a (request, limit) tuple.
memoryUnion[str, tuple] = NoneMemory allocation using Kubernetes units (e.g., '1Gi', '512Mi') or a (request, limit) tuple.
gpuUnion[int, str, [Device](device.md?sid=flyte__resources_device)] = NoneAccelerator allocation. Supports GPU count (int), type and quantity strings (e.g., 'T4:1'), or advanced Device/TPU objects.
diskstr = NoneEphemeral disk storage size with Kubernetes units (e.g., '10Gi').
shmUnion[str, Literal['auto']] = NoneShared 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

TypeDescription
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

TypeDescription
Optional[str]The shared memory string.