RecursionError: maximum recursion depth exceeded while calling a Python object
See original GitHub issuewhen train on 18epoch, it would report error:
Traceback (most recent call last):
File "train.py", line 396, in <module>
train_model(args)
File "train.py", line 213, in train_model
lossTr, lr = train(args, trainLoader, model, criteria, optimizer, epoch)
File "train.py", line 328, in train
optimizer.step()
File "/home/lgq/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/optim/lr_scheduler.py", line 36, in wrapper
return func(*args, **kwargs)
File "/home/lgq/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/optim/lr_scheduler.py", line 36, in wrapper
return func(*args, **kwargs)
File "/home/lgq/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/optim/lr_scheduler.py", line 36, in wrapper
return func(*args, **kwargs)
[Previous line repeated 991 more times]
File "/home/lgq/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/optim/adam.py", line 69, in step
state = self.state[p]
File "/home/lgq/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/tensor.py", line 393, in __hash__
return id(self)
RecursionError: maximum recursion depth exceeded while calling a Python object
I found that you put WarmupPolyLR in every iters, it would make every iter call WarmupPolyLR, maybe it cause the error.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
maximum recursion depth exceeded while calling a Python ...
This means that each call to your recursive function will create a function call stack and because there is a limit of stack...
Read more >Python RecursionError: Maximum Recursion Depth Exceeded ...
A Python RecursionError exception is raised when the execution of your program exceeds the recursion limit of the Python interpreter.
Read more >Python maximum recursion depth exceeded in comparison
The “maximum recursion depth exceeded in comparison” error is raised when you try to execute a function that exceeds Python's built in recursion ......
Read more >maximum recursion depth exceeded while calling a Python ...
When the interpreter detects that the maximum depth for recursion has reached, it throws the recursionerror ...
Read more >Python: Maximum Recursion Depth Exceeded [How to Fix It]
The maximum recursion depth in Python is 1000. To check it, call sys.getrecursionlimit() function. To change it, call sys.setrecursionlimit().
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Maybe this way can help you. https://github.com/xiaoyufenfei/Efficient-Segmentation-Networks/blob/0f0c32e7af3463d381cb184a158ff60e16f7fb9a/train.py#L25
Hi @lgqfhwy Were you able to resolve this issue because I am facing it as of now. Please let me know your workaround. I did try increasing the max recursion depth by using the
sys
library in python, but it still gets stuck at th 9th epoch for me.