mirror of
https://github.com/wassname/ray.git
synced 2026-07-25 13:30:52 +08:00
[tune] Tweaks to Trainable and Verbosity (#2889)
This commit is contained in:
@@ -8,6 +8,7 @@ import logging
|
||||
import time
|
||||
import tempfile
|
||||
import os
|
||||
from numbers import Number
|
||||
|
||||
import ray
|
||||
from ray.tune import TuneError
|
||||
@@ -33,12 +34,14 @@ class Resources(
|
||||
namedtuple("Resources", ["cpu", "gpu", "extra_cpu", "extra_gpu"])):
|
||||
"""Ray resources required to schedule a trial.
|
||||
|
||||
TODO: Custom resources.
|
||||
|
||||
Attributes:
|
||||
cpu (int): Number of CPUs to allocate to the trial.
|
||||
gpu (int): Number of GPUs to allocate to the trial.
|
||||
extra_cpu (int): Extra CPUs to reserve in case the trial needs to
|
||||
cpu (float): Number of CPUs to allocate to the trial.
|
||||
gpu (float): Number of GPUs to allocate to the trial.
|
||||
extra_cpu (float): Extra CPUs to reserve in case the trial needs to
|
||||
launch additional Ray actors that use CPUs.
|
||||
extra_gpu (int): Extra GPUs to reserve in case the trial needs to
|
||||
extra_gpu (float): Extra GPUs to reserve in case the trial needs to
|
||||
launch additional Ray actors that use GPUs.
|
||||
|
||||
"""
|
||||
@@ -46,6 +49,9 @@ class Resources(
|
||||
__slots__ = ()
|
||||
|
||||
def __new__(cls, cpu, gpu, extra_cpu=0, extra_gpu=0):
|
||||
for entry in [cpu, gpu, extra_cpu, extra_gpu]:
|
||||
assert isinstance(entry, Number), "Improper resource value."
|
||||
assert entry >= 0, "Resource cannot be negative."
|
||||
return super(Resources, cls).__new__(cls, cpu, gpu, extra_cpu,
|
||||
extra_gpu)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user