我正在尝试实施fastai pretrain语言模型,它需要火炬才能工作。运行代码后,我遇到了一些关于import torch._C的问题
我在我的linux,python 3.7.1上运行它,通过pip: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是什么?我已经阅读了一些文章,并且大多数人都谈到了未定义的符号,不能打开共享对象文件:没有像我这样的文件或目录。我是蟒蛇和火炬的新手,所以我非常感谢你的回答。
我的问题解决了。我正在卸载我的火炬两次pip uninstall torch; pip uninstall torch
,然后重新安装它回来pip install torch==1.0.1.post2