-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazy import tensorboard #15762
Lazy import tensorboard #15762
Conversation
if _TENSORBOARD_AVAILABLE: | ||
from torch.utils.tensorboard.summary import hparams | ||
else: | ||
from tensorboardX.summary import hparams # type: ignore[no-redef] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how many times is this called per epoch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was answered in #15762 (comment)
_TENSORBOARDX_AVAILABLE = RequirementCache("tensorboardX") | ||
if TYPE_CHECKING: | ||
# assumes at least one will be installed when type checking | ||
if _TENSORBOARD_AVAILABLE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is opposite what @lantiga said in #15728 (comment) 🦦
@@ -109,6 +114,10 @@ def __init__( | |||
sub_dir: Optional[_PATH] = None, | |||
**kwargs: Any, | |||
): | |||
if not _TENSORBOARD_AVAILABLE and not _TENSORBOARDX_AVAILABLE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this won't happen as TBX is mandatory depenency
What does this PR do?
Avoids importing tensorboard unless the logger is used.
Part of #12786
Part of #15662
Does your PR introduce any breaking changes? If yes, please list them.
None
cc @awaelchli @Borda @akihironitta