Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building wheels for torch_sparse in Colab takes forever

I am trying to run the following on Google Colab : !pip install torch_sparse

At first, it seems to be working fine:

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

But from here it just keeps running forever, without outputting any error message, and the wheels never get built.

My Colab environment is hosted and uses a GPU accelerator. I can also install torch and initialize cuda beforehand, but it doesn't change anything.

like image 626
Anthony Frion Avatar asked Apr 27 '21 14:04

Anthony Frion


2 Answers

The installation actually got completed after 30 minutes to 1 hour (I don't have the exact timing). However, when trying to import torch_sparse I had the issue described here : PyTorch Geometric CUDA installation issues on Google Colab

I tried applying the most popular answer, but since it seems to be obsolete I updated it to the following :

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

This installation worked just fine and took only a few seconds. So far, it looks like it makes me able to import everything I need from torch_geometric/torch_sparse. I'll tell you if I experience any issue with this later !

like image 107
Anthony Frion Avatar answered Oct 31 '22 21:10

Anthony Frion


To ease portability, it is also possible to automatically provide the path to the appropriate url given the available pytorch version:

import torch
print(torch.__version__)
!pip install torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-{torch.__version__}.html
like image 45
Tom Avatar answered Oct 31 '22 20:10

Tom