question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'RuntimeError: maximum recursion depth exceeded' when trying to serialize model

See original GitHub issue

When I try

joblib.dump(model, 'my_model.pkl', compress=9)

or to pickle the model, I get:

  File "/home/moose/.local/lib/python2.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 280, in save
    return Pickler.save(self, obj)
  File "/usr/lib/python2.7/pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/lib/python2.7/pickle.py", line 425, in save_reduce
    save(state)
  File "/home/moose/.local/lib/python2.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 280, in save
    return Pickler.save(self, obj)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 655, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 687, in _batch_setitems
    save(v)
  File "/home/moose/.local/lib/python2.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 280, in save
    return Pickler.save(self, obj)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 606, in save_list
    self._batch_appends(iter(obj))
  File "/usr/lib/python2.7/pickle.py", line 639, in _batch_appends
    save(x)
  File "/home/moose/.local/lib/python2.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 280, in save
    return Pickler.save(self, obj)
  File "/usr/lib/python2.7/pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/lib/python2.7/pickle.py", line 425, in save_reduce
    save(state)
  File "/home/moose/.local/lib/python2.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 280, in save
    return Pickler.save(self, obj)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 655, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 687, in _batch_setitems
    save(v)
  File "/home/moose/.local/lib/python2.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 280, in save
    return Pickler.save(self, obj)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 606, in save_list
    self._batch_appends(iter(obj))
  File "/usr/lib/python2.7/pickle.py", line 639, in _batch_appends
    save(x)
  File "/home/moose/.local/lib/python2.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 280, in save
    return Pickler.save(self, obj)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 554, in save_tuple
    save(element)
  File "/home/moose/.local/lib/python2.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 280, in save
    return Pickler.save(self, obj)
  File "/usr/lib/python2.7/pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/lib/python2.7/pickle.py", line 425, in save_reduce
    save(state)
  File "/home/moose/.local/lib/python2.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 280, in save
    return Pickler.save(self, obj)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 655, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 686, in _batch_setitems
    save(k)
  File "/home/moose/.local/lib/python2.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 280, in save
    return Pickler.save(self, obj)
  File "/usr/lib/python2.7/pickle.py", line 271, in save
    pid = self.persistent_id(obj)
RuntimeError: maximum recursion depth exceeded

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dnouricommented, Aug 28, 2016

Have you tried sys.setrecursionlimit(10000)?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python: Maximum recursion depth exceeded - Stack Overflow
Method that I call to get sql results: def returnCategoryQuery(query, variables={}): cursor = db.cursor(cursors.DictCursor); catResults = []; ...
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 >
"maximum recursion depth exceeded " when serializing enum ...
RuntimeError : maximum recursion depth exceeded while calling a Python object. the same script under python3 works fine.
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 ...
I'm seeing this new error with ray==1.12. The same code worked fine in 1.11 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found