error when running test script:
I had installed the graph gym step by step as readme mentioned, But I got this error:
Traceback (most recent call last):
File "main.py", line 5, in
How Can I solve this issue?
Here is the answer from gpt4: The error message indicates that the torch_sparse package is attempting to access a method crow_indices on a torch.Tensor object which does not exist. This could be due to several reasons: Version Incompatibility: The version of PyTorch you're using might not be compatible with the version of torch_sparse. The crow_indices method might have been introduced in a newer version of PyTorch, and if you're using an older version, this method would not be available. Incorrect Tensor Type: The function from_torch_sparse_csr_tensor is expecting a tensor of type CSR (Compressed Sparse Row), which should have the method crow_indices. If the tensor mat is not of the correct sparse format, this method would not be present. To solve this issue, consider the following steps: Update PyTorch: Ensure that you're using the latest version of PyTorch that supports CSR format and has the crow_indices method for sparse tensors. bash 复制 pip install --upgrade torch Check Tensor Format: Make sure that the tensor you're providing to from_torch_sparse_csr_tensor is indeed a CSR tensor. In PyTorch, CSR tensors are created with torch.sparse_csr_tensor. Compatibility Check: Verify that all related libraries (torch_geometric, torch_sparse, and torch) are compatible with each other. Sometimes, libraries are updated to leverage new features in dependencies, and using mismatched versions can cause errors. Environment Clean-Up: If you're working in a conda environment and encountering package conflicts, it may be helpful to create a new environment from scratch, ensuring that you install packages that are compatible with each other. bash
conda create -n new_env_name python=3.7 conda activate new_env_name pip install torch torch_geometric torch_sparse Please replace new_env_name with your desired environment name and adjust the Python version if needed. If after these steps you're still facing issues, it could be helpful to check the documentation of torch_sparse or open an issue on the relevant GitHub repository for assistance from the developers.
Is this correct answer? I have been tried to install graphgym for month, and called some professional helpers, but still don't work, what other information I need provide to you, then you can help me to install the graphgym successfully?
When I am import these torch packages, I got this error: In [1]: import torch_geometric
RuntimeError Traceback (most recent call last)
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch_geometric/init.py in
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch_geometric/utils/init.py in
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch_geometric/utils/scatter.py in
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch_geometric/typing.py in
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch_sparse/init.py in
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch_sparse/tensor.py in
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch/jit/_script.py in script(obj, optimize, _frames_up, _rcb) 972 if _rcb is None: 973 _rcb = _jit_internal.createResolutionCallbackFromFrame(_frames_up + 1) --> 974 _compile_and_register_class(obj, _rcb, qualified_name) 975 return obj 976 else:
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch/jit/_script.py in _compile_and_register_class(obj, rcb, qualified_name) 65 ast = get_jit_class_def(obj, obj.name) 66 defaults = torch.jit.frontend.get_default_args_for_class(obj) ---> 67 torch._C._jit_script_class_compile(qualified_name, ast, defaults, rcb) 68 torch.jit._state._add_script_class(obj, qualified_name) 69
RuntimeError: Tried to access nonexistent attribute or method 'crow_indices' of type 'Tensor'.: File "/data02/home/scv9476/.conda/envs/graphgym_env/lib/python3.7/site-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()
In [2]: import torch_scatter
In [3]: import torch_sparse
RuntimeError Traceback (most recent call last)
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch_sparse/init.py in
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch_sparse/tensor.py in
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch/jit/_script.py in script(obj, optimize, _frames_up, _rcb) 972 if _rcb is None: 973 _rcb = _jit_internal.createResolutionCallbackFromFrame(_frames_up + 1) --> 974 _compile_and_register_class(obj, _rcb, qualified_name) 975 return obj 976 else:
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch/jit/_script.py in _compile_and_register_class(obj, rcb, qualified_name) 65 ast = get_jit_class_def(obj, obj.name) 66 defaults = torch.jit.frontend.get_default_args_for_class(obj) ---> 67 torch._C._jit_script_class_compile(qualified_name, ast, defaults, rcb) 68 torch.jit._state._add_script_class(obj, qualified_name) 69
RuntimeError: class 'torch.torch_sparse.tensor.SparseTensor' already defined.
In [4]: import torch_cluster
RuntimeError Traceback (most recent call last)
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch_cluster/init.py in
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch_cluster/rw.py in walk_length from all node indices
20 in :obj:start in the graph given by :obj:(row, col) as described in the
~/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch/jit/_script.py in script(obj, optimize, _frames_up, _rcb) 988 _rcb = _jit_internal.createResolutionCallbackFromClosure(obj) 989 fn = torch._C._jit_script_compile( --> 990 qualified_name, ast, _rcb, get_default_args(obj) 991 ) 992 # Forward docstrings
RuntimeError:
General Union types are not currently supported. Only Union[T, NoneType] (i.e. Optional[T]) is supported.:
File "/data02/home/scv9476/.conda/envs/graphgym_env/lib/python3.7/site-packages/torch_cluster/rw.py", line 18
num_nodes: Optional[int] = None,
return_edge_indices: bool = False,
) -> Union[Tensor, Tuple[Tensor, Tensor]]:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
"""Samples random walks of length :obj:walk_length from all node indices
in :obj:start in the graph given by :obj:(row, col) as described in the
I think may be these torch packages are incompatible ? Do you know any way that I can install these packages which are not incompatible at all and can run your graphgym?