2016-10-28 00:36:26 +00:00
|
|
|
---
|
2020-02-06 23:45:31 +00:00
|
|
|
layout: docs
|
|
|
|
page_title: resources Stanza - Job Specification
|
|
|
|
sidebar_title: resources
|
2016-10-28 00:36:26 +00:00
|
|
|
description: |-
|
|
|
|
The "resources" stanza describes the requirements a task needs to execute.
|
2020-07-23 13:18:59 +00:00
|
|
|
Resource requirements include memory, cpu, and more.
|
2016-10-28 00:36:26 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# `resources` Stanza
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
<Placement groups={['job', 'group', 'task', 'resources']} />
|
2016-10-28 00:36:26 +00:00
|
|
|
|
|
|
|
The `resources` stanza describes the requirements a task needs to execute.
|
2020-07-23 13:18:59 +00:00
|
|
|
Resource requirements include memory, CPU, and more.
|
2016-10-28 00:36:26 +00:00
|
|
|
|
|
|
|
```hcl
|
|
|
|
job "docs" {
|
|
|
|
group "example" {
|
|
|
|
task "server" {
|
|
|
|
resources {
|
|
|
|
cpu = 100
|
|
|
|
memory = 256
|
|
|
|
|
2019-01-23 00:42:38 +00:00
|
|
|
device "nvidia/gpu" {
|
|
|
|
count = 2
|
|
|
|
}
|
2016-10-28 00:36:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## `resources` Parameters
|
|
|
|
|
|
|
|
- `cpu` `(int: 100)` - Specifies the CPU required to run this task in MHz.
|
|
|
|
|
|
|
|
- `memory` `(int: 300)` - Specifies the memory required in MB
|
|
|
|
|
2019-01-23 00:42:38 +00:00
|
|
|
- `device` <code>([Device][]: <optional>)</code> - Specifies the device
|
|
|
|
requirements. This may be repeated to request multiple device types.
|
|
|
|
|
2016-10-28 00:36:26 +00:00
|
|
|
## `resources` Examples
|
|
|
|
|
|
|
|
The following examples only show the `resources` stanzas. Remember that the
|
2016-10-31 00:41:03 +00:00
|
|
|
`resources` stanza is only valid in the placements listed above.
|
2016-10-28 00:36:26 +00:00
|
|
|
|
|
|
|
### Memory
|
|
|
|
|
2017-07-17 18:41:50 +00:00
|
|
|
This example specifies the task requires 2 GB of RAM to operate. 2 GB is the
|
|
|
|
equivalent of 2000 MB:
|
2016-10-28 00:36:26 +00:00
|
|
|
|
|
|
|
```hcl
|
|
|
|
resources {
|
|
|
|
memory = 2000
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-01-23 00:42:38 +00:00
|
|
|
### Devices
|
|
|
|
|
|
|
|
This example shows a device constraints as specified in the [device][] stanza
|
|
|
|
which require two nvidia GPUs to be made available:
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
resources {
|
|
|
|
device "nvidia/gpu" {
|
|
|
|
count = 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
[device]: /docs/job-specification/device 'Nomad device Job Specification'
|