TypeError Traceback (most recent call last)
----> 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.
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
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
I still have the problem in Google Colab
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.

Make sure that you have the version (0.1). Double check it with: "!pip list".
The following command did the job for me (based on @fbaeumer's answer):
pip install git+https://www.github.com/nvidia/apex
Most helpful comment
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