otx.cli.utils.experiment#

Utils function for experiments.

Classes

CpuUsageRecorder()

CPU usage recorder class.

GpuUsageRecorder([gpu_ids])

GPU usage recorder class.

ResourceRecorder()

Base calss for each resource recorder.

ResourceTracker(output_path[, ...])

Class to track resources usage.

class otx.cli.utils.experiment.CpuUsageRecorder[source]#

Bases: ResourceRecorder

CPU usage recorder class.

Parameters:

Optional[psutil.Process] (target_process) – Process to track.

record()[source]#

Record CPU usage.

report() Dict[str, str][source]#

Aggregate CPU usage.

class otx.cli.utils.experiment.GpuUsageRecorder(gpu_ids: List[int] | None = None)[source]#

Bases: ResourceRecorder

GPU usage recorder class.

Parameters:

Optional[List[int]] (gpu_ids) – GPU indices to record. If not given, first GPU is recorded.

record()[source]#

Record GPU usage.

report() Dict[str, str][source]#

Aggregate GPU usage.

class otx.cli.utils.experiment.ResourceRecorder[source]#

Bases: ABC

Base calss for each resource recorder.

abstract record()[source]#

Record a resource usage.

abstract report()[source]#

Aggregate all resource usages.

class otx.cli.utils.experiment.ResourceTracker(output_path: str | Path, resource_type: str = 'all', gpu_ids: str | None = None)[source]#

Bases: object

Class to track resources usage.

Parameters:
  • output_path (Union[str, Path]) – Output file path to save CPU & GPU utilization and max meory usage values.

  • resource_type (str, optional) – Which resource to track. Available values are cpu, gpu or all now. Defaults to “all”.

  • gpu_ids (Optional[str]) – GPU indices to record.

start()[source]#

Run a process which tracks resources usage.

stop()[source]#

Terminate a process to record resources usage.