Rostyslav
Rostyslav

Reputation: 105

PyTorch torch_sparse installation without CUDA

I am new in PyTorch and I have faced one issue, namely I cannot get my torch_sparse module properly installed. In general, I wanted to use module torch_geometric - this I have installed. However, when during the execution of the program I keep receiving the error ModuleNotFoundError: No module named ‘torch_sparse’ .

I try to intall it, but when I use the command pip install torch-sparse in anaconda, I get an error:

UserWarning: CUDA initialization:Found no NVIDIA driver on your system.

My system does not have a CUDA. So how could I install torch_sparse module without it?

Thank you in advance!

Kind regards

Rostyslav

Upvotes: 8

Views: 19907

Answers (3)

Mahsa
Mahsa

Reputation: 742

Updated Answer: I used this command and it worked like a charm!

!pip install torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-2.3.0+cu121.html

Historical Answer:

I had the same problem with Google Colab. When I checked torch version using:

import torch
torch.__version__

I got 2.3.1+cu121. The latest version of torch-sparse (as of today!) works with torch-2.1.0. So I uninstalled the current torch, and installed the correct version:

!pip uninstall torch
!pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu121

You might need to restart your session for the changes to affect. And after that as mentioned in previous answers:

!pip uninstall torch-scatter torch-sparse torch-geometric torch-cluster  --y
!pip install torch-scatter -f https://data.pyg.org/whl/torch-2.1.0+cu121.html
!pip install torch-sparse -f https://data.pyg.org/whl/torch-2.1.0+cu121.html
!pip install torch-cluster -f https://data.pyg.org/whl/torch-2.1.0+cu121.html
!pip install git+https://github.com/pyg-team/pytorch_geometric.git

It worked like a charm for me! I hope it helps you too! Just keep in mind that in the future torch-sparse might get updated to the latest torch version and you don't need to downgrade your torch version.

Upvotes: 0

chakrr
chakrr

Reputation: 527

I have found the use of conda instead of pip very useful. Running the following three commands turned out to be smooth and without errors:

  1. conda install -c pyg pytorch-sparse
  2. conda install -c pyg pytorch-scatter
  3. conda install -c pyg pyg

As far as I understood from the torch-geometric docs,we should be fine with these commands on CUDA/CPU.

Upvotes: 0

Szymon Maszke
Szymon Maszke

Reputation: 24691

As outlined in in pytorch_geometric installation instructions you have to install dependencies first and torch_geometric after that.

For PyTorch 1.7.0 and CPU:

pip install --no-index torch-scatter -f https://pytorch-geometric.com/whl/torch-1.7.0+cpu.html
pip install --no-index torch-sparse -f https://pytorch-geometric.com/whl/torch-1.7.0+cpu.html
pip install --no-index torch-cluster -f https://pytorch-geometric.com/whl/torch-1.7.0+cpu.html
pip install --no-index torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.7.0+cpu.html
pip install torch-geometric

Please notice torch-1.7.0+cpu at the very end of each page

Upvotes: 13

Related Questions