Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in importing Apex #5

Open
Alamelu1812 opened this issue Mar 5, 2019 · 6 comments
Open

Issue in importing Apex #5

Alamelu1812 opened this issue Mar 5, 2019 · 6 comments

Comments

@Alamelu1812
Copy link

I am having issues while importing apex. I get an error similar to the ones posted in run_classifier repository.

in
----> 1 import apex
2 import pandas as pd
3 import numpy as np
4 import torch
5

/anaconda3/lib/python3.7/site-packages/apex/init.py in
16 from apex.exceptions import (ApexAuthSecret,
17 ApexSessionSecret)
---> 18 from apex.interfaces import (ApexImplementation,
19 IApex)
20 from apex.lib.libapex import (groupfinder,

/anaconda3/lib/python3.7/site-packages/apex/interfaces.py in
8 pass
9
---> 10 class ApexImplementation(object):
11 """ Class so that we can tell if Apex is installed from other
12 applications

/anaconda3/lib/python3.7/site-packages/apex/interfaces.py in ApexImplementation()
12 applications
13 """
---> 14 implements(IApex)

/anaconda3/lib/python3.7/site-packages/zope/interface/declarations.py in implements(*interfaces)
481 # the coverage for this block there. :(
482 if PYTHON3:
--> 483 raise TypeError(_ADVICE_ERROR % 'implementer')
484 _implements("implements", interfaces, classImplements)
485

TypeError: Class advice impossible in Python3. Use the @Implementer class decorator instead.

Could anyone help me with this?

@negacy
Copy link

negacy commented Mar 5, 2019

I had the same issue. If you didn't import apex, it will work fine, but I think that is used for faster computation.

@negacy
Copy link

negacy commented Mar 5, 2019

Also, you can install it using their GitHub page.

@Alamelu1812
Copy link
Author

If I don't import apex, the following statement fails.

from pytorch_pretrained_bert.modeling import BertForPreTraining, BertPreTrainedModel, BertModel, BertConfig, BertForMaskedLM, BertForSequenceClassification

I would like to know whether the above import worked fine without import apex.

I am getting the following error without importing apex. Any suggestions would be really helpful.

TypeError Traceback (most recent call last)
in
24
25 from pytorch_pretrained_bert.tokenization import BertTokenizer, WordpieceTokenizer
---> 26 from pytorch_pretrained_bert.modeling import BertForPreTraining, BertPreTrainedModel, BertModel, BertConfig, BertForMaskedLM, BertForSequenceClassification

/anaconda3/lib/python3.7/site-packages/pytorch_pretrained_bert/init.py in
5 from .tokenization_gpt2 import GPT2Tokenizer
6
----> 7 from .modeling import (BertConfig, BertModel, BertForPreTraining,
8 BertForMaskedLM, BertForNextSentencePrediction,
9 BertForSequenceClassification, BertForMultipleChoice,

/anaconda3/lib/python3.7/site-packages/pytorch_pretrained_bert/modeling.py in
216
217 try:
--> 218 from apex.normalization.fused_layer_norm import FusedLayerNorm as BertLayerNorm
219 except ImportError:
220 print("Better speed can be achieved with apex installed from https://www.github.com/nvidia/apex.")

/anaconda3/lib/python3.7/site-packages/apex/init.py in
16 from apex.exceptions import (ApexAuthSecret,
17 ApexSessionSecret)
---> 18 from apex.interfaces import (ApexImplementation,
19 IApex)
20 from apex.lib.libapex import (groupfinder,

/anaconda3/lib/python3.7/site-packages/apex/interfaces.py in
8 pass
9
---> 10 class ApexImplementation(object):
11 """ Class so that we can tell if Apex is installed from other
12 applications

/anaconda3/lib/python3.7/site-packages/apex/interfaces.py in ApexImplementation()
12 applications
13 """
---> 14 implements(IApex)

/anaconda3/lib/python3.7/site-packages/zope/interface/declarations.py in implements(*interfaces)
481 # the coverage for this block there. :(
482 if PYTHON3:
--> 483 raise TypeError(_ADVICE_ERROR % 'implementer')
484 _implements("implements", interfaces, classImplements)
485

TypeError: Class advice impossible in Python3. Use the @Implementer class decorator instead.

@negacy
Copy link

negacy commented Mar 6, 2019

What Python version are you using? Try it with 3.6

@Alamelu1812
Copy link
Author

I am using Python 3.7. I read in the forums that moving back to 3.6 should solve the problem. I'll try and let you know. Thanks for your help

@bhoomit
Copy link

bhoomit commented Mar 9, 2019

Was able to solve it with

git clone https://github.com/NVIDIA/apex.git && cd apex && python setup.py install --cuda_ext --cpp_ext

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants