diff --git a/examples/nlp/text_classification/text_classification_with_bert.py b/examples/nlp/text_classification/text_classification_with_bert.py index efbc5084bc54..2ae9469fb998 100644 --- a/examples/nlp/text_classification/text_classification_with_bert.py +++ b/examples/nlp/text_classification/text_classification_with_bert.py @@ -108,7 +108,12 @@ @hydra_runner(config_path="conf", config_name="text_classification_config") def main(cfg: DictConfig) -> None: logging.info(f'\nConfig Params:\n{OmegaConf.to_yaml(cfg)}') - trainer = pl.Trainer(plugins=[NLPDDPPlugin()], **cfg.trainer) + try: + plugin = NLPDDPPlugin() + except (ImportError, ModuleNotFoundError): + plugin = None + + trainer = pl.Trainer(plugins=plugin, **cfg.trainer) exp_manager(trainer, cfg.get("exp_manager", None)) if not cfg.model.train_ds.file_path: diff --git a/examples/nlp/token_classification/token_classification_train.py b/examples/nlp/token_classification/token_classification_train.py index 65c7911b09af..3e3b0a245737 100644 --- a/examples/nlp/token_classification/token_classification_train.py +++ b/examples/nlp/token_classification/token_classification_train.py @@ -102,7 +102,12 @@ @hydra_runner(config_path="conf", config_name="token_classification_config") def main(cfg: DictConfig) -> None: - trainer = pl.Trainer(plugins=[NLPDDPPlugin()], **cfg.trainer) + try: + plugin = NLPDDPPlugin() + except (ImportError, ModuleNotFoundError): + plugin = None + + trainer = pl.Trainer(plugins=plugin, **cfg.trainer) exp_manager(trainer, cfg.get("exp_manager", None)) if not cfg.pretrained_model: