stylegan2-ada-pytorch icon indicating copy to clipboard operation
stylegan2-ada-pytorch copied to clipboard

cannot import name 'notf' from 'tensorboard.compat'

Open GorMorGor opened this issue 3 years ago • 6 comments

Everything was running just fine for the past 3 months but since today I'm keep running this issue.

Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/tensorboard/compat/init.py", line 42, in tf from tensorboard.compat import notf # noqa: F401 ImportError: cannot import name 'notf' from 'tensorboard.compat' (/usr/local/lib/python3.7/dist-packages/tensorboard/compat/init.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "train.py", line 582, in main() # pylint: disable=no-value-for-parameter File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 829, in call return self.main(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 782, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 610, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/click/decorators.py", line 21, in new_func return f(get_current_context(), *args, **kwargs) File "train.py", line 575, in main subprocess_fn(rank=0, args=args, temp_dir=temp_dir) File "train.py", line 422, in subprocess_fn training_loop.training_loop(rank=rank, **args) File "/content/drive/My Drive/colab-sg2-ada-pytorch/stylegan2-ada-pytorch/training/training_loop.py", line 244, in training_loop stats_tfevents = tensorboard.SummaryWriter(run_dir) File "/usr/local/lib/python3.7/dist-packages/torch/utils/tensorboard/writer.py", line 220, in init self._get_file_writer() File "/usr/local/lib/python3.7/dist-packages/torch/utils/tensorboard/writer.py", line 251, in _get_file_writer self.flush_secs, self.filename_suffix) File "/usr/local/lib/python3.7/dist-packages/torch/utils/tensorboard/writer.py", line 61, in init log_dir, max_queue, flush_secs, filename_suffix) File "/usr/local/lib/python3.7/dist-packages/tensorboard/summary/writer/event_file_writer.py", line 72, in init tf.io.gfile.makedirs(logdir) File "/usr/local/lib/python3.7/dist-packages/tensorboard/lazy.py", line 65, in getattr return getattr(load_once(self), attr_name) File "/usr/local/lib/python3.7/dist-packages/tensorboard/lazy.py", line 97, in wrapper cache[arg] = f(arg) File "/usr/local/lib/python3.7/dist-packages/tensorboard/lazy.py", line 50, in load_once module = load_fn() File "/usr/local/lib/python3.7/dist-packages/tensorboard/compat/init.py", line 45, in tf import tensorflow File "/usr/local/lib/python3.7/dist-packages/tensorflow/init.py", line 51, in from ._api.v2 import compat File "/usr/local/lib/python3.7/dist-packages/tensorflow/_api/v2/compat/init.py", line 37, in from . import v1 File "/usr/local/lib/python3.7/dist-packages/tensorflow/_api/v2/compat/v1/init.py", line 30, in from . import compat File "/usr/local/lib/python3.7/dist-packages/tensorflow/_api/v2/compat/v1/compat/init.py", line 37, in from . import v1 File "/usr/local/lib/python3.7/dist-packages/tensorflow/_api/v2/compat/v1/compat/v1/init.py", line 47, in from tensorflow._api.v2.compat.v1 import lite File "/usr/local/lib/python3.7/dist-packages/tensorflow/_api/v2/compat/v1/lite/init.py", line 9, in from . import experimental File "/usr/local/lib/python3.7/dist-packages/tensorflow/_api/v2/compat/v1/lite/experimental/init.py", line 8, in from . import authoring File "/usr/local/lib/python3.7/dist-packages/tensorflow/_api/v2/compat/v1/lite/experimental/authoring/init.py", line 8, in from tensorflow.lite.python.authoring.authoring import compatible File "/usr/local/lib/python3.7/dist-packages/tensorflow/lite/python/authoring/authoring.py", line 43, in from tensorflow.lite.python import convert File "/usr/local/lib/python3.7/dist-packages/tensorflow/lite/python/convert.py", line 29, in from tensorflow.lite.python import util File "/usr/local/lib/python3.7/dist-packages/tensorflow/lite/python/util.py", line 51, in from jax import xla_computation as _xla_computation File "/usr/local/lib/python3.7/dist-packages/jax/init.py", line 59, in from .core import eval_context as ensure_compile_time_eval File "/usr/local/lib/python3.7/dist-packages/jax/core.py", line 47, in import jax._src.pretty_printer as pp File "/usr/local/lib/python3.7/dist-packages/jax/_src/pretty_printer.py", line 56, in CAN_USE_COLOR = _can_use_color() File "/usr/local/lib/python3.7/dist-packages/jax/_src/pretty_printer.py", line 54, in _can_use_color return sys.stdout.isatty() AttributeError: 'Logger' object has no attribute 'isatty'

GorMorGor avatar Jul 13 '22 18:07 GorMorGor

OK. Got workaround by replacing init.py in the /usr/local/lib/python3.7/dist-packages/tensorboard/compat/ directory with a 'blank' init.py from the repo. But why is it started accessing the file in this exact directory?

GorMorGor avatar Jul 13 '22 18:07 GorMorGor

Hello @GorMorGor - i'm having the same issue but I'm using the notebook through Google colab. Would you know how to fix this issue in Colab?

redyellowRain avatar Jul 13 '22 21:07 redyellowRain

@redyellowRain Thank you. I'm using Colab, too. The workaround with the file replacement I have described in the comment above helps me run the process in Colab, but I would like to know how to make this replacement automatic and fix it in the code.

GorMorGor avatar Jul 14 '22 06:07 GorMorGor

@GorMorGor - I see. i tried your solution and it works. even removing the init file completely with os.remove() works . I'll be waiting for a better solution as well but as a work around it's good and i thank you for that!

redyellowRain avatar Jul 14 '22 11:07 redyellowRain

Hello @GorMorGor, I encounter the exact same problem, but by deleting the init.py file, it gave me a new cannot import name 'tf' error. Any idea?

zuuukiiio avatar Aug 02 '22 22:08 zuuukiiio

@zuuukiiio I belief this is a separate issue caused by PyTorch, Tensorflow or one of the modules versions mismatch. I have no idea what versions you have installed and, most importantly, what versions it should be.

GorMorGor avatar Aug 03 '22 04:08 GorMorGor