Installation

is available for Python 3.7 to Python 3.10.

Note

We do not recommend installation as a root user on your system Python. Please setup a virtual environment, e.g., via Anaconda or Miniconda, or create a Docker image.

Quick Start

PyTorch
Your OS
Package
CUDA
Run:

Installation via Anaconda

You can now install via Anaconda for all major OS/PyTorch/CUDA combinations 🤗 If you have not yet installed , install it via conda as described in its official documentation. Given that you have installed (>=1.8.0), simply run

conda install pyg -c pyg

Warning

Conda packages are currently not available for M1/M2/M3 macs. Please install the extension packages from source.

Installation via Pip Wheels

We have outsourced a lot of functionality of to other packages, which needs to be installed in advance. These packages come with their own CPU and GPU kernel implementations based on the PyTorch C++/CUDA extension interface. We provide pip wheels for these packages for all major OS/PyTorch/CUDA combinations, see here:

Warning

Wheels are currently not available for M1/M2/M3 macs. Please install the extension packages from source.

  1. Ensure that at least 1.12.0 is installed:

    python -c "import torch; print(torch.__version__)"
    >>> 1.13.0
    
  2. Find the CUDA version was installed with:

    python -c "import torch; print(torch.version.cuda)"
    >>> 11.6
    
  3. Install the relevant packages:

    pip install pyg-lib torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
    pip install torch-geometric
    

    where ${TORCH} and ${CUDA} should be replaced by the specific and CUDA versions, respectively:

    • 1.13: ${TORCH}=1.13.0 and ${CUDA}=cpu|cu116|cu117

    • 1.12: ${TORCH}=1.12.0 and ${CUDA}=cpu|cu102|cu113|cu116

    For example, for 1.13.* and CUDA 11.6, type:

    pip install pyg-lib torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-1.13.0+cu116.html
    pip install torch-geometric
    

    For 1.12.* and CUDA 11.3, type:

    pip install pyg-lib torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-1.12.0+cu113.html
    pip install torch-geometric
    
  4. Install additional packages (optional):

    To add additional functionality to , such as k-NN and radius graph generation or SplineConv support, run

    pip install torch-cluster torch-spline-conv -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
    

    following the same procedure as mentioned above.

Note: Binaries of older versions are also provided for 1.4.0, 1.5.0, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.10.0, 1.10.1, 1.10.2, and 1.11.0 (following the same procedure). For older versions, you need to explicitly specify the latest supported version number or install via pip install --no-index in order to prevent a manual installation from source. You can look up the latest supported version number here.

Installation from Source

In case a specific version is not supported by our wheels, you can alternatively install from source:

  1. Ensure that your CUDA is setup correctly (optional):

    1. Check if is installed with CUDA support:

      python -c "import torch; print(torch.cuda.is_available())"
      >>> True
      
    2. Add CUDA to $PATH and $CPATH (note that your actual CUDA path may vary from /usr/local/cuda):

      export PATH=/usr/local/cuda/bin:$PATH
      echo $PATH
      >>> /usr/local/cuda/bin:...
      
      export CPATH=/usr/local/cuda/include:$CPATH
      echo $CPATH
      >>> /usr/local/cuda/include:...
      
    3. Add CUDA to $LD_LIBRARY_PATH on Linux and to $DYLD_LIBRARY_PATH on macOS (note that your actual CUDA path may vary from /usr/local/cuda):

      export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
      echo $LD_LIBRARY_PATH
      >>> /usr/local/cuda/lib64:...
      
      export DYLD_LIBRARY_PATH=/usr/local/cuda/lib:$DYLD_LIBRARY_PATH
      echo $DYLD_LIBRARY_PATH
      >>> /usr/local/cuda/lib:...
      
    4. Verify that nvcc is accessible from terminal:

      nvcc --version
      >>> 11.3
      
    5. Ensure that and system CUDA versions match:

      python -c "import torch; print(torch.version.cuda)"
      >>> 11.3
      
      nvcc --version
      >>> 11.3
      
  2. Install the relevant packages:

    pip install git+https://github.com/pyg-team/pyg-lib.git
    pip install torch-scatter
    pip install torch-sparse
    pip install torch-geometric
    
  3. Install additional packages (optional):

    pip install torch-cluster
    pip install torch-spline-conv
    

In rare cases, CUDA or Python path problems can prevent a successful installation. pip may even signal a successful installation, but execution simply crashes with Segmentation fault (core dumped). We collected common installation errors in the Frequently Asked Questions subsection. In case the FAQ does not help you in solving your problem, please create an issue. Before, please verify that your CUDA is set up correctly by following the official installation guide.

Frequently Asked Questions

  1. undefined symbol: **make_function_schema**: This issue signals (1) a version conflict between your installed version and the ${TORCH} version specified to install the extension packages, or (2) a version conflict between the installed CUDA version of and the ${CUDA} version specified to install the extension packages. Please verify that your version and its CUDA version match with your installation command:

    python -c "import torch; print(torch.__version__)"
    python -c "import torch; print(torch.version.cuda)"
    nvcc --version
    

    For re-installation, ensure that you do not run into any caching issues by using the pip --force-reinstall --no-cache-dir flags. In addition, the pip --verbose option may help to track down any issues during installation. If you still do not find any success in installation, please try to install the extension packages from source.