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

py-call-graph incompatible with projects using torch #30

Open
gskt17 opened this issue Sep 5, 2024 · 1 comment
Open

py-call-graph incompatible with projects using torch #30

gskt17 opened this issue Sep 5, 2024 · 1 comment

Comments

@gskt17
Copy link

gskt17 commented Sep 5, 2024

I am trying to generate a call graph project which happens to use PyTorch. Running pycallgraph graphviz -- ./main.py, I get the following traceback:

Traceback (most recent call last):
  File "/var/www/PM-env/bin/pycallgraph", line 26, in <module>
    exec(__file_content)
  File "<string>", line 18, in <module>
  File [redacted for anonymization], in <module>
    import torch
  File "/var/www/PM-env/lib/python3.8/site-packages/torch/__init__.py", line 629, in <module>
    from .functional import *  # noqa: F403
  File "/var/www/PM-env/lib/python3.8/site-packages/torch/functional.py", line 6, in <module>
    import torch.nn.functional as F
  File "/var/www/PM-env/lib/python3.8/site-packages/torch/nn/__init__.py", line 1, in <module>
    from .modules import *  # noqa: F403
  File "/var/www/PM-env/lib/python3.8/site-packages/torch/nn/modules/__init__.py", line 2, in <module>
    from .linear import Identity, Linear, Bilinear, LazyLinear
  File "/var/www/PM-env/lib/python3.8/site-packages/torch/nn/modules/linear.py", line 6, in <module>
    from .. import functional as F
  File "/var/www/PM-env/lib/python3.8/site-packages/torch/nn/functional.py", line 1278, in <module>
    _VF.threshold_,
  File "/var/www/PM-env/lib/python3.8/site-packages/torch/_VF.py", line 25, in __getattr__
    def __getattr__(self, attr):
  File "/var/www/PM-env/lib/python3.8/site-packages/pycallgraph/tracer.py", line 24, in tracer
    self.processor.process(frame, event, arg, self.memory())
  File "/var/www/PM-env/lib/python3.8/site-packages/pycallgraph/tracer.py", line 169, in process
    module_path = module.__file__
  File "/var/www/PM-env/lib/python3.8/site-packages/torch/_VF.py", line 26, in __getattr__
    return getattr(self.vf, attr)
AttributeError: 'torch._C._VariableFunctionsClass' object has no attribute '__file__'

If I am reading this correctly, it means that pycallgraph cannot make a call graph of any project using PyTorch.

@rtarquini
Copy link

I'm also seeing this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants