From a22242b7f2cba91ee8ae240c3c86a78c5072a0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20W=C3=A4lchli?= Date: Tue, 14 Mar 2023 20:27:32 +0100 Subject: [PATCH] Improve the error message for installing tensorboardx (#17053) --- src/lightning/fabric/CHANGELOG.md | 2 ++ src/lightning/fabric/loggers/tensorboard.py | 3 ++- src/lightning/pytorch/CHANGELOG.md | 3 +++ src/lightning/pytorch/loggers/tensorboard.py | 5 ++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lightning/fabric/CHANGELOG.md b/src/lightning/fabric/CHANGELOG.md index d1cfe9ab0d..97f2872453 100644 --- a/src/lightning/fabric/CHANGELOG.md +++ b/src/lightning/fabric/CHANGELOG.md @@ -76,6 +76,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed issue where the wrapped dataloader `iter()` would be called twice ([#16841](https://github.com/Lightning-AI/lightning/pull/16841)) +- Improved the error message for installing tensorboard or tensorboardx ([#17053](https://github.com/Lightning-AI/lightning/pull/17053)) + ## [1.9.4] - 2023-03-01 diff --git a/src/lightning/fabric/loggers/tensorboard.py b/src/lightning/fabric/loggers/tensorboard.py index 462b7243fe..a7790e5b70 100644 --- a/src/lightning/fabric/loggers/tensorboard.py +++ b/src/lightning/fabric/loggers/tensorboard.py @@ -91,7 +91,8 @@ class TensorBoardLogger(Logger): ): if not _TENSORBOARD_AVAILABLE and not _TENSORBOARDX_AVAILABLE: raise ModuleNotFoundError( - "Neither `tensorboard` nor `tensorboardX` is available. Try `pip install`ing either." + "Neither `tensorboard` nor `tensorboardX` is available. Try `pip install`ing either.\n" + f"{str(_TENSORBOARDX_AVAILABLE)}\n{str(_TENSORBOARD_AVAILABLE)}" ) super().__init__() root_dir = os.fspath(root_dir) diff --git a/src/lightning/pytorch/CHANGELOG.md b/src/lightning/pytorch/CHANGELOG.md index e4a0dd2ba2..ae0c9aa4f1 100644 --- a/src/lightning/pytorch/CHANGELOG.md +++ b/src/lightning/pytorch/CHANGELOG.md @@ -439,6 +439,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed an issue with comparing torch versions when using a version of torch built from source ([#17030](https://github.com/Lightning-AI/lightning/pull/17030)) +- Improved the error message for installing tensorboard or tensorboardx ([#17053](https://github.com/Lightning-AI/lightning/pull/17053)) + + ## [1.9.4] - 2023-03-01 ### Added diff --git a/src/lightning/pytorch/loggers/tensorboard.py b/src/lightning/pytorch/loggers/tensorboard.py index 7cc5c00190..bcced33e5b 100644 --- a/src/lightning/pytorch/loggers/tensorboard.py +++ b/src/lightning/pytorch/loggers/tensorboard.py @@ -117,7 +117,10 @@ class TensorBoardLogger(Logger, FabricTensorBoardLogger): **kwargs, ) if log_graph and not _TENSORBOARD_AVAILABLE: - rank_zero_warn("You set `TensorBoardLogger(log_graph=True)` but `tensorboard` is not available.") + rank_zero_warn( + "You set `TensorBoardLogger(log_graph=True)` but `tensorboard` is not available.\n" + f"{str(_TENSORBOARD_AVAILABLE)}" + ) self._log_graph = log_graph and _TENSORBOARD_AVAILABLE self.hparams: Union[Dict[str, Any], Namespace] = {}