Skip to content

Commit

Permalink
disable opencv threading for forked process (apache#12025)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhreshold authored and aaronmarkham committed Aug 6, 2018
1 parent 14538cc commit abdc9e2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/initialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include <dmlc/logging.h>
#include <mxnet/engine.h>
#include "./engine/openmp.h"
#if MXNET_USE_OPENCV
#include <opencv2/opencv.hpp>
#endif // MXNET_USE_OPENCV

namespace mxnet {
#if MXNET_USE_SIGNAL_HANDLER && DMLC_LOG_STACK_TRACE
Expand Down Expand Up @@ -57,6 +60,9 @@ class LibraryInitializer {
// Make children single threaded since they are typically workers
dmlc::SetEnv("MXNET_CPU_WORKER_NTHREADS", 1);
dmlc::SetEnv("OMP_NUM_THREADS", 1);
#if MXNET_USE_OPENCV
cv::setNumThreads(0); // disable opencv threading
#endif // MXNET_USE_OPENCV
engine::OpenMP::Get()->set_enabled(false);
Engine::Get()->Start();
});
Expand Down

0 comments on commit abdc9e2

Please sign in to comment.