我正在尝试实现fastai预训练语言模型,这需要工作才能进行。运行代码后,我遇到了有关导入割炬的问题。_C
我通过pip在Linux python 3.7.1上运行它:火炬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和火炬的新手,非常感谢您的回答。
答案 0 :(得分:0)
我的问题解决了。我两次卸载了割炬pip uninstall torch; pip uninstall torch
,然后将其重新安装回了pip install torch==1.0.1.post2