8000 Fix deprecation warning in `torch.utils.tensorboard` import · Issue #84712 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content
Fix deprecation warning in torch.utils.tensorboard import #84712
@milutter

Description

@milutter

🚀 The feature, motivation and pitch

Importing the tensorboard writer yields a deprecation warning from distutils in python 3.10, i.e.,
DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.

This can be easily fixed as mentioned in the deprecation warning. One needs to replace the current lines 2 - 9 (https://github.com/pytorch/pytorch/blob/master/torch/utils/tensorboard/__init__.py#L2)

from distutils.version import LooseVersion

if not hasattr(tensorboard, "__version__") or LooseVersion(
    tensorboard.__version__
) < LooseVersion("1.15"):
    raise ImportError("TensorBoard logging requires TensorBoard version 1.15 or above")

del LooseVersion

with

import packaging

if not hasattr(tensorboard, "__version__") or packaging.version.parse(
        tensorboard.__version__
) < packaging.version.Version("1.15"):
    raise ImportError("TensorBoard logging requires TensorBoard version 1.15 or above")

del packaging

I am happy to submit the PR but I do not know how to test against all supported python versions and changing all requirements correctly in all different build targets.

Alternatives

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: tensorboardtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0