1

I'm running a Julia 1.4 notebook, via Jupyter lab. I need to limit the notebook to a single logical CPU core, on average.

In Python I use the following incantation to restrict Numpy's CPU usage:

from threadpoolctl import threadpool_info,threadpool_limits
with threadpool_limits(limits=1, user_api='blas'):
    >> code here <<

Would anyone happen to know whether its possible to similarly limit Julia's CPU usage from within a notebook?

MRule
  • 121
  • 3

1 Answers1

1

If the high CPU usage is due to parallelized linear algebra routines, limiting the CPU usage of the linear algebra backend helps. For Julia 1.4 compiled to use BLAS, the following limits it to a single core:

using LinearAlgebra; 
BLAS.set_num_threads(1);

(Many forum posts recommend blas_set_num_threads(1) for older versions of Julia. This seems to have been depricated)

MRule
  • 121
  • 3