Practical overview
When it fits
Use PyG when a PyTorch workflow needs graph-specific data handling, benchmark dataset access, batching across differently sized graphs, or graph neural network training support.
Who it is for
- Python developers building graph neural networks with PyTorch
- Researchers prototyping graph-learning methods on benchmark datasets
- Teams handling graph, mesh or point-cloud data in geometric deep-learning workflows
Documented uses
- Represent nodes, edges, features, targets and other graph attributes in a PyTorch-compatible data object.
- Load and inspect benchmark datasets for graph or node prediction work.
- Batch graphs with different numbers of nodes and edges for model training.
- Apply transforms to graph and geometric data.
- Build distributed or compiled graph-neural-network training workflows.
Requirements & limits
- The core package requires PyTorch; the installation guide identifies Python 3.10 through 3.14.
- Optional extension packages add specific capabilities and may require wheels matched to the PyTorch and CUDA versions.
- The documented batching approach combines variable-size graphs through sparse block-diagonal connectivity and concatenated feature and target matrices.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install PyG for a basic Python setup
Install the core PyG package in a Python environment that already has PyTorch.
Before you start
- Python 3.10 to 3.14
- PyTorch
- A virtual environment or container is recommended.
Steps
Create or activate a virtual environment.
Install the core package with the command below.
pip install torch_geometric
Expected outcome
The core PyG package is installed; the documentation says basic use does not require external libraries beyond PyTorch.
Guide limitations
- Additional packages are needed for some features, including heterogeneous GNN operators, graph sampling and clustering, accelerated sparse reductions, or SparseTensor support.
- This is an installation recipe, not a test of the resulting environment.
Load and batch the ENZYMES graph dataset
Follow the documented example to load ENZYMES and combine graphs into mini-batches.
Before you start
- PyTorch and PyG installed
- Access to download the dataset files
Steps
Initialize
TUDatasetwithroot='/tmp/ENZYMES'andname='ENZYMES'.Create a PyG
DataLoaderwithbatch_size=32andshuffle=True.Iterate over the loader to obtain batches; PyG combines graph connectivity and features for graphs of varying sizes.
Expected outcome
A loader yields graph mini-batches, with the documented example grouping 32 graphs per batch.
Guide limitations
- The example demonstrates loading and batching, not model definition or training.
- Dataset initialization downloads and processes raw dataset files.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 12 October 2026
- Original website title
- PyG Documentation — pytorch_geometric documentation · Official homepage title · retained in its source language

