github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/docs/job-specification/resources.mdx (about)

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