Apex: ImportError: cannot import name rnn_compat

Created on 10 May 2019  路  7Comments  路  Source: NVIDIA/apex

When I import apex after the installation (finished with success) I get this error:

Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import apex
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "apex/__init__.py", line 2, in <module>
    from . import amp
  File "apex/amp/__init__.py", line 1, in <module>
    from .amp import init, half_function, float_function, promote_function,\
  File "apex/amp/amp.py", line 1, in <module>
    from . import compat, rnn_compat, utils, wrap
  File "apex/amp/rnn_compat.py", line 1, in <module>
    from . import utils, wrap
  File "apex/amp/wrap.py", line 4, in <module>
    from . import rnn_compat
ImportError: cannot import name rnn_compat

torch version 1.0.0.dev20190322
Python 2.7.15rc1
cuda 10

Most helpful comment

The solution for me is
import rnn_compat
(instead of from . import rnn_compat)

All 7 comments

Are you using apex as your working directory?
If so, could you change the wdir and try to import apex again?

this is not the problem, but /homedir/.local/lib/python2.7/site-packages/apex/amp/rnn_compat.py is there

I could reproduce this error using Python 2.7.15 and as stated in the docs, we only support Python >=3.
Would it be possible for you to use a newer Python version?

oh right, it might be this the problem.
thanks I'll check

Did updating python fix the issue? Can we close this?

Please reopen if the problem continues with python 3+.

The solution for me is
import rnn_compat
(instead of from . import rnn_compat)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chccgiven picture chccgiven  路  4Comments

aliyesilkanat picture aliyesilkanat  路  4Comments

jiangnanyida picture jiangnanyida  路  3Comments

dave-epstein picture dave-epstein  路  3Comments

TheRevanchist picture TheRevanchist  路  3Comments