I am running a k-means cluster analysis in python and am getting a warning.
UserWarning: KMeans is known to have a memory leak on Windows with MKL, when there are less chunks than available threads. You can avoid it by setting the environment variable OMP_NUM_THREADS=1.
I have tried to set the environ variable
import os
os.environ["OMP_NUM_THREADS"] = '1'
But the warnings don't go away, and it looks like the variable is not persistent (when i restart python, it's not there anymore) which got me searching through stackoverflow and found the following sites
answer
answer
answer
Bear in mind I am on the work PC and I have no admin rights. So my question are:
- What happens if I just ignore the warning and keep using k-means? The results look fine as it is but would not want to kick the can down the road.
- Is there any solution that doesn't involve admin rights or writing scripts (not that i am familiar with anyways)?
Since I am beginning to use python extensively and other modules with similar issues, I would like to tackle this problem sooner than later.
Thanks, Jung
I am running a k-means cluster analysis in python and am getting a warning.
UserWarning: KMeans is known to have a memory leak on Windows with MKL, when there are less chunks than available threads. You can avoid it by setting the environment variable OMP_NUM_THREADS=1.
I have tried to set the environ variable
import os
os.environ["OMP_NUM_THREADS"] = '1'
But the warnings don't go away, and it looks like the variable is not persistent (when i restart python, it's not there anymore) which got me searching through stackoverflow and found the following sites
answer
answer
answer
Bear in mind I am on the work PC and I have no admin rights. So my question are:
- What happens if I just ignore the warning and keep using k-means? The results look fine as it is but would not want to kick the can down the road.
- Is there any solution that doesn't involve admin rights or writing scripts (not that i am familiar with anyways)?
Since I am beginning to use python extensively and other modules with similar issues, I would like to tackle this problem sooner than later.
Thanks, Jung
Share asked Mar 5 at 16:51 Jung Hun KimJung Hun Kim 194 bronze badges 2 |1 Answer
Reset to default -1You don't need admin rights to set user environment variables. Type 'env' into your start menu and look for a 'Edit environment variables for your account'. Add it in there. You will need to restart your shell/IDE/platform to make it available.
os.environ[...]
before or after your other imports? Make sure it's before so that if you're importing anything else. The variable goes away because it won't persist in the environment variables, you'd have to manually set that, but it would limit things to one thread for MKL, so might not want that for all applications. – Chrispresso Commented Mar 5 at 16:59OMP_NUM_THREADS=1
directly in console and it should remeber it until you close console. You may also use it in the same line as you start scriptOMP_NUM_THREADS=1 python script.py
(at least it can work on Linux) but this need to run everytime. Or you can create script which set variable and run code and always start this script to run your code. Eventually in code you can try to use standard modulewarning
to hide this message. – furas Commented Mar 6 at 5:44