MindSpore Graph Learning( 二 )

如果看到以上的消息,那就表示编译构建成功了,接下来只要把生成的whl包使用pip进行安装即可:
$ python3 -m pip install ./output/mindspore_gl_gpu-0.1-cp39-cp39-linux_x86_64.whlProcessing ./output/mindspore_gl_gpu-0.1-cp39-cp39-linux_x86_64.whlRequirement already satisfied: Cython in /home/dechin/.local/lib/python3.9/site-packages (from mindspore-gl-gpu==0.1) (0.29.32)Requirement already satisfied: astpretty in /home/dechin/.local/lib/python3.9/site-packages (from mindspore-gl-gpu==0.1) (3.0.0)Requirement already satisfied: ast-decompiler>=0.3.2 in /home/dechin/.local/lib/python3.9/site-packages (from mindspore-gl-gpu==0.1) (0.7.0)Requirement already satisfied: scikit-learn>=0.24.2 in /home/dechin/.local/lib/python3.9/site-packages (from mindspore-gl-gpu==0.1) (1.1.3)Requirement already satisfied: threadpoolctl>=2.0.0 in /home/dechin/.local/lib/python3.9/site-packages (from scikit-learn>=0.24.2->mindspore-gl-gpu==0.1) (3.1.0)Requirement already satisfied: joblib>=1.0.0 in /home/dechin/.local/lib/python3.9/site-packages (from scikit-learn>=0.24.2->mindspore-gl-gpu==0.1) (1.2.0)Requirement already satisfied: scipy>=1.3.2 in /home/dechin/anaconda3/envs/mindspore16/lib/python3.9/site-packages (from scikit-learn>=0.24.2->mindspore-gl-gpu==0.1) (1.5.3)Requirement already satisfied: numpy>=1.17.3 in /home/dechin/anaconda3/envs/mindspore16/lib/python3.9/site-packages (from scikit-learn>=0.24.2->mindspore-gl-gpu==0.1) (1.23.2)Installing collected packages: mindspore-gl-gpuSuccessfully installed mindspore-gl-gpu-0.1我们可以用如下指令验证一下mindspore-gl是否安装成功(后面的告警信息是MindSpore产生的,不是mindspore-gl产生的,一般情况下,我们可以忽视掉):
$ python3 -c 'import mindspore_gl'[WARNING] ME(3662914:140594637309120,MainProcess):2022-11-09-17:22:29.348.03 [mindspore/run_check/_check_version.py:189] Cuda ['10.1', '11.1'] version(need by mindspore-gpu) is not found, please confirm that the path of cuda is set to the env LD_LIBRARY_PATH, please refer to the installation guidelines: https://www.mindspore.cn/install[WARNING] ME(3662914:140594637309120,MainProcess):2022-11-09-17:22:29.350.73 [mindspore/run_check/_check_version.py:189] Cuda ['10.1', '11.1'] version(need by mindspore-gpu) is not found, please confirm that the path of cuda is set to the env LD_LIBRARY_PATH, please refer to the installation guidelines: https://www.mindspore.cn/install[WARNING] ME(3662914:140594637309120,MainProcess):2022-11-09-17:22:29.351.54 [mindspore/run_check/_check_version.py:189] Cuda ['10.1', '11.1'] version(need by mindspore-gpu) is not found, please confirm that the path of cuda is set to the env LD_LIBRARY_PATH, please refer to the installation guidelines: https://www.mindspore.cn/install[WARNING] ME(3662914:140594637309120,MainProcess):2022-11-09-17:22:29.352.40 [mindspore/run_check/_check_version.py:189] Cuda ['10.1', '11.1'] version(need by mindspore-gpu) is not found, please confirm that the path of cuda is set to the env LD_LIBRARY_PATH, please refer to the installation guidelines: https://www.mindspore.cn/install[WARNING] ME(3662914:140594637309120,MainProcess):2022-11-09-17:22:29.352.94 [mindspore/run_check/_check_version.py:189] Cuda ['10.1', '11.1'] version(need by mindspore-gpu) is not found, please confirm that the path of cuda is set to the env LD_LIBRARY_PATH, please refer to the installation guidelines: https://www.mindspore.cn/install[WARNING] ME(3662914:140594637309120,MainProcess):2022-11-09-17:22:29.353.43 [mindspore/run_check/_check_version.py:189] Cuda ['10.1', '11.1'] version(need by mindspore-gpu) is not found, please confirm that the path of cuda is set to the env LD_LIBRARY_PATH, please refer to the installation guidelines: https://www.mindspore.cn/install[WARNING] ME(3662914:140594637309120,MainProcess):2022-11-09-17:22:29.353.91 [mindspore/run_check/_check_version.py:189] Cuda ['10.1', '11.1'] version(need by mindspore-gpu) is not found, please confirm that the path of cuda is set to the env LD_LIBRARY_PATH, please refer to the installation guidelines: https://www.mindspore.cn/installmindspore-gl的简单案例我们先考虑这样一个比较基础的案例,就是最简单的一个全连接图 , 一个三角形 。其顶点编号分别为0、1、2 , 节点值分别为1、2、3,但是这里需要注意的一点是:mindspore-gl所构建的图是有向图,如果我们需要构建一个无向图 , 那么就需要手动copy+concat一份反方向的参数 。mindspore-gl的一种典型的使用方法,是使用稀疏形式的近邻表COO去定义一个图结构GraphField,再把图作为GNNCell的一个入参传进去 。
在计算的过程中,mindspore-gl会先执行一步编译 。mindspore-gl支持用户使用一个非常简单的for循环去对图的所有节点或者邻近节点进行遍历,然后在后台对该操作进行优化和编译 。为了展示编译成效和语法的简洁,mindspore-gl会在编译过程中把没有mindspore-gl支持下的语法都展示出来 , 从对比中可以看出,mindspore-gl极大程度上提高了编程的便利性 。

推荐阅读