I’m also getting the error if I try to do a more substantial search using OptunaSearch.
import numpy as np
from ray import train, tune
from ray.tune.search.optuna import OptunaSearch
def rastrigin(config):
score = (
config['x'] ** 2
- 10 * np.cos(2 * np.pi * config['x'])
+ config['y'] ** 2
- 10 * np.cos(2 * np.pi * config['y'])
+ 20
)
return {"score": score}
search_space = {
"x": tune.uniform(-5.12, 5.12),
"y": tune.uniform(-5.12, 5.12),
}
optuna_search = OptunaSearch(metric='score', mode='min')
tune_config = tune.TuneConfig(search_alg=optuna_search, num_samples=-1, time_budget_s=20)
run_config = train.RunConfig(name='rastrigin', verbose=0)
tuner = tune.Tuner(rastrigin, param_space=search_space, tune_config=tune_config, run_config=run_config)
results = tuner.fit()
Using a large integer value for num_samples does not fix it.
The error:
2023-12-28 16:54:42,007 ERROR worker.py:405 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
(bundle_reservation_check_func pid=664883) Traceback (most recent call last):
(bundle_reservation_check_func pid=664883) File "python/ray/_raylet.pyx", line 1788, in ray._raylet.execute_task
(bundle_reservation_check_func pid=664883) File "python/ray/_raylet.pyx", line 1790, in ray._raylet.execute_task
(bundle_reservation_check_func pid=664883) File "/home/florin/.local/lib/python3.11/site-packages/ray/_private/worker.py", line 790, in deserialize_objects
(bundle_reservation_check_func pid=664883) context = self.get_serialization_context()
(bundle_reservation_check_func pid=664883) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(bundle_reservation_check_func pid=664883) File "/home/florin/.local/lib/python3.11/site-packages/ray/_private/worker.py", line 678, in get_serialization_context
(bundle_reservation_check_func pid=664883) context_map[job_id] = serialization.SerializationContext(self)
(bundle_reservation_check_func pid=664883) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(bundle_reservation_check_func pid=664883) File "/home/florin/.local/lib/python3.11/site-packages/ray/_private/serialization.py", line 153, in __init__
(bundle_reservation_check_func pid=664883) serialization_addons.apply(self)
(bundle_reservation_check_func pid=664883) File "/home/florin/.local/lib/python3.11/site-packages/ray/util/serialization_addons.py", line 29, in apply
(bundle_reservation_check_func pid=664883) from ray._private.pydantic_compat import register_pydantic_serializers
(bundle_reservation_check_func pid=664883) File "/home/florin/.local/lib/python3.11/site-packages/ray/_private/pydantic_compat.py", line 2, in <module>
(bundle_reservation_check_func pid=664883) from pkg_resources import packaging
(bundle_reservation_check_func pid=664883) File "/home/florin/.local/lib/python3.11/site-packages/pkg_resources/__init__.py", line 31, in <module>
(bundle_reservation_check_func pid=664883) import pkgutil
(bundle_reservation_check_func pid=664883) File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
(bundle_reservation_check_func pid=664883) File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
(bundle_reservation_check_func pid=664883) File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
(bundle_reservation_check_func pid=664883) File "<frozen importlib._bootstrap_external>", line 936, in exec_module
(bundle_reservation_check_func pid=664883) File "<frozen importlib._bootstrap_external>", line 1069, in get_code
(bundle_reservation_check_func pid=664883) File "<frozen importlib._bootstrap_external>", line 729, in _compile_bytecode
(bundle_reservation_check_func pid=664883) File "/home/florin/.local/lib/python3.11/site-packages/ray/_private/worker.py", line 841, in sigterm_handler
(bundle_reservation_check_func pid=664883) raise_sys_exit_with_custom_error_message(
(bundle_reservation_check_func pid=664883) File "python/ray/_raylet.pyx", line 846, in ray._raylet.raise_sys_exit_with_custom_error_message
(bundle_reservation_check_func pid=664883) SystemExit: 1