找做网站签证,个人网站备案填写,wordpress 百万ip,企业微网站怎么建设ubuntu下安装torch-geometric库#xff0c;图神经网络 开发环境 ubuntu22.04 conda 24.5.0 python 3.9 pytorch 2.0.1 cuda 11.8 
pyg的安装网上教程流传着许多安装方式#xff0c;这些安装方式主要是#xff1a;预先安装好pyg的依赖库#xff0c;这些依赖库需要对应上pyth… ubuntu下安装torch-geometric库图神经网络 开发环境 ubuntu22.04 conda 24.5.0 python 3.9 pytorch 2.0.1 cuda 11.8 
pyg的安装网上教程流传着许多安装方式这些安装方式主要是预先安装好pyg的依赖库这些依赖库需要对应上python、pytorch、cuda的版本需要小心对应很容易出错而且这些依赖库的安装推荐采用的是预先编译好的库安装。 
一、采用已编译好的包进行安装 
即先按python、pytorch、cuda版本选择对应的pyg_lib、torch_cluster、torch_scatter、torch_sparse、torch_spline_conv 版本下载到本地然后pip安装最后安装pip install torch-geometric 
1、首先我们安装pyg的 
https://github.com/pyg-team/pytorch_geometric  点击here进入https://data.pyg.org/whl/  点击你对应的torch版本及cuda版本这里选择的是torch 2.01 及 cuda 11.8 
然后进入https://data.pyg.org/whl/torch-2.0.1%2Bcu118.html 如下页面 
pyg_lib-0.2.0pt20cu118-cp310-cp310-linux_x86_64.whl
pyg_lib-0.2.0pt20cu118-cp311-cp311-linux_x86_64.whl
pyg_lib-0.2.0pt20cu118-cp38-cp38-linux_x86_64.whl
pyg_lib-0.2.0pt20cu118-cp39-cp39-linux_x86_64.whl
pyg_lib-0.3.0pt20cu118-cp310-cp310-linux_x86_64.whl
pyg_lib-0.3.0pt20cu118-cp311-cp311-linux_x86_64.whl
pyg_lib-0.3.0pt20cu118-cp38-cp38-linux_x86_64.whl
pyg_lib-0.3.0pt20cu118-cp39-cp39-linux_x86_64.whl
pyg_lib-0.3.1pt20cu118-cp310-cp310-linux_x86_64.whl
pyg_lib-0.3.1pt20cu118-cp311-cp311-linux_x86_64.whl
pyg_lib-0.3.1pt20cu118-cp38-cp38-linux_x86_64.whl
pyg_lib-0.3.1pt20cu118-cp39-cp39-linux_x86_64.whl
pyg_lib-0.4.0pt20cu118-cp310-cp310-linux_x86_64.whl
pyg_lib-0.4.0pt20cu118-cp311-cp311-linux_x86_64.whl
pyg_lib-0.4.0pt20cu118-cp38-cp38-linux_x86_64.whl
pyg_lib-0.4.0pt20cu118-cp39-cp39-linux_x86_64.whl
torch_cluster-1.6.1pt20cu118-cp310-cp310-linux_x86_64.whl
torch_cluster-1.6.1pt20cu118-cp310-cp310-win_amd64.whl
torch_cluster-1.6.1pt20cu118-cp311-cp311-linux_x86_64.whl
torch_cluster-1.6.1pt20cu118-cp311-cp311-win_amd64.whl
torch_cluster-1.6.1pt20cu118-cp38-cp38-linux_x86_64.whl
torch_cluster-1.6.1pt20cu118-cp38-cp38-win_amd64.whl
torch_cluster-1.6.1pt20cu118-cp39-cp39-linux_x86_64.whl
torch_cluster-1.6.1pt20cu118-cp39-cp39-win_amd64.whl
torch_cluster-1.6.2pt20cu118-cp310-cp310-linux_x86_64.whl
torch_cluster-1.6.2pt20cu118-cp310-cp310-win_amd64.whl
torch_cluster-1.6.2pt20cu118-cp311-cp311-linux_x86_64.whl
torch_cluster-1.6.2pt20cu118-cp311-cp311-win_amd64.whl
torch_cluster-1.6.2pt20cu118-cp38-cp38-linux_x86_64.whl
torch_cluster-1.6.2pt20cu118-cp38-cp38-win_amd64.whl
torch_cluster-1.6.2pt20cu118-cp39-cp39-linux_x86_64.whl
torch_cluster-1.6.2pt20cu118-cp39-cp39-win_amd64.whl
torch_cluster-1.6.3pt20cu118-cp310-cp310-linux_x86_64.whl
torch_cluster-1.6.3pt20cu118-cp310-cp310-win_amd64.whl
torch_cluster-1.6.3pt20cu118-cp311-cp311-linux_x86_64.whl
torch_cluster-1.6.3pt20cu118-cp311-cp311-win_amd64.whl
torch_cluster-1.6.3pt20cu118-cp38-cp38-linux_x86_64.whl
torch_cluster-1.6.3pt20cu118-cp38-cp38-win_amd64.whl
torch_cluster-1.6.3pt20cu118-cp39-cp39-linux_x86_64.whl
torch_cluster-1.6.3pt20cu118-cp39-cp39-win_amd64.whl
torch_scatter-2.1.1pt20cu118-cp310-cp310-linux_x86_64.whl
torch_scatter-2.1.1pt20cu118-cp310-cp310-win_amd64.whl
torch_scatter-2.1.1pt20cu118-cp311-cp311-linux_x86_64.whl
torch_scatter-2.1.1pt20cu118-cp311-cp311-win_amd64.whl
torch_scatter-2.1.1pt20cu118-cp38-cp38-linux_x86_64.whl
torch_scatter-2.1.1pt20cu118-cp38-cp38-win_amd64.whl
torch_scatter-2.1.1pt20cu118-cp39-cp39-linux_x86_64.whl
torch_scatter-2.1.1pt20cu118-cp39-cp39-win_amd64.whl
torch_scatter-2.1.2pt20cu118-cp310-cp310-linux_x86_64.whl
torch_scatter-2.1.2pt20cu118-cp310-cp310-win_amd64.whl
torch_scatter-2.1.2pt20cu118-cp311-cp311-linux_x86_64.whl
torch_scatter-2.1.2pt20cu118-cp311-cp311-win_amd64.whl
torch_scatter-2.1.2pt20cu118-cp38-cp38-linux_x86_64.whl
torch_scatter-2.1.2pt20cu118-cp38-cp38-win_amd64.whl
torch_scatter-2.1.2pt20cu118-cp39-cp39-linux_x86_64.whl
torch_scatter-2.1.2pt20cu118-cp39-cp39-win_amd64.whl
torch_sparse-0.6.17pt20cu118-cp310-cp310-linux_x86_64.whl
torch_sparse-0.6.17pt20cu118-cp310-cp310-win_amd64.whl
torch_sparse-0.6.17pt20cu118-cp311-cp311-linux_x86_64.whl
torch_sparse-0.6.17pt20cu118-cp311-cp311-win_amd64.whl
torch_sparse-0.6.17pt20cu118-cp38-cp38-linux_x86_64.whl
torch_sparse-0.6.17pt20cu118-cp38-cp38-win_amd64.whl
torch_sparse-0.6.17pt20cu118-cp39-cp39-linux_x86_64.whl
torch_sparse-0.6.17pt20cu118-cp39-cp39-win_amd64.whl
torch_sparse-0.6.18pt20cu118-cp310-cp310-linux_x86_64.whl
torch_sparse-0.6.18pt20cu118-cp310-cp310-win_amd64.whl
torch_sparse-0.6.18pt20cu118-cp311-cp311-linux_x86_64.whl
torch_sparse-0.6.18pt20cu118-cp311-cp311-win_amd64.whl
torch_sparse-0.6.18pt20cu118-cp38-cp38-linux_x86_64.whl
torch_sparse-0.6.18pt20cu118-cp38-cp38-win_amd64.whl
torch_sparse-0.6.18pt20cu118-cp39-cp39-linux_x86_64.whl
torch_sparse-0.6.18pt20cu118-cp39-cp39-win_amd64.whl
torch_spline_conv-1.2.2pt20cu118-cp310-cp310-linux_x86_64.whl
torch_spline_conv-1.2.2pt20cu118-cp310-cp310-win_amd64.whl
torch_spline_conv-1.2.2pt20cu118-cp311-cp311-linux_x86_64.whl
torch_spline_conv-1.2.2pt20cu118-cp311-cp311-win_amd64.whl
torch_spline_conv-1.2.2pt20cu118-cp38-cp38-linux_x86_64.whl
torch_spline_conv-1.2.2pt20cu118-cp38-cp38-win_amd64.whl
torch_spline_conv-1.2.2pt20cu118-cp39-cp39-linux_x86_64.whl
torch_spline_conv-1.2.2pt20cu118-cp39-cp39-win_amd64.whlpyg_lib、torch_cluster、torch_scatter、torch_sparse、torch_spline_conv 都逐一选择一个版本下载 注意选择对python的版本(cp310即python 3.10版本)即操作系统(linux or win) 下载完成如下所示  开始本地安装依赖库如下 
# 激活对应的conda环境
$ conda acitvate pyt2.0
# pip 安装上面5个库
$ pip install pyg_lib-0.4.0pt20cu118-cp39-cp39-linux_x86_64.whl 
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Processing ./pyg_lib-0.4.0pt20cu118-cp39-cp39-linux_x86_64.whl
Installing collected packages: pyg-lib
Successfully installed pyg-lib-0.4.0pt20cu118$ pip install torch_cluster-1.6.3pt20cu118-cp39-cp39-linux_x86_64.whl 
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Processing ./torch_cluster-1.6.3pt20cu118-cp39-cp39-linux_x86_64.whl
Requirement already satisfied: scipy in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from torch-cluster1.6.3pt20cu118) (1.13.1)
Requirement already satisfied: numpy2.3,1.22.4 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from scipy-torch-cluster1.6.3pt20cu118) (1.23.5)
Installing collected packages: torch-cluster
Successfully installed torch-cluster-1.6.3pt20cu118$ pip install torch_scatter-2.1.2pt20cu118-cp39-cp39-linux_x86_64.whl 
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Processing ./torch_scatter-2.1.2pt20cu118-cp39-cp39-linux_x86_64.whl
Installing collected packages: torch-scatter
Successfully installed torch-scatter-2.1.2pt20cu118$ pip install torch_sparse-0.6.18pt20cu118-cp39-cp39-linux_x86_64.whl 
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Processing ./torch_sparse-0.6.18pt20cu118-cp39-cp39-linux_x86_64.whl
Requirement already satisfied: scipy in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from torch-sparse0.6.18pt20cu118) (1.13.1)
Requirement already satisfied: numpy2.3,1.22.4 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from scipy-torch-sparse0.6.18pt20cu118) (1.23.5)
Installing collected packages: torch-sparse
Successfully installed torch-sparse-0.6.18pt20cu118$ pip install torch_spline_conv-1.2.2pt20cu118-cp39-cp39-linux_x86_64.whl 
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Processing ./torch_spline_conv-1.2.2pt20cu118-cp39-cp39-linux_x86_64.whl
Installing collected packages: torch-spline-conv
Successfully installed torch-spline-conv-1.2.2pt20cu118然后安装pyg pip install torch-geometric $ pip install torch-geometric
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting torch-geometricDownloading https://pypi.tuna.tsinghua.edu.cn/packages/97/f0/66ad3a5263aa16efb534aaf4e7da23ffc28c84efbbd720b0c5ec174f6242/torch_geometric-2.5.3-py3-none-any.whl (1.1 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 1.3 MB/s eta 0:00:00
Collecting tqdm (from torch-geometric)Downloading https://pypi.tuna.tsinghua.edu.cn/packages/18/eb/fdb7eb9e48b7b02554e1664afd3bd3f117f6b6d6c5881438a0b055554f9b/tqdm-4.66.4-py3-none-any.whl (78 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.3/78.3 kB 5.5 MB/s eta 0:00:00
Requirement already satisfied: numpy in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from torch-geometric) (1.23.5)
Requirement already satisfied: scipy in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from torch-geometric) (1.13.1)
Collecting fsspec (from torch-geometric)Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5e/44/73bea497ac69bafde2ee4269292fa3b41f1198f4bb7bbaaabde30ad29d4a/fsspec-2024.6.1-py3-none-any.whl (177 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 177.6/177.6 kB 1.8 MB/s eta 0:00:00
Requirement already satisfied: jinja2 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from torch-geometric) (3.1.3)
Requirement already satisfied: aiohttp in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from torch-geometric) (3.9.5)
Requirement already satisfied: requests in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from torch-geometric) (2.31.0)
Requirement already satisfied: pyparsing in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from torch-geometric) (3.0.9)
Requirement already satisfied: scikit-learn in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from torch-geometric) (1.4.2)
Requirement already satisfied: psutil5.8.0 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from torch-geometric) (5.9.0)
Requirement already satisfied: aiosignal1.1.2 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from aiohttp-torch-geometric) (1.2.0)
Requirement already satisfied: attrs17.3.0 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from aiohttp-torch-geometric) (23.1.0)
Requirement already satisfied: frozenlist1.1.1 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from aiohttp-torch-geometric) (1.4.0)
Requirement already satisfied: multidict7.0,4.5 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from aiohttp-torch-geometric) (6.0.4)
Requirement already satisfied: yarl2.0,1.0 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from aiohttp-torch-geometric) (1.9.3)
Requirement already satisfied: async-timeout5.0,4.0 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from aiohttp-torch-geometric) (4.0.3)
Requirement already satisfied: MarkupSafe2.0 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from jinja2-torch-geometric) (2.1.3)
Requirement already satisfied: charset-normalizer4,2 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from requests-torch-geometric) (2.0.4)
Requirement already satisfied: idna4,2.5 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from requests-torch-geometric) (3.4)
Requirement already satisfied: urllib33,1.21.1 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from requests-torch-geometric) (2.1.0)
Requirement already satisfied: certifi2017.4.17 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from requests-torch-geometric) (2024.6.2)
Requirement already satisfied: joblib1.2.0 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from scikit-learn-torch-geometric) (1.4.0)
Requirement already satisfied: threadpoolctl2.0.0 in /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages (from scikit-learn-torch-geometric) (2.2.0)
Installing collected packages: tqdm, fsspec, torch-geometric
Successfully installed fsspec-2024.6.1 torch-geometric-2.5.3 tqdm-4.66.4安装完成后查看一下版本 
$ conda list torch
# packages in environment at /home/myPC/miniconda3/envs/pyt-gpu-2.0:
#
# Name                    Version                   Build  Channel
pytorch                   2.0.1           gpu_cuda118py39he342708_0    defaults
torch-cluster             1.6.3pt20cu118          pypi_0    pypi
torch-geometric           2.5.3                    pypi_0    pypi
torch-scatter             2.1.2pt20cu118          pypi_0    pypi
torch-sparse              0.6.18pt20cu118          pypi_0    pypi
torch-spline-conv         1.2.2pt20cu118          pypi_0    pypi$ conda list pyg-lib
# packages in environment at /home/myPC/miniconda3/envs/pyt-gpu-2.0:
#
# Name                    Version                   Build  Channel
pyg-lib                   0.4.0pt20cu118          pypi_0    pypi 
下载的几个离线包已正常安装 
导入一下验证一下出现如下报错 
OSError: /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_cluster/_version_cuda.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs$ ipython
Python 3.9.18 (main, Sep 11 2023, 13:41:44) 
Type copyright, credits or license for more information
IPython 8.15.0 -- An enhanced Interactive Python. Type ? for help.In [1]: import torch_geometric.datasets
/home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/typing.py:54: UserWarning: An issue occurred while importing pyg-lib. Disabling its usage. Stacktrace: /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/libpyg.so: undefined symbol: _ZNK5torch8autograd4Node4nameEvwarnings.warn(fAn issue occurred while importing pyg-lib. 
/home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/typing.py:72: UserWarning: An issue occurred while importing torch-scatter. Disabling its usage. Stacktrace: /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_scatter/_version_cuda.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSswarnings.warn(fAn issue occurred while importing torch-scatter. 
/home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/typing.py:83: UserWarning: An issue occurred while importing torch-cluster. Disabling its usage. Stacktrace: /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_cluster/_version_cuda.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSswarnings.warn(fAn issue occurred while importing torch-cluster. 
/home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/typing.py:99: UserWarning: An issue occurred while importing torch-spline-conv. Disabling its usage. Stacktrace: /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_spline_conv/_version_cuda.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSswarnings.warn(
/home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/typing.py:110: UserWarning: An issue occurred while importing torch-sparse. Disabling its usage. Stacktrace: /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_sparse/_version_cuda.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSswarnings.warn(fAn issue occurred while importing torch-sparse. 
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
Cell In[1], line 1
---- 1 import torch_geometric.datasetsFile ~/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/__init__.py:1311 import torch_geometric.loader12 import torch_geometric.transforms
--- 13 import torch_geometric.datasets14 import torch_geometric.nn15 import torch_geometric.explainFile ~/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/datasets/__init__.py:10199 from .sbm_dataset import RandomPartitionGraphDataset100 from .mixhop_synthetic_dataset import MixHopSyntheticDataset
-- 101 from .explainer_dataset import ExplainerDataset102 from .infection_dataset import InfectionDataset103 from .ba2motif_dataset import BA2MotifDatasetFile ~/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/datasets/explainer_dataset.py:97 from torch_geometric.datasets.graph_generator import GraphGenerator8 from torch_geometric.datasets.motif_generator import MotifGenerator
---- 9 from torch_geometric.explain import Explanation12 class ExplainerDataset(InMemoryDataset):13     rGenerates a synthetic dataset for evaluating explainabilty algorithms,14     as described in the GNNExplainer: Generating Explanations for Graph15     Neural Networks https://arxiv.org/abs/1903.03894__ paper.(...)66             (default: :obj:None)67     File ~/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/explain/__init__.py:31 from .config import ExplainerConfig, ModelConfig, ThresholdConfig2 from .explanation import Explanation, HeteroExplanation
---- 3 from .algorithm import *  # noqa4 from .explainer import Explainer5 from .metric import *  # noqaFile ~/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/explain/algorithm/__init__.py:1
---- 1 from .base import ExplainerAlgorithm2 from .dummy_explainer import DummyExplainer3 from .gnn_explainer import GNNExplainerFile ~/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/explain/algorithm/base.py:148 from torch_geometric.explain import Explanation, HeteroExplanation9 from torch_geometric.explain.config import (10     ExplainerConfig,11     ModelConfig,12     ModelReturnType,13 )
--- 14 from torch_geometric.nn import MessagePassing15 from torch_geometric.typing import EdgeType, NodeType16 from torch_geometric.utils import k_hop_subgraphFile ~/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/nn/__init__.py:53 from .data_parallel import DataParallel4 from .to_hetero_transformer import to_hetero
---- 5 from .to_hetero_with_bases_transformer import to_hetero_with_bases6 from .to_fixed_size_transformer import to_fixed_size7 from .encoding import PositionalEncoding, TemporalEncodingFile ~/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/nn/to_hetero_with_bases_transformer.py:96 from torch import Tensor7 from torch.nn import Module, Parameter
---- 9 from torch_geometric.nn.conv import MessagePassing10 from torch_geometric.nn.dense import Linear11 from torch_geometric.nn.fx import TransformerFile ~/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/nn/conv/__init__.py:86 from .cugraph.sage_conv import CuGraphSAGEConv7 from .graph_conv import GraphConv
---- 8 from .gravnet_conv import GravNetConv9 from .gated_graph_conv import GatedGraphConv10 from .res_gated_graph_conv import ResGatedGraphConvFile ~/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_geometric/nn/conv/gravnet_conv.py:1310 from torch_geometric.typing import OptTensor, PairOptTensor, PairTensor12 try:
--- 13     from torch_cluster import knn14 except ImportError:15     knn  NoneFile ~/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_cluster/__init__.py:1816 spec  cuda_spec or cpu_spec17 if spec is not None:
--- 18     torch.ops.load_library(spec.origin)19 else:  # pragma: no cover20     raise ImportError(fCould not find module {library}_cpu in 21                       f{osp.dirname(__file__)})File ~/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch/_ops.py:643, in _Ops.load_library(self, path)638 path  _utils_internal.resolve_library_path(path)639 with dl_open_guard():640     # Import the shared library into the process, thus running its641     # static (global) initialization code in order to register custom642     # operators with the JIT.
-- 643     ctypes.CDLL(path)644 self.loaded_libraries.add(path)File ~/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/ctypes/__init__.py:382, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)379 self._FuncPtr  _FuncPtr381 if handle is None:
-- 382     self._handle  _dlopen(self._name, mode)383 else:384     self._handle  handleOSError: /home/myPC/miniconda3/envs/pyt-gpu-2.0/lib/python3.9/site-packages/torch_cluster/_version_cuda.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs上面的问题经过各种尝试又是切换pytroch的版本又是切换cuda的版本、python的版本重复下载pyg_lib、torch_cluster、torch_scatter、torch_sparse、torch_spline_conv 的其他版本还是失败逐一import torch_cluster或者import torch_scatter等发现没一个库可以用猜测可能是在conda下使用pip安装的原因燃鹅conda环境下pip安装的包又能正常使用conda list查看到pip安装的包也确实安装到了conda对应的环境目录下 
各种尝试验证下都失败了几乎绝望放弃了官网上的conda install -c pyg pyg又无法使用pip逐一安装的方式又无法使用绝望! 
二、pip一步安装 
正确的姿势只需要一步就能安装了上我们看看git官网以及pyg的官网的原文 
https://github.com/pyg-team/pytorch_geometric  https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html#  原来PyG 2.3版本以后不需要任何其他库即可安装 
赶紧把其他之前安装的依赖卸载 
# 之前未安装过这些依赖的可跳过这步
pip uninstall torch-geometric torch-scatter torch-sparse torch-spline-conv pyg-lib torch_cluster我们再看看当前的环境 运行环境如下 ubuntu 22.04 python 3.10 pytorch 2.3.0 cuda 11.8 执行安装 
pip install torch_geometric查看一下版本 
conda list torch-geometric
# packages in environment at /home/myPC/miniconda3/envs/pyg:
#
# Name                    Version                   Build  Channel
torch-geometric           2.5.3                    pypi_0    pypi验证一下无限报错 
$ ipython
Python 3.10.14 (main, May  6 2024, 19:42:50) [GCC 11.2.0]
Type copyright, credits or license for more information
IPython 8.25.0 -- An enhanced Interactive Python. Type ? for help.In [1]: import torch_geometricA module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with pybind112.12.If you are a user of the module, the easiest solution will be to
downgrade to numpy2 or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.Traceback (most recent call last):  File /home/myPC/miniconda3/envs/pyg/bin/ipython, line 11, in modulesys.exit(start_ipython())File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/IPython/__init__.py, line 130, in start_ipythonreturn launch_new_instance(argvargv, **kwargs)File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/traitlets/config/application.py, line 1075, in launch_instanceapp.start()File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/IPython/terminal/ipapp.py, line 317, in startself.shell.mainloop()File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py, line 917, in mainloopself.interact()File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py, line 910, in interactself.run_cell(code, store_historyTrue)File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/IPython/core/interactiveshell.py, line 3075, in run_cellresult  self._run_cell(File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/IPython/core/interactiveshell.py, line 3130, in _run_cellresult  runner(coro)File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/IPython/core/async_helpers.py, line 129, in _pseudo_sync_runnercoro.send(None)File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/IPython/core/interactiveshell.py, line 3334, in run_cell_asynchas_raised  await self.run_ast_nodes(code_ast.body, cell_name,File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/IPython/core/interactiveshell.py, line 3517, in run_ast_nodesif await self.run_code(code, result, async_asy):File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/IPython/core/interactiveshell.py, line 3577, in run_codeexec(code_obj, self.user_global_ns, self.user_ns)File ipython-input-1-c36e13293883, line 1, in moduleimport torch_geometricFile /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/torch_geometric/__init__.py, line 5, in modulefrom .isinstance import is_torch_instanceFile /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/torch_geometric/isinstance.py, line 8, in moduleimport torch._dynamoFile /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/torch/_dynamo/__init__.py, line 64, in moduletorch.manual_seed  disable(torch.manual_seed)File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/torch/_dynamo/decorators.py, line 50, in disablereturn DisableContext()(fn)File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py, line 410, in __call__(filename is None or trace_rules.check(fn))File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/torch/_dynamo/trace_rules.py, line 3378, in checkreturn check_verbose(obj, is_inlined_call).skippedFile /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/torch/_dynamo/trace_rules.py, line 3361, in check_verboserule  torch._dynamo.trace_rules.lookup_inner(File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/torch/_dynamo/trace_rules.py, line 3442, in lookup_innerrule  get_torch_obj_rule_map().get(obj, None)File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/torch/_dynamo/trace_rules.py, line 2782, in get_torch_obj_rule_mapobj  load_object(k)File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/torch/_dynamo/trace_rules.py, line 2811, in load_objectval  _load_obj_from_str(x[0])File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/torch/_dynamo/trace_rules.py, line 2795, in _load_obj_from_strreturn getattr(importlib.import_module(module), obj_name)File /home/myPC/miniconda3/envs/pyg/lib/python3.10/importlib/__init__.py, line 126, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File /home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/torch/nested/_internal/nested_tensor.py, line 417, in modulevaluestorch.randn(3, 3, devicemeta),
/home/myPC/miniconda3/envs/pyg/lib/python3.10/site-packages/torch/nested/_internal/nested_tensor.py:417: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at /home/conda/feedstock_root/build_artifacts/libtorch_1715556200933/work/torch/csrc/utils/tensor_numpy.cpp:84.)valuestorch.randn(3, 3, devicemeta),numpy库又有问题不对了尝试更新一下numpy到2.0版本 
conda install -c conda-forge numpy2.0再次测试 
ipython
Python 3.10.14 (main, May  6 2024, 19:42:50) [GCC 11.2.0]
Type copyright, credits or license for more information
IPython 8.25.0 -- An enhanced Interactive Python. Type ? for help.In [1]: import torch_geometric这次没报任何错误完美 
总结torch-geometric版本组合 可行的组合版本(亲测)python 3.10  pytroch2.3  cuda11.8  torch-geometric 2.5.3  numpy 2.0 另外一种版本组合(亲测)python3.12  pytroch2.3  cuda11.8  torch-geometric 2.5.3  numpy 1.26 
 文章转载自: http://www.morning.znsyn.cn.gov.cn.znsyn.cn http://www.morning.qrqg.cn.gov.cn.qrqg.cn http://www.morning.kdgcx.cn.gov.cn.kdgcx.cn http://www.morning.trkl.cn.gov.cn.trkl.cn http://www.morning.mcbqq.cn.gov.cn.mcbqq.cn http://www.morning.hkcjx.cn.gov.cn.hkcjx.cn http://www.morning.mfqmk.cn.gov.cn.mfqmk.cn http://www.morning.mlbdr.cn.gov.cn.mlbdr.cn http://www.morning.dncgb.cn.gov.cn.dncgb.cn http://www.morning.wtnyg.cn.gov.cn.wtnyg.cn http://www.morning.lfqnk.cn.gov.cn.lfqnk.cn http://www.morning.kpfds.cn.gov.cn.kpfds.cn http://www.morning.nktgj.cn.gov.cn.nktgj.cn http://www.morning.yrjhr.cn.gov.cn.yrjhr.cn http://www.morning.xnpj.cn.gov.cn.xnpj.cn http://www.morning.nj-ruike.cn.gov.cn.nj-ruike.cn http://www.morning.fxzlg.cn.gov.cn.fxzlg.cn http://www.morning.xnqjs.cn.gov.cn.xnqjs.cn http://www.morning.ypxyl.cn.gov.cn.ypxyl.cn http://www.morning.lxlfr.cn.gov.cn.lxlfr.cn http://www.morning.lhygbh.com.gov.cn.lhygbh.com http://www.morning.mjdbd.cn.gov.cn.mjdbd.cn http://www.morning.deanzhu.com.gov.cn.deanzhu.com http://www.morning.gtkyr.cn.gov.cn.gtkyr.cn http://www.morning.xnrgb.cn.gov.cn.xnrgb.cn http://www.morning.lsssx.cn.gov.cn.lsssx.cn http://www.morning.zwsgl.cn.gov.cn.zwsgl.cn http://www.morning.grlth.cn.gov.cn.grlth.cn http://www.morning.qgzmz.cn.gov.cn.qgzmz.cn http://www.morning.yydeq.cn.gov.cn.yydeq.cn http://www.morning.wdhzk.cn.gov.cn.wdhzk.cn http://www.morning.mttck.cn.gov.cn.mttck.cn http://www.morning.lxqyf.cn.gov.cn.lxqyf.cn http://www.morning.qptbn.cn.gov.cn.qptbn.cn http://www.morning.wgrl.cn.gov.cn.wgrl.cn http://www.morning.krdmn.cn.gov.cn.krdmn.cn http://www.morning.rrqgf.cn.gov.cn.rrqgf.cn http://www.morning.dyhlm.cn.gov.cn.dyhlm.cn http://www.morning.ryztl.cn.gov.cn.ryztl.cn http://www.morning.mxnfh.cn.gov.cn.mxnfh.cn http://www.morning.khdw.cn.gov.cn.khdw.cn http://www.morning.qyfrd.cn.gov.cn.qyfrd.cn http://www.morning.qbgdy.cn.gov.cn.qbgdy.cn http://www.morning.wyrsn.cn.gov.cn.wyrsn.cn http://www.morning.rfxg.cn.gov.cn.rfxg.cn http://www.morning.brmbm.cn.gov.cn.brmbm.cn http://www.morning.nyhtf.cn.gov.cn.nyhtf.cn http://www.morning.ymqrc.cn.gov.cn.ymqrc.cn http://www.morning.jstggt.cn.gov.cn.jstggt.cn http://www.morning.kgnrh.cn.gov.cn.kgnrh.cn http://www.morning.wxqmc.cn.gov.cn.wxqmc.cn http://www.morning.mkydt.cn.gov.cn.mkydt.cn http://www.morning.hhqjf.cn.gov.cn.hhqjf.cn http://www.morning.dlwzm.cn.gov.cn.dlwzm.cn http://www.morning.mqzcn.cn.gov.cn.mqzcn.cn http://www.morning.njddz.cn.gov.cn.njddz.cn http://www.morning.pqchr.cn.gov.cn.pqchr.cn http://www.morning.lkhfm.cn.gov.cn.lkhfm.cn http://www.morning.krzrg.cn.gov.cn.krzrg.cn http://www.morning.hwycs.cn.gov.cn.hwycs.cn http://www.morning.tplht.cn.gov.cn.tplht.cn http://www.morning.bcjbm.cn.gov.cn.bcjbm.cn http://www.morning.grzpc.cn.gov.cn.grzpc.cn http://www.morning.qsmmq.cn.gov.cn.qsmmq.cn http://www.morning.sxfnf.cn.gov.cn.sxfnf.cn http://www.morning.wplbs.cn.gov.cn.wplbs.cn http://www.morning.mrfbp.cn.gov.cn.mrfbp.cn http://www.morning.lbrrn.cn.gov.cn.lbrrn.cn http://www.morning.gybnk.cn.gov.cn.gybnk.cn http://www.morning.sogou66.cn.gov.cn.sogou66.cn http://www.morning.tnhmp.cn.gov.cn.tnhmp.cn http://www.morning.rwfj.cn.gov.cn.rwfj.cn http://www.morning.stflb.cn.gov.cn.stflb.cn http://www.morning.qxxj.cn.gov.cn.qxxj.cn http://www.morning.rtlth.cn.gov.cn.rtlth.cn http://www.morning.mwbqk.cn.gov.cn.mwbqk.cn http://www.morning.qhczg.cn.gov.cn.qhczg.cn http://www.morning.mdtfh.cn.gov.cn.mdtfh.cn http://www.morning.xfyjn.cn.gov.cn.xfyjn.cn http://www.morning.qxmys.cn.gov.cn.qxmys.cn