我在dgl(DeepMind的Deep Graph Library)中导入pytorch时遇到错误,具体是:
ImportError:/home/user/anaconda3/envs/my_env/lib/python3.7/site-packages/torch/lib/libtorch.so.1:未定义的符号:nvrtcGetProgramLogSize
我试图重新安装pytorch(使用卸载重新安装conda un/install
)。我也在Google中搜索,发现了这个https://github.com/pytorch/pytorch/issues/14973。在那里,他们解决它在连接libnvrtc.so
和libcuda.so
,但我不知道这意味着什么。有人知道吗?
这是基本代码:
import dgl from parseador import train_df g = dgl.DGLGraph() g.add_nodes(5) g.add_edges([0, 0, 0, 0], [1, 2, 3, 4]) g.ndata['h'] = th.randn(5, 3) g.edata['h'] = th.randn(4, 4)
这是错误:
Traceback (most recent call last): File "/home/user/Documentos/Repo/grafos.py", line 1, inimport dgl File "/home/user/anaconda3/envs/my_env/lib/python3.7/site-packages/dgl/__init__.py", line 2, in from . import function File "/home/user/anaconda3/envs/my_env/lib/python3.7/site-packages/dgl/function/__init__.py", line 5, in from .message import * File "/home/user/anaconda3/envs/my_env/lib/python3.7/site-packages/dgl/function/message.py", line 7, in from .. import backend as F File "/home/user/anaconda3/envs/my_env/lib/python3.7/site-packages/dgl/backend/__init__.py", line 46, in load_backend(os.environ.get('DGLBACKEND', 'pytorch').lower()) File "/home/user/anaconda3/envs/my_env/lib/python3.7/site-packages/dgl/backend/__init__.py", line 18, in load_backend mod = importlib.import_module('.%s' % mod_name, __name__) File "/home/user/anaconda3/envs/my_env/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/home/user/anaconda3/envs/my_env/lib/python3.7/site-packages/dgl/backend/pytorch/__init__.py", line 1, in from .tensor import * File "/home/user/anaconda3/envs/my_env/lib/python3.7/site-packages/dgl/backend/pytorch/tensor.py", line 5, in import torch as th File "/home/user/anaconda3/envs/my_env/lib/python3.7/site-packages/torch/__init__.py", line 102, in from torch._C import * ImportError: /home/user/anaconda3/envs/my_env/lib/python3.7/site-packages/torch/lib/libtorch.so.1: undefined symbol: nvrtcGetProgramLogSize
如何解决此错误?前一段时间,我在Windows 10中正确运行了此代码,而现在我正在运行Ubuntu 18.04。
我也遇到了这个问题,但是我实际上想使用GPU,因此安装pytorch-cpu
不是我的选择。
相反,pytorch
从pytorch
渠道安装软件包(而不是defaults
)为我解决了这个问题:conda install pytorch --channel pytorch