1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python scikit-learn memory leak

Discussão em 'Python' iniciado por Stack, Dezembro 20, 2024.

  1. Stack

    Stack Membro Participativo

    This simple python code causes memory leak at each loop cycle. The leak only happens when when n_jobs parameter is not 1. Is there something I'm missing or any way to free memory leak caused by library?

    import gc
    import numpy as np
    from sklearn.manifold import TSNE
    from sklearn.cluster import OPTICS
    import psutil
    process = psutil.Process()


    def main():
    data = np.random.random((100, 100))
    for _i in range(1, 50):
    points = TSNE().fit_transform(data)
    prediction = OPTICS(n_jobs=2).fit_predict(points) # n_jobs!=1
    points = None
    prediction = None
    del prediction
    del points
    gc.collect()
    print(process.memory_info().rss)


    main()


    I tried to manually free used variables and call garbage collector, but it doesn't work because it should be called within sub threads, which I don't have access to, I suppose.

    Continue reading...

Compartilhe esta Página