Pytorch version mismatch?

Hi, thanks for the allennlp to create such a useful tool and this community for us.

I fininshed the tutorial in ‘guide’ website, and want to replicate it locally.

from collections import Counter, defaultdict

from allennlp.data.fields import TextField, LabelField, SequenceLabelField
from allennlp.data.token_indexers import SingleIdTokenIndexer
from allennlp.data.tokenizers import Token
from allennlp.data.vocabulary import Vocabulary

tokens = [Token (‘The’), Token(‘best’), Token(‘movie’), Token(‘ever’), Token(’!’)]
token_indexer = {‘tokens’:SingleIdTokenIndexer()}
text_field= TextField (tokens,token_indexers=token_indexer)

label_field = LabelField (‘pos’)

sequence_label_field= SequenceLabelField (
[‘DET’,‘ADJ’,‘NOUN’,‘ADV’,‘PUNKT’],
text_field
)
print (text_field)
print (label_field)
print (sequence_label_field)

There is a furture warning about numpy like:

D:\anaconda3\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_qint8 = np.dtype([(“qint8”, np.int8, 1)])

And another error about 'no attribute in torch"

File “D:\anaconda3\lib\site-packages\allennlp\nn\util.py”, line 106, in
def get_lengths_from_binary_sequence_mask(mask: torch.BoolTensor) -> torch.LongTensor:
AttributeError: module ‘torch’ has no attribute ‘BoolTensor’

I double checked the version of torch is 1.51 as suggested when installing allennlp,
and allennlp is 1.00.

I checked the code on guidance page is for allennlp 1.00
Did I lost something else important or how can I fix on this? THX.

I checked the ‘Declaration and Usage’ of ‘torch.BoolTensor’, it lead me to a class named BoolTensor in torch’s init.pyi, seems there exists booltensor?

By the way, before, a similar error with: module ‘torch’ has no attribute ‘IterableDataset’
(I thought this was becasue mismatch of versions at that time so I ignored it and turned to the new guidance)

If you’re getting torch errors like that, my guess is it’s a problem with your installation of pytorch. Maybe you actually have multiple versions installed somehow, and it’s using the wrong one? Hard for us to debug this without access to your environment, unfortunately.

Thanks mattg! that really helps.

For those who may encounter with similar problem:

do check that if you install multiple versions of pytorch (by uninstalling torch and then check ‘pip list’ to see whether there is still a torch version)!

By the way mattg,

I see the guidance document, the allennlp doesn’t support windows?
So far I’m working good on the tutorial :rofl: what is the part that windows may not work with?

We don’t know. That’s a really old issue, and I think it used to be more of a problem than it is now. The point is that it’s not officially supported, as we don’t have any CI or anything set up to test it, nor do any of the developers use windows, so we can’t really debug issues for it. It might work, but it also might not, and if it’s a windows-specific issue that’s the problem we can’t promise to help you, though we are happy to take PRs that fix windows-specific problems.

Thank you mattg,
nice to have your support today.

Have a good day