


To learn GNN, you will definitely use the torch_geometric package. PyG (PyTorch Geometric) is a library built on PyTorch that allows easy writing and training of Graph Neural Networks (GNNs), suitable for various applications related to structured data. A GCNConv can be easily called with just one line of code. Below is a detailed introduction to the installation process of the torch_geometric package.
1Environment Version Check
conda activate your-evn-name
import torch
print(torch.__version__) # Check the installed version of PyTorch
print(torch.cuda.is_available()) # Check if CUDA is available. True means available, indicating GPU version of PyTorch
print(torch.cuda.get_device_name(0)) # Return GPU model
print(torch.cuda.device_count()) # Return the number of available CUDA (GPU), 0 means one
print(torch.version.cuda) # Check CUDA version

🔔Note: To install torch, you need to go to the GitHub page of the pyg-team to find pytorch-geometric. The website is https://github.com/pyg-team/pytorch_geometric. Then click on the location below to jump to the link.
After that, a new interface will pop up, as shown. Find the appropriate torch version according to your computer situation, and select the corresponding CUDA version. For me, it is the gray torch-1.8.0+cu111 selected in the image (the image is only for illustration; the actual choice is torch-1.8.0+cu111). Here is the direct URL: https://data.pyg.org/whl/

2Install Dependencies

pip install C:\Users\dell\Downloads\torch_cluster-1.5.9-cp39-cp39-win_amd64.whl
pip install C:\Users\dell\Downloads\torch_spline_conv-1.2.1-cp39-cp39-win_amd64.whl
pip install C:\Users\dell\Downloads\torch_sparse-0.6.12-cp39-cp39-win_amd64.whl
pip install C:\Users\dell\Downloads\torch_scatter-2.0.8-cp39-cp39-win_amd64.whl

pip install torch-geometric==2.0.4
3Run Test

After installation, the default matching numpy package is version 2.0.2, which may not match torch=1.8.0 in some cases, leading to code errors and inability to run correctly. It needs to be uninstalled and reinstalled with the corresponding version. I chose numpy=1.23.5 version;
In some cases, it may lead to GitHub being inaccessible. The dependency files and datasets used in the example can be obtained by replying: PyG Demo in the background! If you encounter problems, feel free to discuss in the comments section~

â–²
Follow our public account for more related materials!