use cpu count explicitly in job count
This commit is contained in:
parent
79aab4cce2
commit
2713fdb860
@ -323,13 +323,13 @@ class Hyperopt(Backtesting):
|
|||||||
results.trade_duration.mean(),
|
results.trade_duration.mean(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_optimizer(self) -> Optimizer:
|
def get_optimizer(self, cpu_count) -> Optimizer:
|
||||||
return Optimizer(
|
return Optimizer(
|
||||||
self.hyperopt_space(),
|
self.hyperopt_space(),
|
||||||
base_estimator="ET",
|
base_estimator="ET",
|
||||||
acq_optimizer="auto",
|
acq_optimizer="auto",
|
||||||
n_initial_points=30,
|
n_initial_points=30,
|
||||||
acq_optimizer_kwargs={'n_jobs': -1}
|
acq_optimizer_kwargs={'n_jobs': cpu_count}
|
||||||
)
|
)
|
||||||
|
|
||||||
def run_optimizer_parallel(self, parallel, asked) -> List:
|
def run_optimizer_parallel(self, parallel, asked) -> List:
|
||||||
@ -361,11 +361,11 @@ class Hyperopt(Backtesting):
|
|||||||
self.load_previous_results()
|
self.load_previous_results()
|
||||||
|
|
||||||
cpus = multiprocessing.cpu_count()
|
cpus = multiprocessing.cpu_count()
|
||||||
logger.info(f'Found {cpus}. Let\'s make them scream!')
|
logger.info(f'Found {cpus} CPU cores. Let\'s make them scream!')
|
||||||
|
|
||||||
opt = self.get_optimizer()
|
opt = self.get_optimizer(cpus)
|
||||||
try:
|
try:
|
||||||
with Parallel(n_jobs=-1) as parallel:
|
with Parallel(n_jobs=cpus) as parallel:
|
||||||
for i in range(self.total_tries//cpus):
|
for i in range(self.total_tries//cpus):
|
||||||
asked = opt.ask(n_points=cpus)
|
asked = opt.ask(n_points=cpus)
|
||||||
f_val = self.run_optimizer_parallel(parallel, asked)
|
f_val = self.run_optimizer_parallel(parallel, asked)
|
||||||
|
Loading…
Reference in New Issue
Block a user