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

TypeError: Class advice impossible in Python3 #163

Closed
lynnna-xu opened this issue Jan 4, 2019 · 5 comments
Closed

TypeError: Class advice impossible in Python3 #163

lynnna-xu opened this issue Jan 4, 2019 · 5 comments

Comments

@lynnna-xu
Copy link


TypeError Traceback (most recent call last)
in ()
----> 1 from pytorch_pretrained_bert import BertTokenizer

/opt/conda/envs/py3/lib/python3.6/site-packages/pytorch_pretrained_bert/init.py in ()
1 version = "0.4.0"
2 from .tokenization import BertTokenizer, BasicTokenizer, WordpieceTokenizer
----> 3 from .modeling import (BertConfig, BertModel, BertForPreTraining,
4 BertForMaskedLM, BertForNextSentencePrediction,
5 BertForSequenceClassification, BertForMultipleChoice,

/opt/conda/envs/py3/lib/python3.6/site-packages/pytorch_pretrained_bert/modeling.py in ()
152
153 try:
--> 154 from apex.normalization.fused_layer_norm import FusedLayerNorm as BertLayerNorm
155 except ImportError:
156 print("Better speed can be achieved with apex installed from https://www.github.com/nvidia/apex.")

/opt/conda/envs/py3/lib/python3.6/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,

/opt/conda/envs/py3/lib/python3.6/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

/opt/conda/envs/py3/lib/python3.6/site-packages/apex/interfaces.py in ApexImplementation()
12 applications
13 """
---> 14 implements(IApex)

/opt/conda/envs/py3/lib/python3.6/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.

@lynnna-xu
Copy link
Author

Hi, I came across this error after running import pytorch_pretrained_bert. My configurations are as follows:
torch version 1.0.0
python version 3.6
cuda 9.2

@lynnna-xu
Copy link
Author

I uninstalled the old version of apex and reinstalled a new version. It worked. Thanks.

git clone https://www.github.com/nvidia/apex
cd apex
python setup.py install

@NeelKanwal
Copy link

I still have the problem in Google Colab

@fbaeumer
Copy link

I still have the problem in Google Colab

Hello! I also had the problem and now I could solve it. Please install apex exactly as described above:

git clone https://www.github.com/nvidia/apex
cd apex
python setup.py install

Double check the following: The git command creates a folder called apex. In this folder is another folder called apex. This folder is the folder of interest. Please rename the folder on the top level (e.g. apex-2) and move the lower apex folder to the main level. Then python will also find the folder and it should work.

Bildschirmfoto 2020-05-26 um 17 31 44

Make sure that you have the version (0.1). Double check it with: "!pip list".

@kommerzienrat
Copy link

The following command did the job for me (based on @fbaeumer's answer):
pip install git+https://www.github.com/nvidia/apex

ZYC-ModelCloud pushed a commit to ZYC-ModelCloud/transformers that referenced this issue Nov 14, 2024
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

4 participants