如题,最近在安装OGB的时候快被各种库的兼容问题搞疯了,看了几个教程说要一个个版本一一对应,实在是太麻烦了,然后发现官网就有解决方案:
Installation — pytorch_geometric documentation
具体方法如下:
首先确保安装了torch和cuda(有gpu的话),然后检查版本:
python -c "import torch; print(torch.__version__)"
>>> 2.1.0
python -c "import torch; print(torch.version.cuda)"
>>> 12.1
我们这里pytorch是2.1.0版本, cuda是12.1版本,然后根据官网的这个表选择对应的版本:
它会告诉你相应的安装代码,如果你的版本不在表格里面,就通过修改这个里面torch和cuda的版本:
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
我们的安装代码如下:
pip install torch_geometric
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.1.0+cu121.html
会直接帮你安装好兼容的库,注意torch_scatter, torch_sparse这些库一定要一起安装,然后通过
https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
直接找你的torch和cuda版本对应的轮子,不然要么就是一直卡在building wheels,要么就是安装了之后不兼容!!!
这样的话就不用找每个库对应的版本了, 他会直接帮你安好兼容的版本!