Parallelize for loop with multiple XGBoost predictions

Viewed 13

I have multiple different XGBoost models, which are already trained. Now I want to predict a given input with each of these models. When I try to parallelize them, I end up in a deadlock. Is there a way to solve this? The next input is influenced by the output of the predictions so i cannot simply collect them and predict them all at once.

def parallel_model(input, model):
    reward = model.predict(input)
    return reward

def main():
    reward = 0
    with futures.ProcessPoolExecutor() as pool:
        for r in pool.map(parallel_model, inputs, models):
             reward += r
0 Answers
Related