rusty1s / pytorch_sparse

PyTorch Extension Library of Optimized Autograd Sparse Matrix Operations
MIT License
1.01k stars 147 forks source link

RuntimeError: Not compiled with CUDA support #281

Closed KS-spec closed 2 years ago

KS-spec commented 2 years ago

Hi -,

I got the message: RuntimeError: Not compiled with CUDA support How should I do to fix it? I have not any problem when I import torch_sparse.

Thanks,

File c:\Miniconda\envs\ocp-models102_2\lib\site-packages\torch_sparse\tensor.py:585, in getitem(self, index) 583 dim += 1 584 elif item.dtype == torch.long: --> 585 out = out.index_select(dim, item) 586 dim += 1 587 elif item == Ellipsis:

File c:\Miniconda\envs\ocp-models102_2\lib\site-packages\torch_sparse\index_select.py:98, in (self, dim, idx) 92 value = value[idx] 94 return SparseTensor(row=row, rowptr=None, col=col, value=value, 95 sparse_sizes=src.sparse_sizes(), is_sorted=True) ---> 98 SparseTensor.index_select = lambda self, dim, idx: index_select(self, dim, idx) 99 tmp = lambda self, idx, layout=None: index_select_nnz( # noqa 100 self, idx, layout) 101 SparseTensor.index_select_nnz = tmp

File c:\Miniconda\envs\ocp-models102_2\lib\site-packages\torch_sparse\index_select.py:15, in index_select(src, dim, idx) 12 assert idx.dim() == 1 14 if dim == 0: ---> 15 old_rowptr, col, value = src.csr() 16 rowcount = src.storage.rowcount() 18 rowcount = rowcount[idx]

File c:\Miniconda\envs\ocp-models102_2\lib\site-packages\torch_sparse\tensor.py:203, in SparseTensor.csr(self) 202 def csr(self) -> Tuple[torch.Tensor, torch.Tensor, Optional[torch.Tensor]]: --> 203 return self.storage.rowptr(), self.storage.col(), self.storage.value()

File c:\Miniconda\envs\ocp-models102_2\lib\site-packages\torch_sparse\storage.py:197, in SparseStorage.rowptr(self) 195 row = self._row 196 if row is not None: --> 197 rowptr = torch.ops.torch_sparse.ind2ptr(row, self._sparse_sizes[0]) 198 self._rowptr = rowptr 199 return rowptr

RuntimeError: Not compiled with CUDA support

rusty1s commented 2 years ago

How did you install torch-sparse? If you installed it from source, you can force CUDA installation via the FORCE_CUDA=1 environment variable.

KS-spec commented 2 years ago

Thank you for your reply. I have installed it via pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.10.2+cu102.html

Should I do force CUDA installation? I have no idea why, but I suddenly got the error.

rusty1s commented 2 years ago

Can you try to run

pip uninstall torch-sparse
pip uninstall torch-sparse
pip install --no-index torch-sparse -f https://pytorch-geometric.com/whl/torch-1.10.2+cu102.html
KS-spec commented 2 years ago

Thank you very much! I could successfully install it.