Set #threads from within python code

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Set #threads from within python code

Neal Becker
I don't want my python code to run multi-thread.  So I can do:

MKL_NUM_THREAD=1 NUMEXPR_NUM_THREADS=1 OMP_NUM_THREADS=1 my_program...

But I don't seem to be able to achieve this effect without setting env 
variables on the command line; within my_program.  Using os.environ doesn't 
work.  I don't understand why.  I'd like to not have to put this on the 
command line because I sometimes forget.


_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set #threads from within python code

Daπid
On 24 March 2017 at 12:30, Neal Becker <[hidden email]> wrote:
> Using os.environ doesn't
> work.  I don't understand why.

It should, I do that for other variables. Are you setting the
variables before importing other libraries? They may only get read at
import time.
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set #threads from within python code

Neal Becker
Ah, that probably explains it!

On Fri, Mar 24, 2017 at 7:37 AM Daπid <[hidden email]> wrote:
On 24 March 2017 at 12:30, Neal Becker <[hidden email]> wrote:
> Using os.environ doesn't
> work.  I don't understand why.

It should, I do that for other variables. Are you setting the
variables before importing other libraries? They may only get read at
import time.
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Set #threads from within python code

Pavlyk, Oleksandr
In reply to this post by Neal Becker

Rather than keeping the number of threads MKL uses to 1, it is better to use MKL_THREADING_LAYER=SEQUENTIAL

 

https://software.intel.com/en-us/node/528380

 

--Sasha

 

From: NumPy-Discussion [mailto:numpy-discussion-bounces+oleksandr.pavlyk=[hidden email]] On Behalf Of Neal Becker
Sent: Friday, March 24, 2017 6:31 AM
To: [hidden email]
Subject: [Numpy-discussion] Set #threads from within python code

 

I don't want my python code to run multi-thread.  So I can do:

 

MKL_NUM_THREAD=1 NUMEXPR_NUM_THREADS=1 OMP_NUM_THREADS=1 my_program...

 

But I don't seem to be able to achieve this effect without setting env 

variables on the command line; within my_program.  Using os.environ doesn't 

work.  I don't understand why.  I'd like to not have to put this on the 

command line because I sometimes forget.

 


_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Loading...