17

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

desertnaut
  • 57,590
  • 26
  • 140
  • 166
chapatigod
  • 191
  • 1
  • 1
  • 8

2 Answers2

25

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

cottontail
  • 10,268
  • 18
  • 50
  • 51
GTS
  • 550
  • 5
  • 7
1

To rebuild TensorFlow with compiler flags, you'll need to follow these steps:

  1. Install required dependencies: You'll need to install the necessary software and libraries required to build TensorFlow. This includes a Python environment, the Bazel build system, and the Visual Studio Build Tools.

  2. Clone the TensorFlow repository: Clone the TensorFlow repository from GitHub to your local machine. This will give you access to the source code for TensorFlow.

  3. Configure the build: Navigate to the TensorFlow repository you cloned in step 2 and run the configure.py script to configure the build. You can use the --copt flag to specify compiler flags during the configuration process.

  4. Build TensorFlow: Use the Bazel build system to build TensorFlow. You can use the bazel build command to build the TensorFlow library and its dependencies.

Here's how I built TensorFlow with compiler flags on my Windows 10 machine:

 # Clone the TensorFlow repository
 git clone https://github.com/tensorflow/tensorflow.git
 
 # Navigate to the TensorFlow repository
 cd tensorflow
 
 # Configure the build
 python configure.py --copt=-march=native
 
 # Build TensorFlow
 bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
Bellash
  • 7,560
  • 6
  • 53
  • 86
  • Line 3 does not work anymore: `python configure.py --copt=-march=native` `usage: configure.py [-h] [--workspace WORKSPACE] configure.py: error: unrecognized arguments: --copt=-march=native` – Putnik Aug 26 '23 at 18:22