Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV 4.4 and multiprocessing on Windows 10

Hello OpenCV community,

I downloaded and compiled OpenCV 4.4 on my Windows 10 machine. It has been working great, except ...

I can't seem to get multiprocessing support to work (in Python - version 3.8.5). So far I have tried: multiprocessing.Pool, multiprocessing.Process and concurrent.futures.ProcessPoolExecutor. I believe on windows, these modules spawn a command shell to execute the workload. What I see is that the workload fails with the dreaded message: "ImportError: DLL load failed while importing cv2: The specified module could not be found"

Interestingly, all OpenCV python samples use multiprocessing.pool.ThreadPool module to process workloads. I tried that as well, and it works, but from looking at TaskManager, it seems to spawn only one instance of workload. I believe multi-threading is useful only when you have mix of I/O bound and compute bound workloads. My code is purely compute bound, so this does not help.

I can get things to work by executing in multiple Windows 10 shells, so I believe my OpenCV install is fine. I have a 12 core desktop and I would like to use all of them!

Your help would be greatly appreciated - I am at a dead-end in terms of looking online for help.

Regards,

Vijay

OpenCV 4.4 and multiprocessing on Windows 10

Hello OpenCV community,

I downloaded and compiled OpenCV 4.4 on my Windows 10 machine. It has been working great, except ...

I can't seem to get multiprocessing support to work (in Python - version 3.8.5). So far I have tried: multiprocessing.Pool, multiprocessing.Process and concurrent.futures.ProcessPoolExecutor. I believe on windows, these modules spawn a command shell to execute the workload. What I see is that the workload fails with the dreaded message: "ImportError: DLL load failed while importing cv2: The specified module could not be found"

Interestingly, all OpenCV python samples use multiprocessing.pool.ThreadPool module to process workloads. I tried that as well, and it works, but from looking at TaskManager, it seems to spawn only one instance of workload. I believe multi-threading is useful only when you have mix of I/O bound and compute bound workloads. My code is purely compute bound, so this does not help.

I can get things to work by executing in multiple Windows 10 shells, so I believe my OpenCV install is fine. I have a 12 core desktop and I would like to use all of them!

Your help would be greatly appreciated - I am at a dead-end in terms of looking online for help.

Regards,

Vijay