CONF#

This module contains utility functions for configuration settings.

Functions#

utils.conf.base_path(override=None)[source]#

Returns the base bath where to log accuracies and tensorboard data.

Parameters:

override – the path to override the default one. Once set, it is stored and used for all the next calls.

Returns:

./data/)

Return type:

the base path (default

utils.conf.create_seeded_dataloader(args, dataset, non_verbose=False, **dataloader_args)[source]#

Creates a dataloader object from a dataset, setting the seeds for the workers (if –seed is set).

Parameters:
  • args – the arguments of the program

  • dataset – the dataset to be loaded

  • verbose – whether to print the number of workers

  • dataloader_args – external arguments of the dataloader

Returns:

the dataloader object

Return type:

DataLoader

utils.conf.get_alloc_memory_all_devices(return_all=False)[source]#

Returns the memory allocated on all the available devices. By default, tries to return the memory read from pynvml, if available. Else, it returns the memory reserved by torch.

If return_all is set to True, it returns a tuple with the memory reserved, allocated and from pynvml.

Values are in Bytes.

Return type:

list[int]

utils.conf.get_device(avail_devices=None)[source]#

Returns the least used GPU device if available else MPS or CPU.

Return type:

device

utils.conf.set_random_seed(seed)[source]#

Sets the seeds at a certain value.

Parameters:

seed (int) – the value to be set

utils.conf.warn_once(*msg)[source]#

Prints a warning message only once.

Parameters:

msg – the message to be printed

utils.conf.worker_init_fn(worker_id, num_workers, seed, rank=1)[source]#

Sets the seeds for a worker of a dataloader. The seed of each worker is set to: num_worker * rank + worker_id + seed