Comments (6)
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.
That's interesting...
Could you share a code sample that we can use to reproduce that (on colab for example)?
from pytorchviz.
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.
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.
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.
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)
- No text label displayed on Google Colab (Pytorch 1.8.1) HOT 1
- Add variable names to nodes HOT 5
- Incorrect graph for saved variable using custom autograd function HOT 5
- Inconsistent arrow directions for saved variables HOT 2
- Graph terminates in small horizontal bar HOT 1
- RecursionError when used on subclass of Tensor HOT 5
- Page beyond pdf interface
- Lisibility of saved tensor HOT 1
- 'NotImplementedError:' when passing multiple input to model()
- Failing on large digraph HOT 3
- torchviz module not found HOT 2
- PNG Generation HOT 7
- Plotting model HOT 1
- AttributeError in make_dot with GNN from dgl.ai HOT 1
- Supress a model/nn.module
- How to plot transformer model? (BERT Model) HOT 3
- Pytorchviz with detectron2
- My data must be some integer data,how to do
- Depends on distutils, which has been removed from python3.12 HOT 8
- add color themes - drafted
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorchviz.