Git Product home page Git Product logo

Comments (6)

tanayag avatar tanayag commented on July 21, 2024 1

You increase the recursion depth by doing the following(change the depth as per your need):

import sys
sys.setrecursionlimit(1000000)

But the make_dot function took forever to run, we had a very deep network, with tons of multi-headed attention nodes and what not.

from pytorchviz.

albanD avatar albanD commented on July 21, 2024

That's interesting...
Could you share a code sample that we can use to reproduce that (on colab for example)?

from pytorchviz.

nihirv avatar nihirv commented on July 21, 2024

I have a similar usecase - I'm getting this error too.

Maybe our models are too big to be visualised?

  File "multi30k_main.py", line 67, in training_step
    make_dot(loss_lm, params=dict(self.model.model.named_parameters())).render("model_lm", format="png")
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/torchviz/dot.py", line 163, in make_dot
    add_base_tensor(var)
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/torchviz/dot.py", line 151, in add_base_tensor
    add_nodes(var.grad_fn)
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/torchviz/dot.py", line 134, in add_nodes
    add_nodes(u[0])
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/torchviz/dot.py", line 134, in add_nodes
    add_nodes(u[0])
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/torchviz/dot.py", line 134, in add_nodes
    add_nodes(u[0])
  [Previous line repeated 951 more times]
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/torchviz/dot.py", line 127, in add_nodes
    dot.node(str(id(fn)), get_fn_name(fn, show_attrs, max_attr_chars))
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/graphviz/_tools.py", line 171, in wrapper
    return func(*args, **kwargs)
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/graphviz/dot.py", line 196, in node
    attr_list = self._attr_list(label, kwargs=attrs, attributes=_attributes)
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/graphviz/_tools.py", line 171, in wrapper
    return func(*args, **kwargs)
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/graphviz/quoting.py", line 152, in attr_list
    content = a_list(label, kwargs=kwargs, attributes=attributes)
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/graphviz/_tools.py", line 171, in wrapper
    return func(*args, **kwargs)
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/graphviz/quoting.py", line 123, in a_list
    result = [f'label={quote(label)}'] if label is not None else []
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/graphviz/_tools.py", line 171, in wrapper
    return func(*args, **kwargs)
  File "/data/nv419/anaconda3/envs/gnmt/lib/python3.8/site-packages/graphviz/quoting.py", line 82, in quote
    if is_html_string(identifier) and not isinstance(identifier, NoHtml):
RecursionError: maximum recursion depth exceeded while calling a Python object

Is this a known issue with large/complicated models? I can create a reproducible example if not

from pytorchviz.

albanD avatar albanD commented on July 21, 2024

Hi,

It is not very common to have big enough models for this to happen no.
I'm sure we could refactor the current recursive algorithm into an iterative one though if this is a blocker on your end.

from pytorchviz.

nihirv avatar nihirv commented on July 21, 2024

Hi @albanD. It's not a blocker (though a nice to have!). I'm not sure it's worth the effort of doing that for what seems to be 3 people.

However if you have any hints on why this might happen then it could be useful. The model I'm running this on has 3 full BERT-base encoders within it

from pytorchviz.

albanD avatar albanD commented on July 21, 2024

My guess, based on the stack you shared, is just that the graph we're trying to build has too much depth. And because we use recursion every time to get to the next Node, the stack end up being pretty deep. In your case almost 1000 deep and python doesn't like that.

That's why the proposed fix was to limit the recursion depth by using iterative algorithms instead here.

from pytorchviz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.