You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/12/03 03:28:45 UTC

[GitHub] [incubator-mxnet] MediosZ opened a new issue #16961: Unable to hardcode the OMP_NUM_THREADS into program

MediosZ opened a new issue #16961: Unable to hardcode the OMP_NUM_THREADS into program
URL: https://github.com/apache/incubator-mxnet/issues/16961
 
 
   Hi, I want to run mxnet in single thread mode, and for some reason I can't set environment variables.
   First I recompile the library without MKL-DNN and OpenMP support using the latest code and hardcode "MXNET_ENGINE_TYPE=NaiveEngine"
   Then I want to set OMP_NUM_THREADS=1 in a similar way.
   
   Here's what I done, I modify some code in openmp.cc
   ```c++
   OpenMP::OpenMP()
     : omp_num_threads_set_in_environment_(true) {
       enabled_ = true;
       omp_thread_max_ = 1;
   }
   
   void OpenMP::on_start_worker_thread(bool use_omp) {
     omp_set_num_threads(1);
   }
   
   void OpenMP::set_reserve_cores(int cores) {
     
     CHECK_GE(cores, 0);
     reserve_cores_ = cores;
     omp_set_num_threads(1);
   }
   
   int OpenMP::GetRecommendedOMPThreadCount(bool exclude_reserved) const {
     return 1;
   }
   ```
   
   But the program will create 56 workers as usual.
   When I set environment variable OMP_NUM_THREADS=1, there would be only one worker.
   I don't see how the program would handle this environment variable.
   And if I really want to hardcode this, what should I do?
   Thanks a lot!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services