本篇主要针对使用torch-geometric读取数据时出现错误:
The ‘data’ object was created by an older version of PyG. If this error occurred while loading an already existing dataset, remove the ‘processed/’ directory in the dataset’s root folder and try again.”
但实际上data中没有processed文件(data中的数据为pkl格式)
一开始以为是pickle的问题,实际上最终就是torch-geometric版本不对的问题。先对其他安装进行说明:
目前使用PyG库需要的下载的whl主要为torch-cluster;torch-scatter;torch-scatter;torch-sparse;torch-spline-conv,下载方式很多教程里都有。
主要从这里下载:(先检查电脑的torch和cuda版本)
https://data.pyg.org/whl/torch-1.6.0%2Bcu102.html
(离线安装):
下载到本地后我放到 conda创建的名为(Py_G)的环境下
然后在终端中进行安装pip install +下载的全名
pip install torch_cluster-1.5.7-cp38-cp38-win_amd64.whl
在线安装 :将${CUDA}
和 ${TORCH}替换成对应cuda和torch版本
pip install torch-scatter -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
pip install torch-sparse -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
比如说:
pip install torch-scatter -f https://data.pyg.org/whl/torch-1.12.0+cu116.html
在安装完相应版本的torch-cluster;torch-scatter;torch-scatter;torch-sparse;torch-spline-conv后,所有教程都是直接:pip install torch-geometric
这时候安装的 torch-geometric2.0.X版本的,这时候读取数据就会出现,此时我们需要下载1.X.X低版本的 torch-geometric。
本文以下载1.6.0为例:
btorch-geometric · PyPI
进去后会有release history
1.选择对应的版本:
2.点进去下载文件:
3.下载
4.将下好的解压好放入编译器环境的包中:Lib\site-packages
5.打开其中的setup.py文件
6.查看安装1.6.0的torch-geometric所需要的依赖包
此处需要下载:torch,numpy,tqd,scipy,networkx,scikit-learn,numba........
7.终端下载
pip install numba
pip install networkx
......
8.完成依赖包下载后,对torch-geometric进行安装
在终端输入
Python setup.py install
9.大功告成!查看下好啦!再次运行已经不会出现说什么是由于PyG旧版本而不能读取的问题了