Suppress OpenMP debug messages when running Tensorflow on CPU

前端 未结 2 1141
误落风尘
误落风尘 2021-01-19 15:00

When running a Python program on Linux that includes import tensorflow (installed without GPU support), a bunch of OpenMP debug messages are written to stdout,

2条回答
  •  鱼传尺愫
    2021-01-19 15:38

    As the other answer told me what to do but not exactly how to do it, I decided to add my answer.

    If you want to suppress these warnings, you can do so by setting the KMP_WARNINGS environment variable to a false value. In code, you can do this as follows; in your script you need to first import os and then set the environ variable, like so:

    import os
    os.environ["KMP_WARNINGS"] = "FALSE" 
    

    Any false value works here as long its a string format, "0" , "off" and "no" will also work.

提交回复
热议问题