rllib/agents/trainer_config.py
def resources(
        self,
        *,
        num_gpus: Optional[Union[float, int]] = None,
        _fake_gpus: Optional[bool] = None,
        num_cpus_per_worker: Optional[int] = None,
        num_gpus_per_worker: Optional[Union[float, int]] = None,
        num_cpus_for_local_worker: Optional[int] = None,
        custom_resources_per_worker: Optional[dict] = None,
        placement_strategy: Optional[str] = None,
    ) -> "TrainerConfig":
        """Specifies resources allocated for a Trainer and its ray actors/workers.

        Args:
            num_gpus: Number of GPUs to allocate to the trainer process.
                Note that not all algorithms can take advantage of trainer GPUs.
                Support for multi-GPU is currently only available for
                tf-[PPO/IMPALA/DQN/PG]. This can be fractional (e.g., 0.3 GPUs).
            _fake_gpus: Set to True for debugging (multi-)?GPU funcitonality on a
                CPU machine. GPU towers will be simulated by graphs located on
                CPUs in this case. Use `num_gpus` to test for different numbers of
                fake GPUs.
            num_cpus_per_worker: Number of CPUs to allocate per worker.
            num_gpus_per_worker: Number of GPUs to allocate per worker. This can be
                fractional. This is usually needed only if your env itself requires a
                GPU (i.e., it is a GPU-intensive video game), or model inference is
                unusually expensive.
            custom_resources_per_worker: Any custom Ray resources to allocate per
                worker.
            num_cpus_for_local_worker: Number of CPUs to allocate for the trainer.
                Note: this only takes effect when running in Tune. Otherwise,
                the trainer runs in the main program (driver).
            custom_resources_per_worker: Any custom Ray resources to allocate per
                worker.
            placement_strategy: The strategy for the placement group factory returned by
                `Trainer.default_resource_request()`. A PlacementGroup defines, which
                devices (resources) should always be co-located on the same node.
                For example, a Trainer with 2 rollout workers, running with
                num_gpus=1 will request a placement group with the bundles:
                [{"gpu": 1, "cpu": 1}, {"cpu": 1}, {"cpu": 1}], where the first bundle
                is for the driver and the other 2 bundles are for the two workers.
                These bundles can now be "placed" on the same or different
                nodes depending on the value of `placement_strategy`:
                "PACK": Packs bundles into as few nodes as possible.
                "SPREAD": Places bundles across distinct nodes as even as possible.
                "STRICT_PACK": Packs bundles into one node. The group is not allowed
                    to span multiple nodes.
                "STRICT_SPREAD": Packs bundles across distinct nodes.

        Returns:
            This updated TrainerConfig object.
        """
        if num_gpus is not None:
            self.num_gpus = num_gpus
        if _fake_gpus is not None:
            self._fake_gpus = _fake_gpus
        if num_cpus_per_worker is not None:
            self.num_cpus_per_worker = num_cpus_per_worker
        if num_gpus_per_worker is not None:
            self.num_gpus_per_worker = num_gpus_per_worker
        if num_cpus_for_local_worker is not None:
            self.num_cpus_for_local_worker = num_cpus_for_local_worker
        if custom_resources_per_worker is not None:
            self.custom_resources_per_worker = custom_resources_per_worker
        if placement_strategy is not None:
            self.placement_strategy = placement_strategy

        return self
Specifies resources allocated for a Trainer and its ray actors/workers.

        Args:
            num_gpus: Number of GPUs to allocate to the trainer process.
                Note that not all algorithms can take advantage of trainer GPUs.
                Support for multi-GPU is currently only available for
                tf-[PPO/IMPALA/DQN/PG]. This can be fractional (e.g., 0.3 GPUs).
            _fake_gpus: Set to True for debugging (multi-)?GPU funcitonality on a
                CPU machine. GPU towers will be simulated by graphs located on
                CPUs in this case. Use `num_gpus` to test for different numbers of
                fake GPUs.
            num_cpus_per_worker: Number of CPUs to allocate per worker.
            num_gpus_per_worker: Number of GPUs to allocate per worker. This can be
                fractional. This is usually needed only if your env itself requires a
                GPU (i.e., it is a GPU-intensive video game), or model inference is
                unusually expensive.
            custom_resources_per_worker: Any custom Ray resources to allocate per
                worker.
            num_cpus_for_local_worker: Number of CPUs to allocate for the trainer.
                Note: this only takes effect when running in Tune. Otherwise,
                the trainer runs in the main program (driver).
            custom_resources_per_worker: Any custom Ray resources to allocate per
                worker.
            placement_strategy: The strategy for the placement group factory returned by
                `Trainer.default_resource_request()`. A PlacementGroup defines, which
                devices (resources) should always be co-located on the same node.
                For example, a Trainer with 2 rollout workers, running with
                num_gpus=1 will request a placement group with the bundles:
                [{"gpu": 1, "cpu": 1}, {"cpu": 1}, {"cpu": 1}], where the first bundle
                is for the driver and the other 2 bundles are for the two workers.
                These bundles can now be "placed" on the same or different
                nodes depending on the value of `placement_strategy`:
                "PACK": Packs bundles into as few nodes as possible.
                "SPREAD": Places bundles across distinct nodes as even as possible.
                "STRICT_PACK": Packs bundles into one node. The group is not allowed
                    to span multiple nodes.
                "STRICT_SPREAD": Packs bundles across distinct nodes.

        Returns:
            This updated TrainerConfig object.
        
Specifies resources allocated for a Trainer and its ray actors/workers.
Specifies resources allocated for a Trainer and its ray actors / workers .
def resources(
        self,
        *,
        num_gpus: Optional[Union[float, int]] = None,
        _fake_gpus: Optional[bool] = None,
        num_cpus_per_worker: Optional[int] = None,
        num_gpus_per_worker: Optional[Union[float, int]] = None,
        num_cpus_for_local_worker: Optional[int] = None,
        custom_resources_per_worker: Optional[dict] = None,
        placement_strategy: Optional[str] = None,
    ) -> "TrainerConfig":
        if num_gpus is not None:
            self.num_gpus = num_gpus
        if _fake_gpus is not None:
            self._fake_gpus = _fake_gpus
        if num_cpus_per_worker is not None:
            self.num_cpus_per_worker = num_cpus_per_worker
        if num_gpus_per_worker is not None:
            self.num_gpus_per_worker = num_gpus_per_worker
        if num_cpus_for_local_worker is not None:
            self.num_cpus_for_local_worker = num_cpus_for_local_worker
        if custom_resources_per_worker is not None:
            self.custom_resources_per_worker = custom_resources_per_worker
        if placement_strategy is not None:
            self.placement_strategy = placement_strategy
        return self
def resources ( self , * , num_gpus : Optional [ Union [ float , int ] ] = None , _fake_gpus : Optional [ bool ] = None , num_cpus_per_worker : Optional [ int ] = None , num_gpus_per_worker : Optional [ Union [ float , int ] ] = None , num_cpus_for_local_worker : Optional [ int ] = None , custom_resources_per_worker : Optional [ dict ] = None , placement_strategy : Optional [ str ] = None , ) -> "TrainerConfig" : if num_gpus is not None : self . num_gpus = num_gpus if _fake_gpus is not None : self . _fake_gpus = _fake_gpus if num_cpus_per_worker is not None : self . num_cpus_per_worker = num_cpus_per_worker if num_gpus_per_worker is not None : self . num_gpus_per_worker = num_gpus_per_worker if num_cpus_for_local_worker is not None : self . num_cpus_for_local_worker = num_cpus_for_local_worker if custom_resources_per_worker is not None : self . custom_resources_per_worker = custom_resources_per_worker if placement_strategy is not None : self . placement_strategy = placement_strategy return self
Specifies resources allocated for a Trainer and its ray actors/workers.
Specifies resources allocated for a Trainer and its ray actors / workers .
"""Specifies resources allocated for a Trainer and its ray actors/workers.

        Args:
            num_gpus: Number of GPUs to allocate to the trainer process.
                Note that not all algorithms can take advantage of trainer GPUs.
                Support for multi-GPU is currently only available for
                tf-[PPO/IMPALA/DQN/PG]. This can be fractional (e.g., 0.3 GPUs).
            _fake_gpus: Set to True for debugging (multi-)?GPU funcitonality on a
                CPU machine. GPU towers will be simulated by graphs located on
                CPUs in this case. Use `num_gpus` to test for different numbers of
                fake GPUs.
            num_cpus_per_worker: Number of CPUs to allocate per worker.
            num_gpus_per_worker: Number of GPUs to allocate per worker. This can be
                fractional. This is usually needed only if your env itself requires a
                GPU (i.e., it is a GPU-intensive video game), or model inference is
                unusually expensive.
            custom_resources_per_worker: Any custom Ray resources to allocate per
                worker.
            num_cpus_for_local_worker: Number of CPUs to allocate for the trainer.
                Note: this only takes effect when running in Tune. Otherwise,
                the trainer runs in the main program (driver).
            custom_resources_per_worker: Any custom Ray resources to allocate per
                worker.
            placement_strategy: The strategy for the placement group factory returned by
                `Trainer.default_resource_request()`. A PlacementGroup defines, which
                devices (resources) should always be co-located on the same node.
                For example, a Trainer with 2 rollout workers, running with
                num_gpus=1 will request a placement group with the bundles:
                [{"gpu": 1, "cpu": 1}, {"cpu": 1}, {"cpu": 1}], where the first bundle
                is for the driver and the other 2 bundles are for the two workers.
                These bundles can now be "placed" on the same or different
                nodes depending on the value of `placement_strategy`:
                "PACK": Packs bundles into as few nodes as possible.
                "SPREAD": Places bundles across distinct nodes as even as possible.
                "STRICT_PACK": Packs bundles into one node. The group is not allowed
                    to span multiple nodes.
                "STRICT_SPREAD": Packs bundles across distinct nodes.

        Returns:
            This updated TrainerConfig object.
        """
This updated TrainerConfig object.
This updated TrainerConfig object .
self
num_gpus
Optional[Union[float, int]]
Number of GPUs to allocate to the trainer process.
Note that not all algorithms can take advantage of trainer GPUs.
Support for multi-GPU is currently only available for
tf-[PPO/IMPALA/DQN/PG]. This can be fractional .
Number of GPUs to allocate to the trainer process . Note that not all algorithms can take advantage of trainer GPUs . Support for multi - GPU is currently only available for tf - [ PPO / IMPALA / DQN / PG ] . This can be fractional .
_fake_gpus
Optional[bool]
Set to True for debugging (multi-)?GPU funcitonality on a
CPU machine. GPU towers will be simulated by graphs located on
CPUs in this case. Use `num_gpus` to test for different numbers of
fake GPUs.
Set to True for debugging ( multi - ) ?GPU funcitonality on a CPU machine . GPU towers will be simulated by graphs located on CPUs in this case . Use ` num_gpus ` to test for different numbers of fake GPUs .
num_cpus_per_worker
Optional[int]
Number of CPUs to allocate per worker.
Number of CPUs to allocate per worker .
num_gpus_per_worker
Optional[Union[float, int]]
Number of GPUs to allocate per worker. This can be
fractional. This is usually needed only if your env itself requires a
GPU , or model inference is
unusually expensive.
Number of GPUs to allocate per worker . This can be fractional . This is usually needed only if your env itself requires a GPU or model inference is unusually expensive .
num_cpus_for_local_worker
Optional[int]
Number of CPUs to allocate for the trainer.
Note: this only takes effect when running in Tune. Otherwise,
the trainer runs in the main program (driver).
Number of CPUs to allocate for the trainer . Note : this only takes effect when running in Tune . Otherwise the trainer runs in the main program ( driver ) .
custom_resources_per_worker
Optional[dict]
Any custom Ray resources to allocate per
worker.
Any custom Ray resources to allocate per worker .
placement_strategy
Optional[str]
The strategy for the placement group factory returned by
`Trainer.default_resource_request()`. A PlacementGroup defines, which
devices (resources) should always be co-located on the same node.
For example, a Trainer with 2 rollout workers, running with
num_gpus=1 will request a placement group with the bundles:
[{"gpu": 1, "cpu": 1}, {"cpu": 1}, {"cpu": 1}], where the first bundle
is for the driver and the other 2 bundles are for the two workers.
These bundles can now be "placed" on the same or different
nodes depending on the value of `placement_strategy`:
"PACK": Packs bundles into as few nodes as possible.
"SPREAD": Places bundles across distinct nodes as even as possible.
"STRICT_PACK": Packs bundles into one node. The group is not allowed
to span multiple nodes.
"STRICT_SPREAD": Packs bundles across distinct nodes.
The strategy for the placement group factory returned by ` Trainer . default_resource_request () ` . A PlacementGroup defines which devices ( resources ) should always be co - located on the same node . For example a Trainer with 2 rollout workers running with num_gpus = 1 will request a placement group with the bundles : [ { " gpu " : 1 " cpu " : 1 } { " cpu " : 1 } { " cpu " : 1 } ] where the first bundle is for the driver and the other 2 bundles are for the two workers . These bundles can now be " placed " on the same or different nodes depending on the value of ` placement_strategy ` : " PACK " : Packs bundles into as few nodes as possible . " SPREAD " : Places bundles across distinct nodes as even as possible . " STRICT_PACK " : Packs bundles into one node . The group is not allowed to span multiple nodes . " STRICT_SPREAD " : Packs bundles across distinct nodes .