github.com/ferranbt/nomad@v0.9.3-0.20190607002617-85c449b7667c/website/source/docs/job-specification/resources.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "resources Stanza - Job Specification" 4 sidebar_current: "docs-job-specification-resources" 5 description: |- 6 The "resources" stanza describes the requirements a task needs to execute. 7 Resource requirements include memory, network, cpu, and more. 8 --- 9 10 # `resources` Stanza 11 12 <table class="table table-bordered table-striped"> 13 <tr> 14 <th width="120">Placement</th> 15 <td> 16 <code>job -> group -> task -> **resources**</code> 17 </td> 18 </tr> 19 </table> 20 21 The `resources` stanza describes the requirements a task needs to execute. 22 Resource requirements include memory, network, CPU, and more. 23 24 ```hcl 25 job "docs" { 26 group "example" { 27 task "server" { 28 resources { 29 cpu = 100 30 memory = 256 31 32 network { 33 mbits = 100 34 port "http" {} 35 port "ssh" { 36 static = 22 37 } 38 } 39 40 device "nvidia/gpu" { 41 count = 2 42 } 43 } 44 } 45 } 46 } 47 ``` 48 49 ## `resources` Parameters 50 51 - `cpu` `(int: 100)` - Specifies the CPU required to run this task in MHz. 52 53 - `memory` `(int: 300)` - Specifies the memory required in MB 54 55 - `network` <code>([Network][]: <optional>)</code> - Specifies the network 56 requirements, including static and dynamic port allocations. 57 58 - `device` <code>([Device][]: <optional>)</code> - Specifies the device 59 requirements. This may be repeated to request multiple device types. 60 61 ## `resources` Examples 62 63 The following examples only show the `resources` stanzas. Remember that the 64 `resources` stanza is only valid in the placements listed above. 65 66 ### Memory 67 68 This example specifies the task requires 2 GB of RAM to operate. 2 GB is the 69 equivalent of 2000 MB: 70 71 ```hcl 72 resources { 73 memory = 2000 74 } 75 ``` 76 77 ### Network 78 79 This example shows network constraints as specified in the [network][] stanza 80 which require 1 Gbit of bandwidth, dynamically allocates two ports, and 81 statically allocates one port: 82 83 ```hcl 84 resources { 85 network { 86 mbits = 1000 87 port "http" {} 88 port "https" {} 89 port "lb" { 90 static = "8889" 91 } 92 } 93 } 94 ``` 95 96 ### Devices 97 98 This example shows a device constraints as specified in the [device][] stanza 99 which require two nvidia GPUs to be made available: 100 101 ```hcl 102 resources { 103 device "nvidia/gpu" { 104 count = 2 105 } 106 } 107 ``` 108 109 [network]: /docs/job-specification/network.html "Nomad network Job Specification" 110 [device]: /docs/job-specification/device.html "Nomad device Job Specification"