.. Copyright NTESS. See COPYRIGHT file for details.

   SPDX-License-Identifier: MIT

.. _tutorial-resource-defn:

Defining the resource pool
==========================

The resource pool can be specified on the command line by simply defining the number of each resource type.  For example, resource pool having the default CPU count (as determined by ``canary``) and 4 GPUs, can be generated by

.. command-output:: canary -c resource_pool:gpus:4 config show resource_pool
    :nocache:

The resource pool can also be defined in the ``resource_pool`` section of the configuration file:

.. code-block:: yaml

  resource_pool:
    cpus: 10
    gpus: 4

which will expand to

.. code-block:: yaml

  resource_pool:
    resources:
      cpus:
      - id: "0"
        slots: 1
      - id: "1"
        slots: 1
      ...
      - id: "9"
        slots: 1
      gpus:
      - id: "0"
        slots: 1
      - id: "1"
        slots: 1
      - id: "2"
        slots: 1
      - id: "3"
        slots: 1

To define more complex resource pool specifications, for example if each GPU has 2 available slots, define the ``resource_pool`` explicitly:

.. code-block:: yaml

    resource_pool:
      resources:
        gpus:
        - id: "0"
          slots: 2
        - id: "1"
          slots: 2
        - id: "2"
          slots: 2
        - id: "3"
          slots: 2
