torch-sparse gcc编译失败分析

目录

  • torch-sparse安装失败分析
    • 环境
    • 报错内容
    • 原因分析
    • 后记

torch-sparse安装失败分析

环境

  • Linux: Ubuntu 16.04
  • cuda: 9.0
  • cudnn: 7.3.0
  • pytorch: 1.1.0
  • python: 3.6
  • torch-geometric: 1.4.3
  • torch-sparse报错的版本:0.6.0

报错内容

/tmp/pip-install-vjwvkdbw/torch-sparse/csrc/spspmm.cpp:33:5: **error: ‘RegisterOperators’ is not a member of ‘torch’**
         torch::RegisterOperators().op("torch_sparse::spspmm_sum", &spspmm_sum);
         ^

struct TORCH_API **RegisterOperators** {
                      ^
    /tmp/pip-install-vjwvkdbw/torch-sparse/csrc/spspmm.cpp:32:13: warning: ‘registry’ defined but not used [-Wunused-variable]
     static auto registry =
                 ^
    **error: command 'gcc' failed with exit status 1**

-----------------------------------------------------------------------

Command "/home/wb/miniconda3/envs/dl/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-vjwvkdbw/torch-sparse/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-_tbk9rnv/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-vjwvkdbw/torch-sparse/

原因分析

猜测1:难道是cuda版本太低?

分析:可是我的cuda版本肯定不能改啊,改了其他项目代码不久崩了么。想想其他办法。

猜测2:pytorch版本太低?

分析:也不能改,太麻烦,其他代码也依赖。

猜测3:torch-sparse版本太高?

分析:换成 0.4.4 ,pip install torch-sparse==0.4.4 哇,成功了!!!太棒了!!!

后记

后来又报其他的错,我按照这个思路往低版本试,果然可以。

ModuleNotFoundError: No module named ‘torch_scatter’

pip install torch_geometric==1.4.1
pip install torch_sparse==0.4.4
pip install torch_scatter==1.4.0
pip install torch_cluster==1.4.5

后来我发现,这几个库都是一个哥们写的。

我找到了他的github,并找到了这些库每个版本的release记录和日期。

https://github.com/rusty1s/pytorch_sparse/releases

这一个最难安装的,版本0.4.4安装成功了,发布日期是2020/2/4 于是,我以这个时间节点为基准,其他库的发布时间不能大于这个时间,不能会出现依赖问题。

按照这个思路很快,把这一堆包的安装问题搞定了!!!

感觉自己是福尔摩斯!!!

https://github.com/rusty1s/pytorch_geometric/releases

https://github.com/rusty1s/pytorch_scatter/releases

https://github.com/rusty1s/pytorch_cluster/releases

更多内容,欢迎关注我的公众号:AI分享者

你可能感兴趣的:(Deep,Learning,GNN)