hyperopt / hyperopt

Distributed Asynchronous Hyperparameter Optimization in Python
http://hyperopt.github.io/hyperopt
Other
7.2k stars 1.05k forks source link

AttributeError: Can't get attribute 'objective' #340

Open ghost opened 6 years ago

ghost commented 6 years ago

INFO:hyperopt.mongoexp:Error while unpickling. Try installing dill via "pip install dill" for enhanced pickling support. INFO:hyperopt.mongoexp:job exception: Can't get attribute 'objective' on <module 'main' from '/export/home/ysz/hyperopt/scripts/hyperopt-mongo-worker'> Traceback (most recent call last): File "/export/home/ysz/anaconda3/bin/hyperopt-mongo-worker", line 6, in exec(compile(open(file).read(), file, 'exec')) File "/export/home/ysz/hyperopt/scripts/hyperopt-mongo-worker", line 6, in sys.exit(hyperopt.mongoexp.main_worker()) File "/export/home/ysz/hyperopt/hyperopt/mongoexp.py", line 1302, in main_worker return main_worker_helper(options, args) File "/export/home/ysz/hyperopt/hyperopt/mongoexp.py", line 1249, in main_worker_helper mworker.run_one(reserve_timeout=float(options.reserve_timeout)) File "/export/home/ysz/hyperopt/hyperopt/mongoexp.py", line 1064, in run_one domain = pickle.loads(blob) AttributeError: Can't get attribute 'objective' on <module 'main' from '/export/home/ysz/hyperopt/scripts/hyperopt-mongo-worker'>

can you tell me why? It seems to be a matter of procedure

bjkomer commented 6 years ago

I think the issue has to do with pickling a function that the mongo worker script doesn't know about.

Something that might help is to do pip install dill to improve pickling support. That likely won't be enough to fix it (it wasn't for me), check out the answers here for more insight. A workaround is to have your objective function in a separate script accessible to both the hyperopt-mongo-worker and the script where you call fmin.

Related to #184