在 Colab 中为 torch_sparse 构建轮子需要永远

Ant*_*ion 5 python sparse-matrix torch google-colaboratory

我正在尝试在 Google Colab 上运行以下内容: !pip install torch_sparse

起初,它似乎工作正常:

Collecting torch_sparse
  Downloading https://files.pythonhosted.org/packages/9a/86/699eb78ea7ce259da7f9953858ec2a064e4e5f5e6bf7de53aa6c8bb8b9a8/torch_sparse-0.6.9.tar.gz
Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from torch_sparse) (1.4.1)
Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.7/dist-packages (from scipy->torch_sparse) (1.19.5)
Building wheels for collected packages: torch-sparse
Run Code Online (Sandbox Code Playgroud)

但从这里开始,它会一直运行,不会输出任何错误消息,并且轮子永远不会被构建。

我的 Colab 环境是托管的并使用 GPU 加速器。我也可以预先安装火炬并初始化 cuda,但它不会改变任何东西。

小智 18

将之前的所有答案放在一起,这里是无论 colabs 运行时都应该工作的代码片段

import torch

!pip uninstall torch-scatter torch-sparse torch-geometric torch-cluster  --y
!pip install torch-scatter -f https://data.pyg.org/whl/torch-{torch.__version__}.html
!pip install torch-sparse -f https://data.pyg.org/whl/torch-{torch.__version__}.html
!pip install torch-cluster -f https://data.pyg.org/whl/torch-{torch.__version__}.html
!pip install git+https://github.com/pyg-team/pytorch_geometric.git
Run Code Online (Sandbox Code Playgroud)


Ant*_*ion 6

安装实际上在 30 分钟到 1 小时后完成(我没有确切的时间)。但是,在尝试导入 torch_sparse 时,我遇到了此处描述的问题:Google Colab 上的 PyTorch Geometric CUDA 安装问题

我尝试应用最受欢迎的答案,但由于它似乎已过时,我将其更新为以下内容:

!pip install torch-geometric \
  torch-sparse \
  torch-scatter \
  torch-cluster \
  -f https://pytorch-geometric.com/whl/torch-1.8.0+cu101.html
Run Code Online (Sandbox Code Playgroud)

这个安装工作​​得很好,只花了几秒钟。到目前为止,它似乎使我能够从 torch_geometric/torch_sparse 导入我需要的所有内容。如果我以后遇到任何问题,我会告诉你!