File size: 4,134 Bytes
fc0f7bd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | ---
id: joblib_launcher
title: Joblib Launcher plugin
sidebar_label: Joblib Launcher plugin
---
[](https://pypi.org/project/hydra-joblib-launcher/)


[](https://pypistats.org/packages/hydra-joblib-launcher)
[](https://github.com/facebookresearch/hydra/tree/master/plugins/hydra_joblib_launcher/example)
[](https://github.com/facebookresearch/hydra/tree/master/plugins/hydra_joblib_launcher)
The Joblib Launcher plugin provides a launcher for parallel tasks based on [`Joblib.Parallel`](https://joblib.readthedocs.io/en/latest/parallel.html).
### Installation
This plugin requires Hydra 1.0 (Release candidate)
```commandline
$ pip install hydra-joblib-launcher --pre
```
### Usage
Once installed, add `hydra/launcher=joblib` to your command line. Alternatively, override `hydra/launcher` in your config:
```yaml
defaults:
- hydra/launcher: joblib
```
By default, process-based parallelism using all available CPU cores is used. By overriding the default configuration, it is e.g. possible limit the number of parallel executions.
The default configuration packaged with the plugin is:
```python
@dataclass
class JobLibLauncherConf(PluginConf):
cls: str = "hydra_plugins.hydra_joblib_launcher.JoblibLauncher"
params: JobLibConf = JobLibConf()
```
The JobLibConf class is defined [here](https://github.com/facebookresearch/hydra/blob/master/plugins/hydra_joblib_launcher/hydra_plugins/hydra_joblib_launcher/config.py):
It looks like this:
```python
@dataclass
class JobLibConf:
# maximum number of concurrently running jobs. if -1, all CPUs are used
n_jobs: int = -1
# allows to hard-code backend, otherwise inferred based on prefer and require
backend: Optional[str] = None
# processes or threads, soft hint to choose backend
prefer: str = "processes"
# null or sharedmem, sharedmem will select thread-based backend
require: Optional[str] = None
# if greater than zero, prints progress messages
verbose: int = 0
# timeout limit for each task
timeout: Optional[int] = None
# number of batches to be pre-dispatched
pre_dispatch: str = "2*n_jobs"
# number of atomic tasks to dispatch at once to each worker
batch_size: str = "auto"
# folder used for memmapping large arrays for sharing memory with workers
temp_folder: Optional[str] = None
# thresholds size of arrays that triggers automated memmapping
max_nbytes: Optional[str] = None
# memmapping mode for numpy arrays passed to workers
mmap_mode: str = "r"
```
See [`Joblib.Parallel` documentation](https://joblib.readthedocs.io/en/latest/parallel.html) for full details about the parameters above.
<div class="alert alert--info" role="alert">
NOTE: The only supported JobLib backend is Loky (process-based parallelism).
</div><br/>
An [example application](https://github.com/facebookresearch/hydra/tree/master/plugins/hydra_joblib_launcher/example) using this launcher is provided in the plugin repository.
Starting the app with `python my_app.py --multirun task=1,2,3,4,5` will launch five parallel executions:
```text
$ python my_app.py --multirun task=1,2,3,4,5
[HYDRA] Joblib.Parallel(n_jobs=-1,verbose=0,timeout=None,pre_dispatch=2*n_jobs,batch_size=auto,temp_folder=None,max_nbytes=None,mmap_mode=r,backend=loky) is launching 5 jobs
[HYDRA] Launching jobs, sweep output dir : multirun/2020-02-18/10-00-00
[__main__][INFO] - Process ID 14336 executing task 2 ...
[__main__][INFO] - Process ID 14333 executing task 1 ...
[__main__][INFO] - Process ID 14334 executing task 3 ...
[__main__][INFO] - Process ID 14335 executing task 4 ...
[__main__][INFO] - Process ID 14337 executing task 5 ...
```
|