# Task hardware environment

## Customizing task resources

You can customize the hardware environment in which your task code executes.

Depending on your needs, there are two different of ways to define and register tasks with their own custom hardware requirements:

* Configuration in the `@union.task` decorator
* Defining a `PodTemplate`

### Using the `@union.task` decorator

You can specify `requests` and `limits` on:

* CPU number
* GPU number
* Memory size
* Ephemeral storage size

See [Customizing task resources](https://www.union.ai/docs/v1/union/user-guide/core-concepts/tasks/task-hardware-environment/customizing-task-resources/page.md) for details.

### Using PodTemplate

If your needs are more complex, you can use Kubernetes-level configuration to constrain a task to only run on a specific machine type.

This requires that you coordinate with Union.ai to set up the required machine types and node groups with the appropriate node assignment configuration (node selector labels, node affinities, taints, tolerations, etc.)

In your task definition you then use a `PodTemplate` that uses the matching node assignment configuration to make sure that the task will only be scheduled on the appropriate machine type.

### `pod_template` and `pod_template_name` @union.task parameters

The `pod_template` parameter can be used to supply a custom Kubernetes `PodTemplate` to the task.
This can be used to define details about node selectors, affinity, tolerations, and other Kubernetes-specific settings.

The `pod_template_name` is a related parameter that can be used to specify the name of an already existing `PodTemplate` resource which will be used in this task.

For details see [Configuring task pods with Kubernetes PodTemplates]().
<!-- TODO: Add link to API -->

## Accelerators

If you specify GPUs, you can also specify the type of GPU to be used by setting the `accelerator` parameter.
See [Accelerators](https://www.union.ai/docs/v1/union/user-guide/core-concepts/tasks/task-hardware-environment/accelerators/page.md) for more information.

## Task-level monitoring

You can also monitor the hardware resources used by a task.
See [Task-level monitoring](https://www.union.ai/docs/v1/union/user-guide/core-concepts/tasks/task-hardware-environment/task-level-monitoring/page.md) for details.

## Subpages

- [Customizing task resources](https://www.union.ai/docs/v1/union/user-guide/core-concepts/tasks/task-hardware-environment/customizing-task-resources/page.md)
  - The `requests` and `limits` settings
  - The `accelerator` setting
  - Execution defaults and resource quotas
  - Task resource validation
  - The `with_overrides` method
- [Accelerators](https://www.union.ai/docs/v1/union/user-guide/core-concepts/tasks/task-hardware-environment/accelerators/page.md)
  - Finding your available accelerators
  - Requesting the provisioning of accelerators
  - Using predefined accelerator constants
  - List of predefined accelerator constants
- [Retries and timeouts](https://www.union.ai/docs/v1/union/user-guide/core-concepts/tasks/task-hardware-environment/retries-and-timeouts/page.md)
  - Retry types
  - Configuring retries
  - Retrying interruptible tasks
  - Retrying map tasks
  - Timeouts
- [Interruptible instances](https://www.union.ai/docs/v1/union/user-guide/core-concepts/tasks/task-hardware-environment/interruptible-instances/page.md)
  - Configuring tasks to use interruptible instances
  - Workflow level interruptible
  - Advantages and disadvantages of interruptible instances
- [Task-level monitoring](https://www.union.ai/docs/v1/union/user-guide/core-concepts/tasks/task-hardware-environment/task-level-monitoring/page.md)
  - Execution Resources
  - Memory Quota
  - CPU Cores Quota
  - GPU Memory Utilization
  - GPU Utilization
  - Execution Logs (Preview)
  - Map Tasks

---
**Source**: https://github.com/unionai/unionai-docs/blob/main/content/user-guide/core-concepts/tasks/task-hardware-environment/_index.md
**HTML**: https://www.union.ai/docs/v1/union/user-guide/core-concepts/tasks/task-hardware-environment/
