caffe icon indicating copy to clipboard operation
caffe copied to clipboard

OpenMP causes caffe to hang

Open Compuholic opened this issue 10 years ago • 0 comments

Hi,

I noticed a potential problem with OpenMP and newer versions of caffe. I am writing some custom training code: I manually fill the blobs and use Solver->step to run a forward/backward pass. In order to pre-process the data that goes into the input blobs in parallel, I use an OpenMP "parallel for" construct. All OpenMP threads share a single Solver object. All parts of the code that are concerned with accessing blobs and executing the forward/backward pass are protected by a "critical" section.

Everything works fine until I use more than 1 OpenMP thread. If I do, caffe hangs before completing its first iteration and it doesn't even print the usual line: I0215 18:53:20.922806 5963 solver.cpp:229] Iteration 0, loss = 5.43428

I never had this issue with older versions of caffe where this construct worked fine. I suspect some conflict between OpenMP and caffe's internal threads.

Can somebody reproduce this issue and/or suggest a workaround?

Edit: I have now determined that caffe does not actually hang. It just reverts to training on a CPU (single threaded) which is very slow.

Compuholic avatar Feb 15 '16 18:02 Compuholic