sherpa-ai / sherpa

Hyperparameter optimization that enables researchers to experiment, visualize, and scale quickly.
http://parameter-sherpa.readthedocs.io/
GNU General Public License v3.0
333 stars 54 forks source link

Can't pickle local object 'Flask.init..' #115

Open RalfKellner opened 3 years ago

RalfKellner commented 3 years ago

When running the code below, I get the error "Can't pickle local object 'Flask.init..'"

import sherpa parameters = [sherpa.Discrete('num_units', [50, 200])] alg = sherpa.algorithms.RandomSearch(max_num_trials=50) study = sherpa.Study(parameters=parameters, algorithm=alg, lower_is_better=True)

Can you recommend me something which solves this error?

LemonCANDY42 commented 2 years ago

me too.. Traceback (most recent call last): File "/Users/kennymccormick/github/QInvestment/Monitor_RPC_Client.py", line 16, in study = sherpa.Study(parameters=parameters, File "/Users/kennymccormick/opt/miniconda3/envs/scientific/lib/python3.9/site-packages/sherpa/core.py", line 109, in init self.dashboard_process = self._run_web_server(dashboard_port) File "/Users/kennymccormick/opt/miniconda3/envs/scientific/lib/python3.9/site-packages/sherpa/core.py", line 300, in _run_web_server proc.start() File "/Users/kennymccormick/opt/miniconda3/envs/scientific/lib/python3.9/multiprocessing/process.py", line 121, in start self._popen = self._Popen(self) File "/Users/kennymccormick/opt/miniconda3/envs/scientific/lib/python3.9/multiprocessing/context.py", line 224, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "/Users/kennymccormick/opt/miniconda3/envs/scientific/lib/python3.9/multiprocessing/context.py", line 284, in _Popen return Popen(process_obj) File "/Users/kennymccormick/opt/miniconda3/envs/scientific/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 32, in init super().init(process_obj) File "/Users/kennymccormick/opt/miniconda3/envs/scientific/lib/python3.9/multiprocessing/popen_fork.py", line 19, in init self._launch(process_obj) File "/Users/kennymccormick/opt/miniconda3/envs/scientific/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 47, in _launch reduction.dump(process_obj, fp) File "/Users/kennymccormick/opt/miniconda3/envs/scientific/lib/python3.9/multiprocessing/reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) AttributeError: Can't pickle local object 'Flask.init..'

rrushing20 commented 2 years ago

I had the same issue, interestingly enough I fixed it by reverting back to python 3.6. Hopefully, this works for you.

AharonSterman commented 2 years ago

After 3 days, thanks g-d I found this just add an import and a first line of code

from sherpa import multiprocessing

multiprocessing.set_start_method("fork")