1

I have tried to compile Tensorflow 2.0 to get the benefits of extra cpu instructions like avx, but to no avail. I have read through How to compile Tensorflow with SSE4.2 and AVX instructions? but I am still confused as unless you are building for another PC surely -march=native should just work. I have tried building 2 times with different instructions and am still getting the warning message. I think I used the below, and I think I have the logs still saved if someone wants to help. "bazel build //tensorflow/tools/pip_package:build_pip_package d_pip_package --config=mkl"

"bazel build -c opt --copt=-march=native --config=mkl //tensorflow/tools/pip_package:build_pip_package

This is only for the satisfaction of understanding what is going on. I currently don't need the benefit the optimisation will bring, but I do not understand why the method I used isn't working as I followed it exactly.

apuri123
  • 11
  • 2

1 Answers1

0

As noted by my edit in the top answer on the question you linked, it seems bazel and/or TensorFlow's build scripts are buggy. They mishandle -march=native and fail to pass it on to the compiler. I'm guessing it does something wrong with args that have an = in their name, because args like -mfma work.

You are correct, if they were correctly passing -march=native to the compiler there would be no problem, and no need for any of this complication.

IDK why nobody's fix this huge inconvenience yet, instead leaving lots of users who aren't experts on x86 CPU features to stumble around trying to figure out which features their CPU has and how to enable them for gcc/clang. This is exactly what -march=native is for, along with the other important feature of setting tuning options appropriately for the machine you're compiling on.

I had a look once, but I don't actually use TensorFlow and don't know bazel so I got bogged down in the maze of build machinery between that command line and actual invocation of g++ ... foo.cpp

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • Ok, I saw that but just assumed by default I had done something wrong. I guess there is nothing more that someone of my level can do. I did manage at some point to get a list of all the features my CPU supported, but I don't know how run the build command properly with them. – apuri123 Jan 16 '20 at 18:21