Unable to import PyTorch in Jetson nano

I have trouble importing PyTorch in my jetson nano (jetpack 4.4).I have successfully installed it from .whl file. please help.

Traceback (most recent call last):
  File "/code/catkin_ws/src/duckietown-safe-ml-demo/packages/safe_ml/src/ood_node.py", line 13, in <module>
    import torch
  File "/usr/local/lib/python3.6/dist-packages/torch/__init__.py", line 188, in <module>
    _load_global_deps()
  File "/usr/local/lib/python3.6/dist-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

Hello @vivek.velachhawala,

Can you try installing the following dependencies ?

sudo apt-get install libopenblas-base libopenmpi-dev

Please let us know how it goes.

regards,
Andrew
Embedded Software Engineer

yes, I did but still having same error.

<== Entrypoint
Reading package lists… Done
Building dependency tree
Reading state information… Done
libopenmpi-dev is already the newest version (4.0.3-0ubuntu1).
libopenblas-base is already the newest version (0.3.8+ds-1ubuntu0.20.04.1).
0 upgraded, 0 newly installed, 0 to remove and 289 not upgraded.
==> Launching app…
Traceback (most recent call last):
File “/code/catkin_ws/src/duckietown-safe-ml-demo/packages/safe_ml/src/ood_node.py”, line 13, in
import torch
File “/usr/local/lib/python3.6/dist-packages/torch/init.py”, line 188, in
_load_global_deps()
File “/usr/local/lib/python3.6/dist-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
^C^C^C<== App terminated!

@vivek.velachhawala,

That is interesting.

From this forum: Cannot install pytorch - #5 by dusty_nv

Seems to be the solution, however, it mentions that you need to install those dependencies before installing the pytorch wheel. Can you try reinstalling pytorch ?

regards,
Andrew
Embedded Software Developer

Hi,

Which PyTorch package do you use?
Please note that you will need to install the package that built with the same environment.

For JetPack 4.4, the latest version is v1.10.0 shared in the below link:

Thanks.

Yes, I am installing pytorch v1.10.0 using dockerfile.

I am using jetpack 4.4 and python 3.8, which pytorch version should i use?

Hi,

We only provide the package for the default Python version (3.6 in JetPack 4).
So if you need the package for 3.8, please build it from the source.

Thanks.

1 Like