#911·hyperopt

Cloudpickle error after many evaluations

Author: btyukodiCreated Jan 10, 2024Updated Jul 24, 2026

I am using hyperopt with Mongo. For many function evaluations it seems to run fine, however, over time I keep getting more and more of the following errors:

   "error" : [
        "<class 'AttributeError'>",
        "Can't get attribute '_make_function' on <module 'cloudpickle.cloudpickle' from '/home/btyukodi/anaconda3/lib/python3.9/site-packages/cloudpickle/cloudpickle.py'>"
    ]

Ultimately fewer and fewer workers are running simultaneously, until all workers stop. The full output is

INFO:hyperopt.mongoexp:Error while unpickling.
INFO:hyperopt.mongoexp:job exception: Can't get attribute '_make_function' on <module 'cloudpickle.cloudpickle' from '/home/btyukodi/anaconda3/lib/python3.9/site-packages/cloudpickle/cloudpickle.py'>
Traceback (most recent call last):
  File "/home/btyukodi/anaconda3/bin/hyperopt-mongo-worker", line 8, in <module>
    sys.exit(main())
  File "/home/btyukodi/anaconda3/lib/python3.9/site-packages/hyperopt/mongoexp.py", line 1329, in main
    sys.exit(main_worker())
  File "/home/btyukodi/anaconda3/lib/python3.9/site-packages/hyperopt/mongoexp.py", line 1411, in main_worker
    return main_worker_helper(options, args)
  File "/home/btyukodi/anaconda3/lib/python3.9/site-packages/hyperopt/mongoexp.py", line 1322, in main_worker_helper
    mworker.run_one(reserve_timeout=float(options.reserve_timeout))
  File "/home/btyukodi/anaconda3/lib/python3.9/site-packages/hyperopt/mongoexp.py", line 1093, in run_one
    domain = pickler.loads(blob)
AttributeError: Can't get attribute '_make_function' on <module 'cloudpickle.cloudpickle' from '/home/btyukodi/anaconda3/lib/python3.9/site-packages/cloudpickle/cloudpickle.py'>

I was unable to identify so far a pattern of when this is happening and the fact that it appears at later stages (after previous successful evaluations) makes me clueless. Any help would be greatly appreciated.

Edit: My max_evals parameter is around 50000. Is there a reason hyperopt might not be able to handle such high numbers?