Tony Einstein 2022-11-09 22:27 采纳率: 45%
浏览 4664
已结题

使用KMeans拟合数据的时候出现警告You can avoid it by setting the environment variable OMP_NUM_THREADS=2

问题遇到的现象和发生背景

使用KMeans拟合数据的时候出现警告。由于可能是数据量太大,然后出现这个情况,但是数据量很少的时候也会出现这个警告。

运行结果及报错内容
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=2.

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.
我想要达到的结果

请问我该如何消除警告,并解决这个提示的内存泄露。

  • 写回答

1条回答 默认 最新

  • 玉堃 2022-11-10 13:45
    关注

    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.**
    根据这个报错的提示,你可以尝试 setting the environment variable OMP_NUM_THREADS=1.
    即,在py文件的开头添加

    import os
    os.environ["OMP_NUM_THREADS"] = '1'
    

    该解决方法来自:https://stackoverflow.com/questions/69596239/how-to-avoid-memory-leak-when-dealing-with-kmeans-for-example-in-this-code-i-am

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

    报告相同问题?

    问题事件

    • 系统已结题 11月18日
    • 已采纳回答 11月10日
    • 创建了问题 11月9日

    悬赏问题

    • ¥15 Qt 不小心删除了自带的类,该怎么办
    • ¥15 我需要在PC端 开两个抖店工作台客户端.(语言-java)
    • ¥15 有没有哪位厉害的人可以用C#可视化呀
    • ¥15 可以帮我看看代码哪里错了吗
    • ¥15 设计一个成绩管理系统
    • ¥15 PCL注册的选点等函数如何取消注册
    • ¥15 问一下各位,为什么我用蓝牙直接发送模拟输入的数据,接收端显示乱码呢,米思齐软件上usb串口显示正常的字符串呢?
    • ¥15 Python爬虫程序
    • ¥15 crypto 这种的应该怎么找flag?
    • ¥15 代码已写好,求帮我指出错误,有偿!