DGL安装教程

时间:2024-10-26 07:31:57

诸神缄默不语-个人****博文目录

DGL官方安装教程网址:Deep Graph Library

以下仅考虑Linux系统的情况。(在Windows上跑GNN是不是太身残志坚了)

以下对应可行的安装时间会对应附上。

注意:这里对应的cuda版本,一般情况下只要跟cudatoolkit对应上就行。

文章目录

  • 1. 安装
  • 2. 检验安装效果

1. 安装

2022.8.3
我安装PyTorch用的Python3.8,命令是conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=10.2 -c pytorch

可以直接在DGL官网选择对应的情况,复制命令行进行安装:
在这里插入图片描述

注意在能够正常使用之前还需要安装psutil包,否则就会报如下错误:

Traceback (most recent call last):
  File "", line 1, in <module>
    import 
  File "my_env/envgraph1/lib/python3.8/site-packages/dgl/__init__.py", line 25, in <module>
    from . import dataloading
  File "my_env/lib/python3.8/site-packages/dgl/dataloading/__init__.py", line 10, in <module>
    from .dataloader import *
  File "my_env/lib/python3.8/site-packages/dgl/dataloading/", line 12, in <module>
    import psutil
ModuleNotFoundError: No module named 'psutil'

安装psutil(psutil的官方下载教程网站:psutil/ at master · giampaolo/psutil):
pip install psutil
在这里插入图片描述

2. 检验安装效果

import dgl.data

dataset = dgl.data.CoraGraphDataset()
print('Number of categories:', dataset.num_classes)

输出:

my_env/lib/python3.8/site-packages/scipy/__init__.py:146: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.23.1
  (f"A NumPy version >={np_minversion} and <{np_maxversion}"
Downloading user_path/.dgl/cora_v2.zip from /dataset/cora_v2.zip...
Extracting file to user_path/.dgl/cora_v2
Finished data loading and preprocessing.
  NumNodes: 2708
  NumEdges: 10556
  NumFeats: 1433
  NumClasses: 7
  NumTrainingSamples: 140
  NumValidationSamples: 500
  NumTestSamples: 1000
Done saving data into cached files.
Number of categories: 7

(这个SciPy和numpy的版本警告我也没辙)