Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import pyg_lib fails due to AttributeError: module 'pyg_lib' has no attribute 'ops' #331

Open
ryrl970311 opened this issue Jul 27, 2024 · 1 comment

Comments

@ryrl970311
Copy link

ryrl970311 commented Jul 27, 2024

🐛 Describe the bug

import torch_sparse

When I run the code above, it raise an error that pyg_lib has no attribute 'ops'. How shoud I solve this problem?

AttributeError                            Traceback (most recent call last)
Cell In[48], line 2
      1 # import pyg_lib
----> 2 import torch_sparse

File ~/venvs/versions/3.12.4/torch/lib/python3.12/site-packages/torch_sparse/__init__.py:39
     31     if t_major != major:
     32         raise RuntimeError(
     33             f'Detected that PyTorch and torch_sparse were compiled with '
     34             f'different CUDA versions. PyTorch has CUDA version '
     35             f'{t_major}.{t_minor} and torch_sparse has CUDA version '
     36             f'{major}.{minor}. Please reinstall the torch_sparse that '
     37             f'matches your PyTorch install.')
---> 39 from .storage import SparseStorage  # noqa
     40 from .tensor import SparseTensor  # noqa
     41 from .transpose import t  # noqa

File ~/venvs/versions/3.12.4/torch/lib/python3.12/site-packages/torch_sparse/storage.py:7
      4 import torch
      5 from torch_scatter import scatter_add, segment_csr
----> 7 from torch_sparse.utils import Final, index_sort
      9 layouts: Final[List[str]] = ['coo', 'csr', 'csc']
     12 def get_layout(layout: Optional[str] = None) -> str:

File ~/venvs/versions/3.12.4/torch/lib/python3.12/site-packages/torch_sparse/utils.py:5
      1 from typing import Any, Optional, Tuple
      3 import torch
----> 5 import torch_sparse.typing
      6 from torch_sparse.typing import pyg_lib
      8 try:

File ~/venvs/versions/3.12.4/torch/lib/python3.12/site-packages/torch_sparse/typing.py:4
      2     import pyg_lib  # noqa
      3     WITH_PYG_LIB = True
----> 4     WITH_INDEX_SORT = hasattr(pyg_lib.ops, 'index_sort')
      5 except ImportError:
      6     pyg_lib = object

AttributeError: module 'pyg_lib' has no attribute 'ops'

Environment

  • pyg-lib version: 0.4.0+pt23
  • PyTorch version:2.3.1
  • OS: MacOS
  • Python version:3.12.4
  • CUDA/cuDNN version:
  • How you installed PyTorch and pyg-lib (conda, pip, source): pip
  • Any other relevant information:
@ryrl970311 ryrl970311 added the bug label Jul 27, 2024
@akihironitta
Copy link
Member

What's the command you ran to install pyg-lib?

@akihironitta akihironitta changed the title pyg_lib has not attribute ops import pyg_lib fails due to AttributeError: module 'pyg_lib' has no attribute 'ops' Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants