rusty1s / pytorch_sparse

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

Please follow semantic versioning 0.6.13 is not backward with 0.6.12 #207

Closed gbmarc1 closed 2 years ago

gbmarc1 commented 2 years ago

The 0.6.13 version is not backward compatible to 0.6.12 while version increment only seems to be a patch.

https://semver.org/

  File "/usr/local/lib/python3.8/dist-packages/torch_geometric/data/data.py", line 3, in <module>
    from torch_geometric.typing import OptTensor, NodeType, EdgeType
  File "/usr/local/lib/python3.8/dist-packages/torch_geometric/typing.py", line 4, in <module>
    from torch_sparse import SparseTensor
  File "/usr/local/lib/python3.8/dist-packages/torch_sparse/__init__.py", line 41, in <module>
    from .tensor import SparseTensor  # noqa
  File "/usr/local/lib/python3.8/dist-packages/torch_sparse/tensor.py", line 13, in <module>
    class SparseTensor(object):
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_script.py", line 974, in script
    _compile_and_register_class(obj, _rcb, qualified_name)
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_script.py", line 67, in _compile_and_register_class
    torch._C._jit_script_class_compile(qualified_name, ast, defaults, rcb)
RuntimeError: 
Tried to access nonexistent attribute or method 'crow_indices' of type 'Tensor'.:
  File "/usr/local/lib/python3.8/dist-packages/torch_sparse/tensor.py", line 109
    def from_torch_sparse_csr_tensor(self, mat: torch.Tensor,
                                     has_value: bool = True):
        rowptr = mat.crow_indices()
                 ~~~~~~~~~~~~~~~~ <--- HERE
        col = mat.col_indices()

I have a model that was trained in 0.6.12. When reloading the model in a fresh environment with the new version, the previous error occurs.

Did you bump the minimum torch version in dependencies?

Regards,

rusty1s commented 2 years ago

I see. The minimum PyTorch version required is now indeed PyTorch 1.10.0. Everything else is fully backward compatible.

RemyLau commented 2 years ago

I'm running into a similar issue here..

    from torch_geometric.data import Data
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/torch_geometric/__init__.py", line 4, in <module>
    import torch_geometric.data
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/torch_geometric/data/__init__.py", line 1, in <module>
    from .data import Data
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/torch_geometric/data/data.py", line 9, in <module>
    from torch_sparse import SparseTensor
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/torch_sparse/__init__.py", line 41, in <module>
    from .tensor import SparseTensor  # noqa
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/torch_sparse/tensor.py", line 13, in <module>
    class SparseTensor(object):
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/torch/jit/_script.py", line 1128, in script
    _compile_and_register_class(obj, _rcb, qualified_name)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/torch/jit/_script.py", line 138, in _compile_and_register_class
    script_class = torch._C._jit_script_class_compile(qualified_name, ast, defaults, rcb)
RuntimeError: 
object has no attribute sparse_csr_tensor:
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/torch_sparse/tensor.py", line 511
            value = torch.ones(self.nnz(), dtype=dtype, device=self.device())

        return torch.sparse_csr_tensor(rowptr, col, value, self.sizes())
               ~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE

I have installed PyTorch 1.9.0. The reason is that it is the only way in my case the prevent the GLIBC error, as also have been discussed previously https://github.com/pyg-team/pytorch_geometric/issues/3593#issuecomment-1061211574

rusty1s commented 2 years ago

You can stay on 0.6.12 if you are using PyTorch 1.9.

RemyLau commented 2 years ago

Good to know @rusty1s, thanks a lot! Ideally, I would like to update the dependencies to the newer versions. I've read through a number of threads regarding this issue but haven't come across a solution that works in my case yet, except the work-around with PyTorch1.9.0. Do you have any suggestions on how to go about resolving the GLIBC issue? E.g., do you know if updating the GLIBC to version 2.27 would fix this (I'm currently on glibc2.17)?

rusty1s commented 2 years ago

Looking at the GLIB==2.27 issue is definitely on my roadmap but seems tricky to fix. The problem is that GitHub does not provide machines with GLIBC==2.17 anymore :( Hopefully I can make some progress on this in the next few weeks. In case I do, I will definitely re-build the libraries.

Note that you can always build the packages from source to avoid the GLIBC issue (e.g., by just running pip install torch-scatter), but I agree that this is not ideal. Can you also share some information about your system and why you are still on GLIBC==2.17?

RemyLau commented 2 years ago

I mainly do my dev work on the HPC at my institution, whose OS currently is CentOS version 7, so I do not have much control over the GLIBC library. The only GLIBC version available right now is 2.17. There might be a workaround by installing GLIBC_2.27 or above just for myself, but my experience and ability are a little bit lacking when it comes to configuring systems-level stuff. I will probably talk to the HPC staff and ask them to update GLIBC on the HPC if necessary.

After playing around with the PyG dependencies' installation, I think the only incompatibility came from torch-spline-conv. Leaving out torch-spline-conv or directly building from its source rather than using the binaries resolves the GLIBC issue.

rusty1s commented 2 years ago

Thanks for the info. This is interesting, in particular, because I have no idea which code in torch-spline-conv requires the GLIBC dependency. Since torch-spline-conv is an optional dependency (and installs pretty fast from source), this issue should be non-blocking for a lot of people. I will still try to make some progress on this in the future.

pakdaman commented 2 years ago

You can stay on 0.6.12 if you are using PyTorch 1.9.

I faced similar problem. Thanks @rusty1s for the suggestion. Using sing 0.6.12 version with PyTorch 1.9 resolved the issue in my case.

github-actions[bot] commented 2 years ago

This issue had no activity for 6 months. It will be closed in 2 weeks unless there is some new activity. Is this issue already resolved?

arunraja-hub commented 1 year ago

You can stay on 0.6.12 if you are using PyTorch 1.9.

Is there a list of corresponding Pytorch and PyG/sparse/scatter versions? This is really confusing As a researcher a huge chunk of my time is being spent on setting up the pytorch environment which changes for each repo. For example this environment: https://github.com/THUNLP-MT/PS-VAE/blob/main/src/requirements.txt does not even work despite it having worked last year for the repo creators. I have spent a week just on trying to setting up the environment yet to no avail. Is there a combination of Pytorch lghtning, Pytorch, Pytorch geo, pytorch sparse and scatter versions that actually work? Please help @rusty1s

rusty1s commented 1 year ago

Why would this requirements.txt file no longer work? For latest support of torch-scatter and torch-sparse for certain PyTorch versions, I suggest to take a look at https://data.pyg.org/whl/index.html