Skip to content

Problem with torch_geometric #92

Closed
@ValerianRey

Description

@ValerianRey

Hi!
I'm trying to integrate my method UPGrad into LibMTL, but since a recent change, I'm struggling to make LibMTL work: running the trainer gives me a ModuleNotFoundError: No module named 'torch_geometric'.
For reference, I followed the installation steps and then used the following command from LibMTL/examples/nyu:

python main.py --weighting EW --arch HPS --dataset_path ./ --gpu_id 0 --scheduler step --mode train --save_path ./results --train_bs=2 --test_bs=2 --epochs=1

This import of torch_geometric was added in a recent commit (e66b411) but it seems that nothing was added to requirements.txt. Note that prior to this commit, I had no major issues when installing LibMTL.

The problem is that even after manually installing torch_geometric with pip install torch_geometric, I get the following error:

Traceback (most recent call last):
  File "main.py", line 5, in <module>
    from utils import *
  File "/home/valerian/Documents/Repos/LibMTL/examples/nyu/utils.py", line 6, in <module>
    from LibMTL.metrics import AbsMetric
  File "/home/valerian/Documents/Repos/LibMTL/LibMTL/__init__.py", line 4, in <module>
    from .trainer import Trainer
  File "/home/valerian/Documents/Repos/LibMTL/LibMTL/trainer.py", line 1, in <module>
    import torch, os, copy, torch_geometric
  File "/home/valerian/anaconda3/envs/libmtl/lib/python3.8/site-packages/torch_geometric/__init__.py", line 8, in <module>
    from .index import Index
  File "/home/valerian/anaconda3/envs/libmtl/lib/python3.8/site-packages/torch_geometric/index.py", line 461, in <module>
    @implements(aten.clone.default)
AttributeError: 'builtin_function_or_method' object has no attribute 'default'

I think the issue is that my version of torch is very old (1.8.1, as specified by requirements.txt), so a recent version of torch_geometric does not work. It seems tedious to install the right version of torch_geometric, especially given that we also need to install its dependencies (torch_sparse, torch_scatter, etc) manually (https://pytorch-geometric.readthedocs.io/en/latest/install/installation.html).

I have a few questions regarding all of this:

  • Could torch_geometric become an optional dependency, or be installed only when required, similarly to what is done with cvxpy for NashMTL? It seems that it's a big dependency that has itself a lot of dependencies, and it's definitely making it much harder to install LibMTL.
  • If not, could you tell us which versions of torch_geometric and of its dependencies worked for you?
  • Is there a possibility to update the requirements.txt file? In particular, I think enforcing the usage of such an old version of torch (1.8.1, from 2021) will cause difficulties in adding new dependencies in the future, because these dependencies (like torch_geometric) sometimes use recent features of torch.

Thanks in advance for the help.

In the meantime, and for anyone experiencing the same issue, removing torch_geometric from import torch, os, copy, torch_geometric in trainer.py works for most use-cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions