Skip to content
Advertisement

Why GridSearchCV spends more than 50% time on {method ‘acquire’ of ‘thread.lock’ objects}?

Recently I am tuning up some of my machine learning pipeline. I decided to take advantage of my multicore processor. And I ran cross-validation with param n_jobs=-1. I also profiled it and what was suprise for me: the top function was:

JavaScript

I was not sure if it was my fault due to operations I do in Pipeline. So I decided to make small experiment:

JavaScript

The output is :

JavaScript

I wonder what is the cause of such behavior. And if it is possible to speed it up a little bit.

Advertisement

Answer

The profiler is only telling you what the main process is doing, while its child processes are doing all the work. Setting verbose=2 on GridSearchCV may give better output than %prun in this case.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement