【问题标题】:Building wheels for torch_sparse in Colab takes forever在 Colab 中为 torch_sparse 构建轮子需要很长时间
【发布时间】:2021-07-20 22:01:34
【问题描述】:

我正在尝试在 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

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

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

【问题讨论】:

    标签: python google-colaboratory sparse-matrix torch


    【解决方案1】:

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

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

    !pip install torch-geometric \
      torch-sparse \
      torch-scatter \
      torch-cluster \
      -f https://pytorch-geometric.com/whl/torch-1.8.0+cu101.html
    

    此安装运行良好,只用了几秒钟。到目前为止,它看起来让我能够从 torch_geometric/torch_sparse 导入我需要的一切。如果我稍后遇到任何问题,我会告诉你!

    【讨论】:

      【解决方案2】:

      为了补充上一个答案,Matthias Fey 建议使用以下方法在 colab 中下载依赖项:

      !pip install -q torch-scatter -f https://data.pyg.org/whl/torch-1.9.0+cu111.html
      !pip install -q torch-sparse -f https://data.pyg.org/whl/torch-1.9.0+cu111.html
      !pip install -q git+https://github.com/pyg-team/pytorch_geometric.git
      

      Colab linkGithub link 可能会有所帮助。

      【讨论】:

        【解决方案3】:

        为了便于移植,还可以根据可用的 pytorch 版本自动提供相应 url 的路径:

        import torch
        print(torch.__version__)
        !pip install torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-{torch.__version__}.html
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2014-05-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-10-24
          相关资源
          最近更新 更多