Frank Shen
11/15/2022, 12:14 AMSamhita Alla
Resources
? You should request for resources in the task decorator: https://docs.flyte.org/projects/cookbook/en/latest/auto/deployment/customizing_resources.html.Frank Shen
11/15/2022, 5:49 PMSamhita Alla
requests
as an argument: https://github.com/flyteorg/flytekit/blob/07299d0b0e8d172e33ad48d719f9014effb5d96b/flytekit/core/python_auto_container.py#L37.Frank Shen
11/15/2022, 5:56 PM@task
def get_xgb_task_resource_request(df: pd.DataFrame) -> Resources:
_Gibibyte = 1073741824
data_size_gb = df.memory_usage(index=True, deep=True).sum() // _Gibibyte
# request more memory for the task if the dataset size is >= 2 GB, because the default task mem alloc might not be enough.
resource_requests = Resources(mem=f'{data_size_gb}Gi') if data_size_gb >= 2 else None
return resource_requests
Samhita Alla
PythonInstanceTask
and requested resources in the execute()
method? Would you mind sharing the coding snippet?Frank Shen
11/16/2022, 5:18 PM_Gibibyte = 1073741824
data_size_gb = (train_size + validation_size) / _Gibibyte
"""
Dynamically request task memory in GB + 0.1 GB buffer for the task (to 3 decimals),
because the default task memory allocation might not be enough for big dataset
"""
self.resources.requests = Resources(mem=f'{round(data_size_gb + 0.1, 3)}Gi')
Samhita Alla
Frank Shen
11/17/2022, 7:56 PMSamhita Alla
Frank Shen
11/18/2022, 5:44 PMSamhita Alla
Frank Shen
11/21/2022, 5:45 PMSamhita Alla
with_overrides
https://docs.flyte.org/projects/cookbook/en/latest/auto/deployment/customizing_resources.html#using-with-overrides?Frank Shen
11/22/2022, 5:45 AMSamhita Alla
with_overrides()
should work with PythonInstanceTask class. Also regarding real-time resource calculation, I’m not sure how that can be done. I’ll defer to Kevin/Eduardo to answer.Eduardo Apolinario (eapolinario)
11/22/2022, 6:49 PM@task
def t(a: int):
...
@dynamic
def dyn(a: int):
t(a=a).with_overrides(
requests=Resources(mem="432Mi"),
limits=Resources(mem="543Mi"),
)