0

I having trouble importing PyTorch in my jetson nano (jetpack 4.4, Cuda 10.2.89), I have successfully installed it from .whl file and it is in my pip3 lib. But when I import it, it shows this error. Please help.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/parikshit/.local/lib/python3.6/site-packages/torch/__init__.py", line 188, in <module>
    _load_global_deps()
  File "/home/parikshit/.local/lib/python3.6/site-packages/torch/__init__.py", line 141, in _load_global_deps
    ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
  File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libmpi_cxx.so.20: cannot open shared object file: No such file or directory```

3 Answers3

1
cd /home/parikshit/.local/lib/python3.6/site-packages/torch ls
# You should find a .so file. Run the following command on that file ldd the_file_you_found.so
#In the output you should see "not found"
#To find out which apt packages provide this .so: sudo apt install apt-file sudo apt-file update
#Now search for that "not found" library file. Example: apt-file search blah.so.100
#In the first part of each line you will see the name of the file that you need to install. Example: sudo apt install lib-hello
#Enjoy!

The previous answer resolve my issue about not finding libmpi_cxx.so.20 on Jetson Nano but I have encountered a different error while importing torch.

Error is: from torch._C import * ImportError: numpy.core.multiarray failed to import

If you have problem importing torch because of failed to import numpy follow the step below.

pip install numpy -I

You can check the issue on GitHub for details.

0

Try to do the following:

cd /home/parikshit/.local/lib/python3.6/site-packages/torch
ls
# You should find a .so file. Run the following command on that file
ldd the_file_you_found.so
#In the output you should see "not found"
#To find out which apt packages provide this .so:
sudo apt install apt-file
sudo apt-file update
#Now search for that "not found" library file. Example:
apt-file search blah.so.100
#In the first part of each line you will see the name of the file that you need to install. Example:
sudo apt install lib-hello
#Enjoy!
cloud_IaaS
  • 91
  • 2
  • 6
0

The first solution worked for me! Should be recognized as the answer! I just had to do an extra step before installing the missing package (libopenmpi-dev in my case)

$ sudo dpkg --remove --force-all libopenmpi-dev
$ sudo apt install libopenmpi-dev