我正在尝试实现fastai预训练语言模型,它需要使用torch。运行代码后,我遇到了一些关于导入torch._C的问题。
我在我的linux系统上通过pip安装了python 3.7.1版本的torch 1.0.1.post2和cuda V7.5.17。我得到了以下错误:
Traceback (most recent call last):
File "pretrain_lm.py", line 7, in <module>
import fastai
File "/home/andira/anaconda3/lib/python3.7/site-packages/fastai/__init__.py", line 1, in <module>
from .basic_train import *
File "/home/andira/anaconda3/lib/python3.7/site-packages/fastai/basic_train.py", line 2, in <module>
from .torch_core import *
File "/home/andira/anaconda3/lib/python3.7/site-packages/fastai/torch_core.py", line 2, in <module>
from .imports.torch import *
File "/home/andira/anaconda3/lib/python3.7/site-packages/fastai/imports/__init__.py", line 2, in <module>
from .torch import *
File "/home/andira/anaconda3/lib/python3.7/site-packages/fastai/imports/torch.py", line 1, in <module>
import torch, torch.nn.functional as F
File "/home/andira/anaconda3/lib/python3.7/site-packages/torch/__init__.py", line 84, in <module>
from torch._C import *
ImportError: libtorch_python.so: cannot open shared object file: No such file or directory
所以我尝试运行了这一行:
from torch._C import *
并获得了相同的结果
ImportError: libtorch_python.so: cannot open shared object file: No such file or directory
我检查了
/home/andira/anaconda3/lib/python3.7/site-packages/torch/lib
目录,只有libcaffe2_gpu.so
和libshm.so
文件,我也找不到libtorch_python.so
。我的问题是,什么是libtorch_python.so
?我读了一些文章,大多数都涉及到未定义符号,而不是像我这样的无法打开共享对象文件:没有这样的文件或目录。我是Python和Torch的新手,非常感谢您的答复。