[Python] getting a warning on k-means

Discussão em 'Python' iniciado por Stack, Março 5, 2025.

  1. Stack

    Stack Membro Participativo

    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:

    1. 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.
    2. 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

    Continue reading...

Compartilhe esta Página