Esempio n. 1
0
def hydra_main(overrides: List[Any]):
    ######################################################################################
    # DO NOT MOVE THIS IMPORT TO TOP LEVEL: submitit processes will not be initialized
    # correctly (MKL_THREADING_LAYER will be set to INTEL instead of GNU)
    ######################################################################################
    from vissl.hooks import default_hook_generator

    ######################################################################################

    print(f"####### overrides: {overrides}")
    with initialize_config_module(config_module="vissl.config"):
        cfg = compose("defaults", overrides=overrides)
    args, config = convert_to_attrdict(cfg)

    if config.SLURM.USE_SLURM:
        assert (
            is_submitit_available()
        ), "Please 'pip install submitit' to schedule jobs on SLURM"
        launch_distributed_on_slurm(engine_name=args.engine_name, cfg=config)
    else:
        launch_distributed(
            cfg=config,
            node_id=args.node_id,
            engine_name=args.engine_name,
            hook_generator=default_hook_generator,
        )
    def _launch_slurm_job(self, args, config):
        # Get next port in the list of #pytorch_ports
        try:
            port = next(self.pytorch_ports_iterable)
        except StopIteration:
            # Start at the beginning of the ports list.
            self.pytorch_ports_iterable = iter(self.pytorch_ports)
            port = next(self.pytorch_ports_iterable)

        config.SLURM.PORT_ID = port

        return launch_distributed_on_slurm(engine_name=args.engine_name, cfg=config)