ModuleNotFoundError: No module named 'fairseq.data.token_block_utils_fast'
See original GitHub issueI’m trying to reproduce results in https://github.com/pytorch/fairseq/blob/master/examples/language_model/README.md for Russian (transformer_lm.wmt19.ru). Unfoortunately when I run the code:
import torch
# List available models
torch.hub.list('pytorch/fairseq') # [..., 'transformer_lm.wmt19.en', ...]
# Load an LM trained on
en_lm = torch.hub.load('pytorch/fairseq',
'transformer_lm.wmt19.ru', tokenizer='moses', bpe='fastbpe')
# Sample from the language model
en_lm.sample('Barack Obama', beam=1, sampling=True, sampling_topk=10, temperature=0.8)
It fails with error:
loading archive file https://dl.fbaipublicfiles.com/fairseq/models/lm/wmt19.ru.tar.bz2 from cache at /home/alx/.cache/torch/pytorch_fairseq/29ba20dab200b0132a327b03b8db9551bc9a7b14963ee3e1fb5636f83023523b.21ea13fab90519145b4248e8a1411920238a7c2d1723c5e456bc0404d6e6ec08
| dictionary: 31232 types
Namespace(activation_fn='relu', adaptive_input=False, adaptive_input_cutoff=None, adaptive_input_factor=4, adaptive_softmax_cutoff=None, adaptive_softmax_dropout=0, adaptive_softmax_factor=4, add_bos_token=False, arch='transformer_lm_gbw', attention_dropout=0.1, bpe='fastbpe', bpe_codes='/home/alx/.cache/torch/pytorch_fairseq/29ba20dab200b0132a327b03b8db9551bc9a7b14963ee3e1fb5636f83023523b.21ea13fab90519145b4248e8a1411920238a7c2d1723c5e456bc0404d6e6ec08/bpecodes', bucket_cap_mb=25, char_embedder_highway_layers=2, character_embedding_dim=4, character_embeddings=False, character_filters='[(1, 64), (2, 128), (3, 192), (4, 256), (5, 256), (6, 256), (7, 256)]', clip_norm=0.1, cpu=False, criterion='cross_entropy', data='/home/alx/.cache/torch/pytorch_fairseq/29ba20dab200b0132a327b03b8db9551bc9a7b14963ee3e1fb5636f83023523b.21ea13fab90519145b4248e8a1411920238a7c2d1723c5e456bc0404d6e6ec08', ddp_backend='c10d', decoder_attention_heads=16, decoder_embed_dim=1024, decoder_ffn_embed_dim=6144, decoder_input_dim=1024, decoder_layerdrop=0, decoder_layers=20, decoder_layers_to_keep=None, decoder_learned_pos=False, decoder_normalize_before=True, decoder_output_dim=1024, device_id=0, distributed_backend='nccl', distributed_init_method='tcp://learnfair1169:55498', distributed_port=55498, distributed_rank=0, distributed_world_size=32, dropout=0.1, fix_batches_to_gpus=False, fp16=True, fp16_init_scale=128, fp16_scale_tolerance=0.0, fp16_scale_window=None, future_target=False, keep_interval_updates=1, keep_last_epochs=-1, layernorm_embedding=False, lazy_load=False, log_format='json', log_interval=1000, lr=[5e-05], lr_period_updates=959000.0, lr_scheduler='cosine', lr_shrink=0.6, max_epoch=0, max_lr=1.0, max_sentences=None, max_sentences_valid=None, max_source_positions=512, max_target_positions=512, max_tokens=2048, max_update=975000, memory_efficient_fp16=False, min_loss_scale=0.0001, min_lr=1e-09, momentum=0.99, moses_no_dash_splits=False, moses_no_escape=False, no_decoder_final_norm=True, no_epoch_checkpoints=True, no_progress_bar=False, no_save=False, no_scale_embedding=False, no_token_positional_embeddings=False, num_workers=0, optimizer='nag', optimizer_overrides='{}', output_dictionary_size=-1, past_target=False, raw_text=False, relu_dropout=0.1, reset_lr_scheduler=False, reset_optimizer=False, restore_file='checkpoint_last.pt', sample_break_mode='eos', save_dir='/checkpoint/nng/lm/wmt/ru_news.mxup975000.mlr1.0.tmult2.per959000.csn.lrs0.6.wrm16000.int1e-07.nag.lr5e-05.clp0.1.lyr20.hd16.drp0.1.ffn6144.at_d0.1.rl_d0.1.i1024.m1024.o1024.mxtk2048.tps512.seed1.bm=eos.ngpu32', save_interval=1, save_interval_updates=959000, seed=1, self_target=False, sentence_avg=False, share_decoder_input_output_embed=False, skip_invalid_size_inputs_valid_test=True, t_mult=2.0, task='language_modeling', tensorboard_logdir='/checkpoint/nng/tensorboard_logs/2019-03-22/ru_news.mxup975000.mlr1.0.tmult2.per959000.csn.lrs0.6.wrm16000.int1e-07.nag.lr5e-05.clp0.1.lyr20.hd16.drp0.1.ffn6144.at_d0.1.rl_d0.1.i1024.m1024.o1024.mxtk2048.tps512.seed1.bm=eos.ngpu32', threshold_loss_scale=None, tie_adaptive_proj=False, tie_adaptive_weights=False, tokenizer='moses', tokens_per_sample=512, train_subset='train', update_freq=[1], user_dir=None, valid_subset='valid', validate_interval=1, warmup_init_lr=1e-07, warmup_updates=16000, weight_decay=0.0)
Loading codes from /home/alx/.cache/torch/pytorch_fairseq/29ba20dab200b0132a327b03b8db9551bc9a7b14963ee3e1fb5636f83023523b.21ea13fab90519145b4248e8a1411920238a7c2d1723c5e456bc0404d6e6ec08/bpecodes ...
Read 24000 codes from the codes file.
Traceback (most recent call last):
File "/home/alx/.cache/torch/hub/pytorch_fairseq_master/fairseq/data/token_block_dataset.py", line 46, in __init__
from fairseq.data.token_block_utils_fast import (
ModuleNotFoundError: No module named 'fairseq.data.token_block_utils_fast'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "fairseq_transformer.py", line 13, in <module>
en_lm.sample('Barack Obama', beam=1, sampling=True, sampling_topk=10, temperature=0.8)
File "/home/alx/.cache/torch/hub/pytorch_fairseq_master/fairseq/hub_utils.py", line 107, in sample
hypo = self.generate(input, beam, verbose, **kwargs)[0]['tokens']
File "/home/alx/.cache/torch/hub/pytorch_fairseq_master/fairseq/hub_utils.py", line 111, in generate
sample = self._build_sample(tokens)
File "/home/alx/.cache/torch/hub/pytorch_fairseq_master/fairseq/hub_utils.py", line 183, in _build_sample
dataset = self.task.build_dataset_for_inference([src_tokens], [src_tokens.numel()])
File "/home/alx/.cache/torch/hub/pytorch_fairseq_master/fairseq/tasks/language_modeling.py", line 208, in build_dataset_for_inference
include_targets=False,
File "/home/alx/.cache/torch/hub/pytorch_fairseq_master/fairseq/data/token_block_dataset.py", line 52, in __init__
'Please build Cython components with: `pip install --editable .` '
ImportError: Please build Cython components with: `pip install --editable .` or `python setup.py build_ext --inplace`
By the way I installed fairseq with pip install --editable .
, but error still occurs.
Does anyone know how to fix this?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
No module named 'fairseq.data.token_block_utils_fast' · Issue ...
I'm trying to reproduce results in https://github.com/pytorch/fairseq/blob/master/examples/language_model/README.md for Russian ...
Read more >install and run fairseq in google colab (ModuleNotFoundError
An error called "ModuleNotFoundError: No module named 'fairseq'" suddenly occurred today. Does anyone know how to solve this?
Read more >ModuleNotFoundError: No module named 'fairseq'
Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'fairseq' How to remove the ModuleNotF.
Read more >No module named 'fairseq.data.data_utils_fast' - 简书
ModuleNotFoundError : No module named 'fairseq.data.data_utils_fast'. 缺少Cython组件,一般可能是直接克隆了fairseq master,.
Read more >build failed: error: can't find python, please install ... - You.com
According to the Python documentation: This module makes available standard errno system symbols. The value of each symbol is the corresponding integer value....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Erifai Hi, I encountered the same issue as yours when using colab for loading the PTM. I struggled a lot and found the following solution feasible. I hope this can help you.
!pip install cython -U !git clone https://github.com/pytorch/fairseq.git %cd fairseq !pip install --quiet --editable . !pip install --quiet sentencepiece cd …
Best, Zeyu
hello guys i’m trying to load camembert model and i’m having the same issue
here’s what m trying to do (jupyter notebook)
any one can help please ? (it’s been a week that m trying to solve this)
ERROR :