My use case requires any application to run on a single thread as our hardware accepts multiple submissions from multiple users, and unintended multithreading can cause conflicts.
I am using Nd4j primarily for matrix multiplication calling Nd4j.setNumThreads(1) prior to any operations. Jobs I submit end up with ~170% CPU usage throughout their run however, indicating that multiple threads are still being used.
I am using version 1.0.0-beta4. I am wondering if I am just configuring it incorrectly to meet my requirements or if there is anything fundamental I am missing which would make this infeasible.
That setting only sets how many threads ND4J itself uses. But ND4J also uses BLAS libraries, which, unless configured differently, will use a varying number of threads, depending on the input size.
In order to tell the BLAS library (usually either OpenBLAS or MKL) to use just one thread you also need to set the “OMP_NUM_THREADS” environment variable to 1.
ND4J is using a BLAS library, and most of those are using OpenMP under the hood. On the last few pages of the reference guide you’ve got the environment variables that can influence it:
Ideally you start with OMP_DISPLAY_ENV=true to get idea what version it actually is, and then get the reference guide to that to know what exactly you can do.
Thanks for the response and linked document. I took a look at it and it’s full things that are absolute Greek to me:
"A directive that can specify multiple directive variants, one of which may be conditionally selected to replace the metadirective based on the enclosing OpenMP context."
I’m a high level user who is clueless under the hood. Let me rephrase my question to give you the context of my cluelessness:
When you say start with OMP_DISPLAY_ENV=true, what are you functionally telling me to do?
Set an OS environment variable (it doesn’t exist on my machine, do I create it?)
Yes, these are environment variables. You don’t necessarily need to set them at OS level, you can set them up in your IDE or in a script that starts your application.
How exactly you should do this, will depend on the environment you are actually running in.