Community
cancel
Showing results for 
Search instead for 
Did you mean: 
tang__chao
Beginner
743 Views

How to bind just one thread to run my code?

Jump to solution

Hi,

I have tried to use KEY_CPU_BIND_THREAD to be NO,but doesn't work.

This is my code:

        std::map<std::string, std::string> config;
        config[PluginConfigParams::KEY_CPU_BIND_THREAD] = PluginConfigParams::NO;

        auto executable_network = plugin.LoadNetwork(network, config);

When I run the sample_ssd code,all of the CPU will be used.So I want to use one thread to run one code.

Could someone tell me how to solve it?

Thanks very much!

0 Kudos
1 Solution
Jeffrey_M_Intel1
Employee
743 Views

THe OpenVINO CPU plugin, MKLDNN, uses OpenMP for threading.  This means you can use standard OpenMP controls.  For example,

export OMP_NUM_THREADS=1

means that MKLDNN will only run on 1 thread.  You can further control behavior with tools like numactl and taskset, as you would with any other CPU application.

View solution in original post

3 Replies
Jeffrey_M_Intel1
Employee
744 Views

THe OpenVINO CPU plugin, MKLDNN, uses OpenMP for threading.  This means you can use standard OpenMP controls.  For example,

export OMP_NUM_THREADS=1

means that MKLDNN will only run on 1 thread.  You can further control behavior with tools like numactl and taskset, as you would with any other CPU application.

View solution in original post

743 Views

Hello,

Can we control this from the code, i.e. without setting environment variable? For the record, adding the line "omp_set_num_threads(1);" to the top of classification sample does not change a thing.

Lourenco__Miguel
Beginner
743 Views

Hello all,

I am facing the same issues regarding OpenVino single thread execution. From what I saw, once I load the network 2 threads are launched, but I would like to avoid this behaviour.

Is there any way to do it? omp_set_num_threads() and a set of other variables (KEY_CPU_THREADS_NUM, KEY_CPU_BIND_THREAD) without any success.

Looking forward for your help.

Miguel

 

Reply