从导入torch_geometric中抛出"std::bad_alloc"实例后调用的终止



我正在用python编写并得到错误:

"终止抛出'std::bad_alloc'实例后的调用。
what(): std::bad_alloc。
Aborted (core dumps)">

经过多次调试,我发现问题的根源是:

import torch_geometric

我甚至只用这行代码创建了一个文件,但我仍然得到错误。
我正在conda环境中运行(4.10.3)我确保在conda环境中安装了torch_geometric。我试着删除和重新安装,但这不起作用。
我也试过删除和重新安装火炬/cuda。
我在谷歌上搜索了错误,但似乎只提出了数据分配问题,但我不确定这将如何成为一个问题,因为我只是导入torch_geometric。

任何想法?

这个问题是由于pytorch的版本不匹配。当前使用的pytorch是1.11.0,但当安装scatter和sparse时,使用1.10.1:

  • pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.1+cu113.html.
  • pip install torch-sparse -f https://data.pyg.org/whl/torch-1.10.1+cu113.html

所以,torch-1.10.1是用来安装scatter和sparse的,但是torch-1.11.0才是真正的版本。

只是做:

  • pip uninstall torch-scatter
  • pip uninstall torch-sparse
  • pip install torch-scatter -f https://data.pyg.org/whl/torch-1.11.0+cu113.html.
  • pip install torch-sparse -f https://data.pyg.org/whl/torch-1.11.0+cu113.html

解决此问题。

最新更新