syne_tune.backend.local_backend module
- class syne_tune.backend.local_backend.LocalBackend(entry_point, delete_checkpoints=False, pass_args_as_json=False, rotate_gpus=True, num_gpus_per_trial=1, gpus_to_use=None)[source]
Bases:
TrialBackendA backend running locally by spawning sub-process concurrently. Note that no resource management is done so the concurrent number of trials should be adjusted to the machine capacity.
Additional arguments on top of parent class
TrialBackend:- Parameters:
entry_point (
str) – Path to Python main file to be tunedrotate_gpus (
bool) – In case several GPUs are present, each trial is scheduled on a different GPU. A new trial is preferentially scheduled on a free GPU, and otherwise the GPU with least prior assignments is chosen. IfFalse, then all GPUs are used at the same time for all trials. Defaults toTrue.num_gpus_per_trial (
int) – Number of GPUs to be allocated to each trial. Must be not larger than the total number of GPUs available. Defaults to 1gpus_to_use (
Optional[List[int]]) – If this is given, the backend only uses GPUs in this lists (non-negative ints). Entries must be inrange(get_num_gpus()). Defaults to using all GPUs.
- trial_path(trial_id)[source]
- Parameters:
trial_id (
int) – ID of trial- Return type:
Path- Returns:
Directory where files related to trial are written to
- checkpoint_trial_path(trial_id)[source]
- Parameters:
trial_id (
int) – ID of trial- Return type:
Path- Returns:
Directory where checkpoints for trial are written to and read from
- copy_checkpoint(src_trial_id, tgt_trial_id)[source]
Copy the checkpoint folder from one trial to the other.
- Parameters:
src_trial_id (
int) – Source trial ID (copy from)tgt_trial_id (
int) – Target trial ID (copy to)
- delete_checkpoint(trial_id)[source]
Removes checkpoint folder for a trial. It is OK for the folder not to exist.
- Parameters:
trial_id (
int) – ID of trial for which checkpoint files are deleted
- busy_trial_ids()[source]
Returns list of ids for currently busy trials
A trial is busy if its status is
in_progressorstopping. If the execution setup is able to runn_workersjobs in parallel, then if this method returns a list of sizen, the tuner may startn_workers - nnew jobs.- Return type:
List[Tuple[int,str]]- Returns:
List of
(trial_id, status)
- stdout(trial_id)[source]
Fetch
stdoutlog for trial- Parameters:
trial_id (
int) – ID of trial- Return type:
List[str]- Returns:
Lines of the log of the trial (stdout)
- stderr(trial_id)[source]
Fetch
stderrlog for trial- Parameters:
trial_id (
int) – ID of trial- Return type:
List[str]- Returns:
Lines of the log of the trial (stderr)
- set_path(results_root=None, tuner_name=None)[source]
- Parameters:
results_root (
Optional[str]) – The local folder that should contain the results of the tuning experiment. Used byTunerto indicate a desired path where the results should be written to. This is used to unify the location of backend files andTunerresults when possible (in the local backend). By default, the backend does not do anything since not all backends may be able to unify their file locations.tuner_name (
Optional[str]) – Name of the tuner, can be used for instance to save checkpoints on remote storage.