Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save porink0424/e43886aa85f7962cf4814703e1db99af to your computer and use it in GitHub Desktop.

Select an option

Save porink0424/e43886aa85f7962cf4814703e1db99af to your computer and use it in GitHub Desktop.
import optuna
from concurrent.futures import ThreadPoolExecutor
optuna.logging.set_verbosity(optuna.logging.WARNING)
def test_free_threaded():
study = optuna.create_study(sampler=optuna.samplers.BruteForceSampler())
def objective(trial):
s = 0
for i in range(10):
s += trial.suggest_int(f"x{i}", 0, 10)
return s
study.optimize(
objective,
n_trials=50,
n_jobs=5,
)
if __name__ == "__main__":
with ThreadPoolExecutor() as executor:
for _ in range(5):
executor.submit(test_free_threaded)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment