linux 无法在Jetson nano(ubuntu)中导入Pytorch

9njqaruj  于 2023-03-07  发布在  Linux
关注(0)|答案(3)|浏览(198)

我在我的jetson nano(jetpack 4.4,Cuda 10.2.89)中导入PyTorch时遇到了问题,我已经成功地从.whl文件中安装了它,它在我的pip3库中。但是当我导入它时,它显示了这个错误。请帮助。

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```
7vux5j2d

7vux5j2d1#

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!

前面的答案解决了我在Jetson Nano上找不到libmpi_cxx.so.20的问题,但我在导入Torch时遇到了另一个错误。
错误为:从焊炬._C导入 * ImportError:numpy.core.multiarray无法导入
如果您有问题导入 Torch ,因为未能导入numpy按照以下步骤。

pip install numpy -I

您可以在GitHub上查看此问题以了解详细信息。

e4yzc0pl

e4yzc0pl2#

尝试执行以下操作:

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!
to94eoyn

to94eoyn3#

第一个解决方案对我很有效!应该被认为是答案!我只需要在安装丢失的软件包之前做一个额外的步骤(在我的例子中是libopenmpi-dev)

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

相关问题