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

apex ImportError on Google Colab #585

Closed
mhiro216 opened this issue Nov 4, 2019 · 2 comments
Closed

apex ImportError on Google Colab #585

mhiro216 opened this issue Nov 4, 2019 · 2 comments

Comments

@mhiro216
Copy link

mhiro216 commented Nov 4, 2019

I try to install apex for pytorch on Google Colab.

I followed the install directions as follows, and the install seem to succeed.

!git clone https://github.com/NVIDIA/apex; cd apex; pip3 install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" . --user

apex seem to be installed at:

!cd '/root/.local/lib/python3.6/site-packages'; ls
...
amp_C.cpython-36m-x86_64-linux-gnu.so
 apex
 apex-0.1-py3.6.egg-info
 apex_C.cpython-36m-x86_64-linux-gnu.so
'~-ex'
'~-ex-0.1-py3.6.egg-info'
 fused_layer_norm_cuda.cpython-36m-x86_64-linux-gnu.so
'~pex'
'~pex-0.1.dist-info'
'~pex-0.1-py3.6.egg-info'
 syncbn.cpython-36m-x86_64-linux-gnu.so

but when I check sys.modules['apex'], this shows just namespace, not like other modules:

sys.modules['apex']
...
<module 'apex' (namespace)>

other modules show like this:

sys.modules['pandas']
...
<module 'pandas' from '/usr/local/lib/python3.6/dist-packages/pandas/__init__.py'>

sys.path shows paths as follows:

sys.path
...
['/usr/lib/python36.zip',
 '/root/.ipython',
 '/root/.local/lib/python3.6/site-packages/',
 '/env/python',
 '/usr/lib/python3.6/lib-dynload',
 '/usr/local/lib/python3.6/dist-packages',
 '/usr/local/lib/python3.6/dist-packages/gitdb/ext/smmap',
 '/content/gdrive/My Drive/Colab Notebooks/kaggle-severstal-master/',
 '/usr/lib/python3.6',
 '/usr/lib/python3/dist-packages',
 '/usr/local/lib/python3.6/dist-packages/git/ext/gitdb',
 '/usr/local/lib/python3.6/dist-packages/IPython/extensions']

Could someone help me out to set the right position to read apex?

@mcarilli
Copy link
Contributor

mcarilli commented Nov 4, 2019

What directory are you attempting import from? Python automatically includes the current directory as a place it searches for packages, so if you are importing apex while you are directly in the apex directory (or even one level above I think) it may try to import directly from the repo folders instead of the install path. Make sure you are importing from a directory that is either several levels up or does not contain apex as a subdirectory. This gotcha can occur with any cloned repo containing Python code (including Pytorch itself, which happens to me occasionally).

See also #259 (comment)

@mhiro216
Copy link
Author

mhiro216 commented Nov 5, 2019

Thank you for your reply.
After restarting Colab Notebook and deleting cloned repo, I succeeded to import apex.
It still fails if I just delete cloned repo. I don't know when it works or not...
Anyway, thank you for your advice.

@mhiro216 mhiro216 closed this as completed Nov 5, 2019
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

2 participants