[Python] Install torch_geometric, and torch_scatter series installation

[Python] Install torch_geometric, and torch_scatter series installation

1 Introduction

First, we need to know:

  • To install torch_geometric, you need to install torch-scatter, torch-sparse, torch-cluster, torch-spline-conv and other libraries at the same time

Therefore, if you only need torch_scatter, you can install it, but if you want torch_geometric, you need to download them all.

2. Method

2.1 Step 1: Check the CUDA version

import torch
print(torch.__version__)
print(torch.version.cuda)

Notice:

  • The versions of Pytorch and CUDA must be corresponding, otherwise, even if it is installed, it will fail to call. In general, do not install the latest version of Pytorch, because CUDA and other related libraries depend on it.
  • If you have installed other versions of CUDA or Pytorch before, you need to uninstall it before installing it. If you install it directly without uninstalling it, the system will have multiple versions. Even if you use nvcc --version to detect that the software is installed, it cannot be called normally. CUDA.

2.2 The second step: installation

## 先安装这四个
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-${
    
    TORCH}+${
    
    CUDA}.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-${
    
    TORCH}+${
    
    CUDA}.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-${
    
    TORCH}+${
    
    CUDA}.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-${
    
    TORCH}+${
    
    CUDA}.html

## 最后安装torch-geometric
pip install torch-geometric

Where {TORCH} is replaced by the version number of P y Torch, and {CUDA} is replaced by the CUDA version number obtained from the above query. CUDA version number format (cpu, cu92, cu101, cu102, cu110, cu111). For example, for PyTorch 2.0.0 and CUDA 11.7, the installation command is as follows:

pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-2.0.0+cu117.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-2.0.0+cu117.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-2.0.0+cu117.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-2.0.0+cu117.html
pip install torch-geometric

2.3 Step 3: Check whether the installation is successful

$ python
Python 3.7.0 (default, Jun 28 2018, 13:15:42)
[GCC 7.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from torch_geometric.data import DataLoader
>>>
  • No error message appears, that is, success.

3. Reference

【1】https://blog.csdn.net/qq_41800917/article/details/120282841

Guess you like

Origin blog.csdn.net/qq_51392112/article/details/130171786