numpy is not multi-thread

Viewed 689

My setup:

  • Python 3.5, compiled and installed to somewhere in my home directory;
  • OpenBLAS, already installed in /usr/local (I compiled my own OpenBLAS too, but the problem persisted)
  • Numpy, checked out from github, edited site.cfg to locate OpenBLAS, and installed in a virtualenv.
  • I have nothing else installed in this virtualenv or on this interpreter.

Problem: Numpy is very slow and always uses a single thread. OMP_NUM_THREADS is not respected. My test case (matrix multiplication) takes 16 sec, regardless of whether OMP_NUM_THREADS is set.

There is also a Python 2.7 interpreter, with its numpy linked to the same OpenBLAS installation. Multi-threading works on that interpreter, and the same test case takes 2.3 sec if OMP_NUM_THREADS is not set, or 2.5 sec if OMP_NUM_THREADS=8, or 13 sec if OMP_NUM_THREADS=1.

Also strangely, I have to specify the location of the OpenBLAS library in the LD_LIBRARY_PATH environment variable in order to use my setup, even though I have provided the path in site.cfg before I compiled numpy. This is not necessary if I use the numpy in Python 2. What steps did I miss?

0 Answers
Related