How to restrict number of cores used?

634 kali dilihat
Langsung ke pesan pertama yang belum dibaca

Ed Mountjoy

belum dibaca,
11 Jan 2016, 08.05.4411/01/16
kepadapystatsmodels
Hi,

I looking to find a way to restrict the number of cores used when doing OLS regression. At the moment statsmodels is using all available cores. This is a problem as I'm using a trying to run jobs on a cluster with nodes that are shared with other users.

Thanks,
Ed

josef...@gmail.com

belum dibaca,
11 Jan 2016, 08.12.5811/01/16
kepadapystatsmodels
I have no idea how to do that. It isn't statsmodels doing it.

I think it's the underlying Blas/Lapack libraries in numpy/scipy that
are using mutliple cores. I saw the same mutli processor usage with
MKL but didn't try to figure out yet how to turn it off and restrict
to one processor.

So this is a question for numpy/scipy or the linalg libraries. But I
would also like to know.


Statsmodels is using joblib in a few places for parallel processing
where it's under our control but mainly for bootstrap and not in the
models.


Josef


>
> Thanks,
> Ed

Nathaniel Smith

belum dibaca,
11 Jan 2016, 10.51.4011/01/16
kepadapystatsmodels

On Jan 11, 2016 5:05 AM, "Ed Mountjoy" <emou...@gmail.com> wrote:
>
> Hi,
>
> I looking to find a way to restrict the number of cores used when doing OLS regression. At the moment statsmodels is using all available cores. This is a problem as I'm using a trying to run jobs on a cluster with nodes that are shared with other users.

Yeah, this is your BLAS library, so it depends on which BLAS you're using.

For openblas, try setting the environment variable OMP_NUM_THREADS=1. (Technically this is how you tell OpenMP to be not-threaded, so watch out for that in case you're using OpenMP on purpose in your own code. But openblas also pays attention to it in all configurations. If for some reason you want OpenMP code to use multiple threads but openblas not to, then check the openblas docs, I think it's possible.)

If you're using MKL then check the MKL docs.

AFAIK those are the only popular multi-threaded BLAS libraries.

-n

Skipper Seabold

belum dibaca,
11 Jan 2016, 17.43.0311/01/16
kepadapystat...@googlegroups.com
FWIW, in Accelerate on OSX, you have VECLIB_MAXIMUM_THREADS.

Skipper
Pesan telah dihapus

Ed Mountjoy

belum dibaca,
27 Apr 2016, 12.02.2727/04/16
kepadapystatsmodels
I figured out that it was because I was using Anaconda which includes MKL optimisations. I can restrict the number of cores using e.g.:

import mkl
mkl
.set_num_threads(1)

Thanks

josef...@gmail.com

belum dibaca,
27 Apr 2016, 12.26.4727/04/16
kepadapystatsmodels
Thanks,

I made a FAQ issue to collect this information

Josef
Balas ke semua
Balas ke penulis
Teruskan
0 pesan baru