yzhangcs / parser

:rocket: State-of-the-art parsers for natural language.
https://parser.yzhang.site/
MIT License
829 stars 141 forks source link

AttributeError: module 'torch.distributed' has no attribute 'is_initialized' #37

Closed Mohd-Misran closed 4 years ago

Mohd-Misran commented 4 years ago

I loaded the crf-con-en model to the Parser. Then I tried to use the predict() function on a list of English tokens. But I get the above error. Need help on how to debug this!

Here's my code:

from supar import Parser import nltk

parser = Parser.load("crf-con-en")

text = nltk.word_tokenize("John, who is the CEO of a company, played golf.")

output = parser.predict(data=[text], verbose=False)

Complete error log:

AttributeError Traceback (most recent call last)

in ----> 1 output = parser.predict(data=[text], verbose=False) ~\anaconda3\lib\site-packages\supar\parsers\crf_constituency.py in predict(self, data, pred, buckets, batch_size, prob, mbr, verbose, **kwargs) 121 """ 122 --> 123 return super().predict(**Config().update(locals())) 124 125 def _train(self, loader): ~\anaconda3\lib\site-packages\supar\parsers\parser.py in predict(self, data, pred, buckets, batch_size, prob, **kwargs) 120 def predict(self, data, pred=None, buckets=8, batch_size=5000, prob=False, **kwargs): 121 args = self.args.update(locals()) --> 122 init_logger(logger, verbose=args.verbose) 123 124 self.transform.eval() ~\anaconda3\lib\site-packages\supar\utils\logging.py in init_logger(logger, path, mode, level, handlers, verbose) 28 level=level, 29 handlers=handlers) ---> 30 logger.setLevel(logging.INFO if is_master() and verbose else logging.WARNING) 31 32 ~\anaconda3\lib\site-packages\supar\utils\parallel.py in is_master() 33 34 def is_master(): ---> 35 return not dist.is_initialized() or dist.get_rank() == 0 AttributeError: module 'torch.distributed' has no attribute 'is_initialized'
yzhangcs commented 4 years ago

Hi, thanks for reporting this error. Could you provide the pytorch version and device info.

Yu Zhang Soochow University


From: Mohammed Misran notifications@github.com Sent: Thursday, July 30, 2020 8:02:02 PM To: yzhangcs/parser parser@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [yzhangcs/parser] AttributeError: module 'torch.distributed' has no attribute 'is_initialized' (#37)

I loaded the crf-con-en model to the Parser. Then I tried to use the predict() function on a list of English tokens. But I get the above error. Need help on how to debug this!

` from supar import Parser import nltk

parser = Parser.load("crf-con-en")

text = nltk.word_tokenize("John, who is the CEO of a company, played golf.")

output = parser.predict(data=[text], verbose=False) `

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/yzhangcs/parser/issues/37, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEMMYK72IAG3GAWY42BNLK3R6FOLVANCNFSM4PNSP65A.

Mohd-Misran commented 4 years ago

@yzhangcs

Torch version 1.5.1 Windows 10 Pro

yzhangcs commented 4 years ago

@Mohd-Misran You could check if torch.distributed.is_available() is True (https://github.com/facebookresearch/maskrcnn-benchmark/issues/280).

Mohd-Misran commented 4 years ago

@yzhangcs torch.distributed.is_available() is False

yzhangcs commented 4 years ago

@Mohd-Misran It seems that distributed training is not supported on Windows.

yzhangcs commented 3 years ago

@Mohd-Misran DDP is supported on Windows since torch 1.7.