Using fewer threads

It seems that automatically, ngsolve will use all the threads to do computation. For example, it always shows “Running parallel using 24 thread(s)” for my computer, which has 24 threads, when running a Python script with ngsolve. I tried to use SetNumThreads (12), but it does not seem to work. I can still see “Running parallel using 24 thread(s)”.

Is there any way to solve the problem? Thanks in advance!

this output comes on startup, before we actually start threads. With SetNumThreads(12) we will start 12 threads with TaskManager.

You can also set the environment variable NGS_NUM_THREADS to the number of threads you want to use on your machine.

1 Like