Search code examples
pythontensorflow

How to rebuild tensorflow with the compiler flags?


I am trying to run binary classification with a tensorflow backend but I keep receiving an error that I believe asks me to rebuild tensorflow with the right compiler flags. I know that my code and data is functionally, so I think the problem is with virtual environment. I have tried finding solutions on tensorflow's website, ibm's website, and stack overflow, but I haven't been successful. I have also tried reinstalling tensorflow and python.

Full Traceback:

I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set

I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA

To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.

Virtual Environment Info:

-using a anaconda environment

-Python 3.7.9

-tensorflow 2.4.1


Solution

  • I hid these warnings with:

    import os
    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
    

    Note that this doesn't rebuild TensorFlow, but just hides the warning.

    Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2