mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

Can't use multi-core CPU correctly!

Open dytmas opened this issue 9 years ago • 7 comments

Run on CPU with openblas and openmp.

Run the following code:

import time, os

def do(x, n):
    return [mx.nd.dot(x,x) for i in range(n)]

def wait(x):
    for y in x:
        y.wait_to_read()
        
tic = time.time()
a = mx.nd.ones((1000, 1000))
b = do(a, 1000)
print('time for pushed into backend engine:\n %f sec' % (time.time()-tic))
wait(b)
print('time for all finished:\n %f sec' % (time.time()-tic))

when OMP_NUM_THREADS = 4, it will take about 8-9s. but when OMP_NUM_THREADS = 32, it will take about 28-32s.

I have checked and I am sure that when OMP_NUM_THREADS = 4, 4 cores are filled, when OMP_NUM_THREADS = 32, 32 cores are filled .

when I set a = mx.nd.ones((10000, 10000)) 32 cores will be faster than 4 cores, but only about 2 times faster.

why mxnet or openblas can't use the power of multi-core cpu, in such a simple situation?

dytmas avatar Jan 05 '17 12:01 dytmas

Try to increase worker thread # as well: export MXNET_CPU_WORKER_NTHREADS=16

howard0su avatar Jan 05 '17 13:01 howard0su

I found that changing $MXNET_CPU_WORKER_NTHREADS has no effect on the results. No matter it's 16, 32, or 1, the results are almost the same.

dytmas avatar Jan 06 '17 02:01 dytmas

This issue is closed due to lack of activity in the last 90 days. Feel free to reopen if this is still an active issue. Thanks!

yajiedesign avatar Sep 28 '17 08:09 yajiedesign

I'm still experiencing the same issue

daranday avatar Oct 05 '17 18:10 daranday

This problem was addressed. Adding the export line increased the detection speed dramatically!

daranday avatar Oct 06 '17 06:10 daranday

@apache/mxnet-committers: This issue has been inactive for the past 90 days. It has no label and needs triage.

For general "how-to" questions, our user forum (and Chinese version) is a good place to get help.

szha avatar Jan 05 '18 12:01 szha

@daranday's comment above says setting 'MXNET_CPU_WORKER_NTHREADS' fixes the problem. I'm closing this issue. Please reopen if that suggestion doesn't fix the problem. Thanks!

indhub avatar Jan 05 '18 21:01 indhub