allenai/allennlp

Incompatible with tensorflow-tensorboard

luheng opened this issue · 9 comments

There might be something I'm missing, but it seems that the import:
from tensorboard import SummaryWriter
would break if I install tensorflow-tensorboard or tensorflow, which is required if I want to launch a tensorboard. My current workaround is to launch a tensorboard outside the virtual environment.

Yes, that's a good point - I also just run tensorboard outside of the virtual environment, but I agree this isn't ideal. We were trying to avoid including tensorflow as a dependency and tensorboard wasn't a separate entity from tensorflow at that point - this would be a good upgrade now it's a separate pip package.

I encountered the same issue, when I run from allennlp.models.encoder_decoders.simple_seq2seq import SimpleSeq2Seq, it breaks as below. I think changing from tensorboard import to from tensorboardX import would help, as tensorboardX is made for pytorch.

In [1]: from allennlp.models.encoder_decoders.simple_seq2seq import SimpleSeq2Seq
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-002fdbacde9d> in <module>()
----> 1 from allennlp.models import simple_seq2seq

~/anaconda3/lib/python3.6/site-packages/allennlp-0.2.1-py3.6.egg/allennlp/models/__init__.py in <module>()
      5 
      6 from allennlp.models.archival import archive_model, load_archive
----> 7 from allennlp.models.decomposable_attention import DecomposableAttention
      8 from allennlp.models.encoder_decoders.simple_seq2seq import SimpleSeq2Seq
      9 from allennlp.models.model import Model

~/anaconda3/lib/python3.6/site-packages/allennlp-0.2.1-py3.6.egg/allennlp/models/decomposable_attention.py in <module>()
     11 from allennlp.nn import InitializerApplicator, RegularizerApplicator
     12 from allennlp.nn.util import get_text_field_mask, last_dim_softmax, weighted_sum
---> 13 from allennlp.training.metrics import CategoricalAccuracy
     14 
     15 

~/anaconda3/lib/python3.6/site-packages/allennlp-0.2.1-py3.6.egg/allennlp/training/__init__.py in <module>()
----> 1 from allennlp.training.trainer import Trainer

~/anaconda3/lib/python3.6/site-packages/allennlp-0.2.1-py3.6.egg/allennlp/training/trainer.py in <module>()
     19 from torch.optim.lr_scheduler import _LRScheduler as PytorchLRScheduler  # pylint: disable=protected-access
     20 import tqdm
---> 21 from tensorboard import SummaryWriter
     22 
     23 from allennlp.common import Params

ImportError: cannot import name 'SummaryWriter'

Confirmed this is still an issue.

$ pip install tensorflow-tensorboard
$ python -c 'from tensorboard import SummaryWriter'                                                                                                                                                                                                                     (allennlp) 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name 'SummaryWriter'

Also confirmed that the following doesn't fail.

python -c 'from tensorboardX import SummaryWriter'

@DeNeutoy are you able to try using tensorboard using tensorboardX and let us know if it still provides you what you need?

I have this problem as well

I have this problem as well.

Can you provide more detail with a traceback / open a new issue? Thanks

File "C:\Anaconda3\envs\allennlp\lib\site-packages\allennlp\common\util.py", line 11, in
import resource
ModuleNotFoundError: No module named 'resource'

for import:
from allennlp.predictors.bidaf import Predictor

@Prav2018 : it looks like you're using windows, which allennlp does not yet support (see #612)

@nelson-liu are there any alternate approaches to this problem ?