注意:版本匹配很重要!
AttributeError: ‘NoneType’ object has no attribute ‘origin’
这个是因为直接使用pip install torch-sparse==某个版本``pip install torch-scatter==某个版本
,导致安装的torch-geometric
不含有-cuda.so
链接库导致的。
详情可以参考:https://github.com/pyg-team/pytorch_geometric/issues/2304
如果你使用如下办法解决这个问题:
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.8.0+cu111.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.8.0+cu111.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.8.0+cu111.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.8.0+cu111.html
pip install torch-geometric
你将会遇到这个错误
OSError: torch_sparse/_version_cuda.so: undefined symbol:
原因是使用上述办法解决会安装最新版的torch-scatter
和torch-sparse
, 最后导致版本不匹配问题。
解决办法如下:
直接到https://pytorch-geometric.com/whl/ 这里下载你需要版本的torch-scatter
和torch-sparse
, 一般延迟两到三个版本就行。