如何解决在 raspberrypi ubuntu20.04 中导入火炬错误
Raspberrypi 4(ram 4),ubuntu 20.04 我尝试在 raspberrypi 上安装 torch 1.7。
首先,我从 Install PyTorch on Raspberry Pi 4
下载了 Torch 1.7、torchvision 0.8 的轮文件但是 pip3 install "wheel file"
不起作用,因为 ubuntu 20.04 的默认 python3 是 python 3.8
所以我尝试使用下面的 venv 安装 3.7
$ sudo apt update
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
$ sudo apt install python3.7
$ sudo apt-get install python3.7-venv
$ python3.7 -m venv env
然后我进入venv
ubuntu@ubuntu:~/programming/torch_project$ source env/bin/activate
(env) ubuntu@ubuntu:~/programming/torch_project$ python3 --version
Python 3.7.9
然后我安装了 torch&torchvisionwheel 文件。它有效!
手电筒
Processing ./torch-1.7.0a0-cp37-cp37m-linux_aarch64.whl
Collecting future
Using cached future-0.18.2.tar.gz (829 kB)
Collecting dataclasses
Using cached dataclasses-0.6-py3-none-any.whl (14 kB)
Collecting typing-extensions
Using cached typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from torch==1.7.0a0) (1.17.4)
Building wheels for collected packages: future
Building wheel for future (setup.py) ... done
Created wheel for future: filename=future-0.18.2-py3-none-any.whl size=491058 sha256=7237fe7994e98e160ba5d310f154550191d7d1e9b1032d0f570207d38b5038e3
Stored in directory: /home/ubuntu/.cache/pip/wheels/56/b0/fe/4410d17b32f1f0c3cf54cdfb2bc04d7b4b8f4ae377e2229ba0
Successfully built future
Installing collected packages: future,dataclasses,typing-extensions,torch
手电筒
Processing ./torchvision-0.8.0a0+45f960c-cp37-cp37m-linux_aarch64.whl
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from torchvision==0.8.0a0+45f960c) (1.17.4)
Requirement already satisfied: torch in /home/ubuntu/.local/lib/python3.7/site-packages (from torchvision==0.8.0a0+45f960c) (1.7.0a0)
Requirement already satisfied: pillow>=4.1.1 in /usr/lib/python3/dist-packages (from torchvision==0.8.0a0+45f960c) (7.0.0)
Requirement already satisfied: dataclasses in /home/ubuntu/.local/lib/python3.7/site-packages (from torch->torchvision==0.8.0a0+45f960c) (0.6)
Requirement already satisfied: future in /home/ubuntu/.local/lib/python3.7/site-packages (from torch->torchvision==0.8.0a0+45f960c) (0.18.2)
Requirement already satisfied: typing-extensions in /home/ubuntu/.local/lib/python3.7/site-packages (from torch->torchvision==0.8.0a0+45f960c) (3.7.4.3)
Installing collected packages: torchvision
Successfully installed torchvision-0.8.0a0+45f960c
但是当我尝试导入火炬时..
>>> import torch
Traceback (most recent call last):
File "<stdin>",line 1,in <module>
File "/home/ubuntu/.local/lib/python3.7/site-packages/torch/__init__.py",line 189,in <module>
_load_global_deps()
File "/home/ubuntu/.local/lib/python3.7/site-packages/torch/__init__.py",line 142,in _load_global_deps
ctypes.CDLL(lib_path,mode=ctypes.RTLD_GLOBAL)
File "/usr/lib/python3.7/ctypes/__init__.py",line 364,in __init__
self._handle = _dlopen(self._name,mode)
OSError: libmpi_cxx.so.40: cannot open shared object file: No such file or directory
我该如何解决这个问题?!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。