Import SummaryWriter gives AttributeError: AttributeError: module 'setuptools._distutils' has no attribute 'version'

I’m using PyTorch on a MacBook with an Apple M1 processor. I am using miniforge to install ARM PyTorch and ARM Tensorflow.

As far as I can tell, everything works except for Tensorboard. For instance, if I refer to the tutorial at torch.utils.tensorboard — PyTorch 1.10.1 documentation I am stopped at the third line:

from torch.utils.tensorboard import SummaryWriter

raises an error:

AttributeError: module 'setuptools._distutils' has no attribute 'version'.

These are the versions I’m using:

python                    3.9.9
tensorboard               2.6.0
pytorch                   1.10.0
tensorflow-deps           2.7.0
tensorflow-estimator      2.7.0
tensorflow-macos          2.7.0
tensorflow-metal          0.3.0

Is this a known issue? And is there a workaround?

Yes, this was a known issue which was already fixed in this PR. You could thus either update PyTorch to the nightly release or downgrade setuptools==59.5.0 as a workaround.

1 Like

Is there a way to update without building from source for ARM?

As an alternative, I just monkey-patched by replacing the old torch/utils/tensorboard/__init__.py file with the new one. It works fine.