0
$\begingroup$

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?

$\endgroup$
0
$\begingroup$

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)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.