Error import Pytorch

I’ve installed PyTorch from source by following the instructions on the Github repo. Everything works fine, and the installation is a success, although the problem arises when I try to import torch. This the following import error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/kevinlu/miniconda3/envs/fastai/lib/python3.6/site-packages/torch/", line 53, in <module>
    from torch._C import *
ImportError: dlopen(/Users/kevinlu/miniconda3/envs/fastai/lib/python3.6/site-packages/torch/, 10): Symbol not found: _ompi_mpi_char
  Referenced from: /Users/kevinlu/miniconda3/envs/fastai/lib/python3.6/site-packages/torch/
  Expected in: flat namespace
 in /Users/kevinlu/miniconda3/envs/fastai/lib/python3.6/site-packages/torch/

This is the issue linked below. There are workarounds in the discussion.

Best regards


I tried the workaround, still doesn’t work :frowning:

You probably have a different Python interpreter in Jupyter.
Can you print the paths on the command line and on Jupyter?

import sys
print('__Python VERSION:', sys.version)

Also run this in Jupyter:

! which python

I’m just running from my command line this is what I’m doing:

(fastai) kevinlu@Kevins-MBP:~/Documents/Move37/JeanApp (master *) $ which python
python is /Users/kevinlu/miniconda3/envs/fastai/bin/python

Then I run python

Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:14:59) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/Users/kevinlu/miniconda3/envs/fastai/lib/', '/Users/kevinlu/miniconda3/envs/fastai/lib/python3.6', '/Users/kevinlu/miniconda3/envs/fastai/lib/python3.6/lib-dynload', '/Users/kevinlu/miniconda3/envs/fastai/lib/python3.6/site-packages']

run this in jupyter please and then report back

This is what I am getting:

Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:14:59) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.0.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: ! which python

I’d recommend editing and doing clean and rebuilding.

Best regards


Tried the fix by changing:
main_libraries += ['cudart', 'nvToolsExt', 'nvrtc', 'cuda', 'mpi_cxx']
and now I’m having trouble building it, here is the output in pastebin.

1 Like

i’ll be fixing this error once and for all today. give me 8 hours more. the github issue will be updated.