Describe the bug
File "run_classifier_torch.py", line 686, in
main()
File "run_classifier_torch.py", line 525, in main
num_labels = num_labels)
File "/home/yuwei/anaconda2/envs/py36/lib/python3.6/site-packages/pytorch_pretrained_bert/modeling.py", line 580, in from_pretrained
model = cls(config, inputs, *kwargs)
File "/home/yuwei/anaconda2/envs/py36/lib/python3.6/site-packages/pytorch_pretrained_bert/modeling.py", line 963, in __init__
self.bert = BertModel(config)
File "/home/yuwei/anaconda2/envs/py36/lib/python3.6/site-packages/pytorch_pretrained_bert/modeling.py", line 684, in __init__
self.embeddings = BertEmbeddings(config)
File "/home/yuwei/anaconda2/envs/py36/lib/python3.6/site-packages/pytorch_pretrained_bert/modeling.py", line 246, in __init__
self.LayerNorm = BertLayerNorm(config.hidden_size, eps=1e-12)
File "/home/yuwei/anaconda2/envs/py36/lib/python3.6/site-packages/apex-0.1-py3.6.egg/apex/normalization/fused_layer_norm.py", line 126, in __init__
File "/home/yuwei/anaconda2/envs/py36/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "
File "
File "
ModuleNotFoundError: No module named 'fused_layer_norm_cuda'
To Reproduce
from flair.embeddings import BertEmbeddings
from flair.data import Sentence
embedding = BertEmbeddings()
sentence = Sentence('The grass is green .')
embedding.embed(sentence)
for token in sentence:
print(token)
print(token.embedding)
Expected behavior
seeing error
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
Additional context
Add any other context about the problem here.
Hello @PaulZhangIsing which version of Flair do you use? and which version of pytorch-pretrained-bert do you have installed?
Hello @PaulZhangIsing which version of Flair do you use? and which version of pytorch-pretrained-bert do you have installed?
I am using python3.6
flair version 0.4.0
pytorch 1.0.1
fused_layer_norm_cuda is a module from https://github.com/NVIDIA/apex. To reproduce the error, I just had to install apex in a virtual environment with Python 3.7, flair 0.4, pytorch 1.01 and pytorch_pretrained_bert 0.6.1 on a Windows 10 machine without CUDA.
In https://github.com/NVIDIA/apex/blob/master/setup.py you can see that 'fused_layer_norm_cuda' is only installed if you add '--cuda_ext' to the install command and only if the CUDA_HOME variable is set to the folder where Cuda is installed.
@PaulZhangIsing maybe one of these 2 is the case for you?
Can you confirm that you can run it without apex installed?
fused_layer_norm_cuda is a module from https://github.com/NVIDIA/apex. To reproduce the error, I just had to install apex in a virtual environment with Python 3.7, flair 0.4, pytorch 1.01 and pytorch_pretrained_bert 0.6.1 on a Windows 10 machine without CUDA.
In https://github.com/NVIDIA/apex/blob/master/setup.py you can see that 'fused_layer_norm_cuda' is only installed if you add '--cuda_ext' to the install command and only if the CUDA_HOME variable is set to the folder where Cuda is installed.
@PaulZhangIsing maybe one of these 2 is the case for you?
Can you confirm that you can run it without apex installed?
Thanks!! seems I didn't install apex correctly. I ran setup.py install without --cuda_ext command
I shall try and get back
Problem solved.
flair_embedding_forward = FlairEmbeddings('news-forward')
bert_embedding = BertEmbeddings('bert-large-cased').cuda()
sentence = Sentence('The grass is green .')
x = bert_embedding.embed(sentence)
for token in sentence:
print(token)
print(token.embedding)
That's great! @PaulZhangIsing thanks for reporting this. @MichaelHintz thanks for fixing this!
Most helpful comment
fused_layer_norm_cuda is a module from https://github.com/NVIDIA/apex. To reproduce the error, I just had to install apex in a virtual environment with Python 3.7, flair 0.4, pytorch 1.01 and pytorch_pretrained_bert 0.6.1 on a Windows 10 machine without CUDA.
In https://github.com/NVIDIA/apex/blob/master/setup.py you can see that 'fused_layer_norm_cuda' is only installed if you add '--cuda_ext' to the install command and only if the CUDA_HOME variable is set to the folder where Cuda is installed.
@PaulZhangIsing maybe one of these 2 is the case for you?
Can you confirm that you can run it without apex installed?