How to compile Tensorflow with SSE4.2 and AVX instructions?

前端 未结 12 854
南笙
南笙 2020-11-22 04:14

This is the message received from running a script to check if Tensorflow is working:

I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUD         


        
12条回答
  •  無奈伤痛
    2020-11-22 04:34

    When building TensorFlow from source, you'll run the configure script. One of the questions that the configure script asks is as follows:

    Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]
    

    The configure script will attach the flag(s) you specify to the bazel command that builds the TensorFlow pip package. Broadly speaking, you can respond to this prompt in one of two ways:

    • If you are building TensorFlow on the same type of CPU type as the one on which you'll run TensorFlow, then you should accept the default (-march=native). This option will optimize the generated code for your machine's CPU type.
    • If you are building TensorFlow on one CPU type but will run TensorFlow on a different CPU type, then consider supplying a more specific optimization flag as described in the gcc documentation.

    After configuring TensorFlow as described in the preceding bulleted list, you should be able to build TensorFlow fully optimized for the target CPU just by adding the --config=opt flag to any bazel command you are running.

提交回复
热议问题