GitHub issue: Thread Count
State: closed

i am using mxnet to develop my algorithm to submit in FRVT11, while validating it shows warning of thread count more than 2.
Can anyone tell me how to solve it?
Is it ok to submit as it is warning and not the error?

@jaisanant0 - this question was addressed in Issue #22. 

@mlngan 

i need to export OMP_NUM_THREADS=1 to limit the thread used by mxnet.
Will NIST to do so?

@jaisanant0 You will have to set any required environment variables within your software.

@mlngan 
I have limited my library running thread to 1.
Total spawned threads are 9 but only 1 is running, rest are sleep.

20   0 5423228 284504 109712 R 99.9  0.9   0:15.65 validate11
20   0  274528 100692  41828 S  0.0  0.3   0:00.18 validate11
20   0 5423228 284504 109712 S  0.0  0.9   0:00.00 validate11
20   0 5423228 284504 109712 S  0.0  0.9   0:00.00 validate11
20   0 5423228 284504 109712 S  0.0  0.9   0:00.00 validate11
20   0 5423228 284504 109712 S  0.0  0.9   0:00.00 validate11
20   0 5423228 284504 109712 S  0.0  0.9   0:00.00 validate11
20   0 5423228 284504 109712 S  0.0  0.9   0:00.00 validate11
20   0 5423228 284504 109712 S  0.0  0.9   0:00.00 validate11

will this be acceptable ?

@jaisanant0 - per the discussion from issue #22, you should be able to get the number of threads down to just one or two coming out of mxnet.  Please look again. 

We distribute workload across multiple processes (and multiple blades). The intent of not allowing threading is to prevent unnecessary thrashing. More importantly, we measure timing and to accomplish a fair timing benchmark, we don't allow threading with the intent to speed up processing.  Please note that during timing, we lock all threads to using a single CPU, so if your submission ends up taking more than 1 second to generate a single template on a single CPU core, your algorithm will not be accepted for testing.

@jaisanant0 did you reduce the number of sleeping threads? I'm struggling with the same problem and will appreciate your help.

@fisakhan I had the same problem and solved it by building TensorFlow with disabled XLA (1) and building OpenCV (in my case) with no parallelism. 
Of course you need to set inter and intra op to 1, as described in many other topics.
In total, i have 4 threads (instead of 15) - 1 active and 3 suspended.

Thanks @stopmosk. What change do you make to disable XLA(1) ? Are 4 threads acceptable to NIST-FRVT?

@fisakhan I didn't find the appropriate option for build and simply commented line in configure script (configure.py):
```
  if environ_cp.get('TF_ENABLE_XLA', '1') == '1':
    #write_to_bazelrc('build --config=xla')
    pass
```
I don't know if 4 threads are enough for the FRVT, but I will try to submit it as is and will find out soon. 

In PyTorch it is as simple as "torch.set_num_threads(1)". It works and generates 3 threads in total (including 1 for python).

@stopmosk did NIST accepte your submission with 4 threads? How did you solve the problem?

> @stopmosk did NIST accepte your submission with 4 threads? How did you solve the problem?

NIST accept my submission, but feature extraction time was too high. I migrated to TFLite.