'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.
Solution 1:[1]
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 !
Solution 2:[2]
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
Solution 3:[3]
To add on to the previous answer, Matthias Fey suggested the following approach for downloading the dependencies in 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
This Colab link and Github link may help.
Solution 4:[4]
None of the above answers worked for me. The wheels on the build went round and round, round and round. I have written below what worked as of posting date:
First find your torch version:
import torch print(torch.__version__)
1.10.0+cu111
- If you're like me and your colab's cuda is not listed in pytorch-geometric's installation directions, then drawing from the installation method of their tutorial notebooks, use the following:
!pip uninstall torch-scatter torch-sparse torch-geometric torch-cluster
!pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0+cu111.html
!pip install torch-sparse -f https://data.pyg.org/whl/torch-1.10.0+cu111.html
!pip install torch-cluster -f https://data.pyg.org/whl/torch-1.10.0+cu111.html
!pip install git+https://github.com/pyg-team/pytorch_geometric.git
Note: You can use https://data.pyg.org/whl/torch-{torch.__version__}.html to replace above
import torch
!echo https://data.pyg.org/whl/torch-{torch.__version__}.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Anthony Frion |
| Solution 2 | Tom |
| Solution 3 | Abhilash Majumder |
| Solution 4 | vinceW |
