源代碼樹的根目錄中包含了一個名爲 configure 的 bash 腳本。
$ ./configure
接下來,配置系統會給出各類詢問,以確認編譯時的配置參數。
1、重要參數解釋
Please specify the location of python. [Default is /usr/bin/python]: /usr/local/bin/python3
上面的提示是Bazel讓咱們選擇Python的安裝路徑,這裏輸入了python3的路徑。直接按回車鍵(Enter)表示使用默認值。
Do you wish to build TensorFlow with jemalloc as malloc support? [Y/n]:
jemalloc as malloc support will be enabled for TensorFlow.
上面的選項表示是否使用jemalloc代替傳統的malloc來管理內存?Jemalloc是傑森·埃文斯(Jason Evans)於2006年開發的用以取代傳統低性能的malloc內存管理模塊而開發的一款內存管理模塊[4]。埃文斯並不是等閒之輩,他是FreeBSD項目(一種類UNIX操做系統)的重要維護者之一。
Jemalloc先被Firefox瀏覽器採用,後來又被Facebook在其本身的各種應用上普遍使用,一戰成名。好技術固然要用!直接按回車,確認默認值Y。
Do you wish to build TensorFlow with Google Cloud Platform support? [Y/n]: n
No Google Cloud Platform support will be enabled for TensorFlow.
這個選項是詢問是否採用Google雲平臺來支持TensorFlow。這個雲平臺國內一般沒法訪問,建議輸入「n」。有條件的讀者,可直接按回車確認使用。
Do you wish to build TensorFlow with Hadoop File System support? [Y/n]: n
No Hadoop File System support will be enabled for TensorFlow.
這個選項是詢問是否使用Hadoop 文件系統(HDFS)來支持TensorFlow。若是搭建了Hadoop集羣,有讀取HDFS數據需求的用戶,能夠回車確認。若是沒有需求,手動輸入「n」。
Do you wish to build TensorFlow with Amazon S3 File System support? [Y/n]: n
No Amazon S3 File System support will be enabled for TensorFlow.
相似的,這個選項是詢問TensorFlow是否支持亞馬遜的S3文件系統。讀者根據本身的須要來肯定「Y」或「n」。若是用不着,建議選擇「n」。
Do you wish to build TensorFlow with Apache Kafka Platform support? [y/N]:
No Apache Kafka Platform support will be enabled for TensorFlow.
Kafka是由Apache軟件基金會開發的一個開源流處理平臺,是一種高吞吐量的分佈式發佈訂閱消息系統。若是沒有這個須要,建議選擇默認值「N」。
Do you wish to build TensorFlow with XLA JIT support? [y/N]: n
No XLA JIT support will be enabled for TensorFlow.
這個選項是詢問是否開啓XLA JIT編譯支持。XLA(Accelerated Linear Algebra/加速線性代數)目前仍是TensorFlow的實驗項目,XLA 使用 JIT(Just in Time,即時編譯)技術來分析用戶在運行時(runtime)建立的 TensorFlow 圖,專門用於實際運行時的維度和類型。做爲新技術,這項編譯技術還不成熟,愛折騰的「極客」讀者能夠選「y」,不然選擇默認值「N」。
Do you wish to build TensorFlow with CUDA support? [y/N]:
No CUDA support will be enabled for TensorFlow.
這個選項是詢問是否使用CUDA。CUDA是一種由NVIDIA推出的通用並行計算架構,該架構使GPU可以解決複雜的計算問題。若是用戶配備有NVIDIA的GPU,能夠選擇「y」,若是僅使用TensorFlow的CPU版本,回車確認「N」。
Do you wish to build TensorFlow with MPI support? [y/N]:
No MPI support will be enabled for TensorFlow.
這個選項是詢問是否使用MPI。MPI(Message-Passing-Interface 消息傳遞接口)是實現進程級別的並行程序的通訊協議,它經過在進程之間進行消息傳遞。若是不是基於TensorFlow作並行程序開發,建議回車確認選擇默認值「N」。
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:
這個選項是指定CPU編譯優化選項。默認值就是「-march=native」。這裏「m」表示「machine(機器)」,「arch」就是「architecture」簡寫。「march」合在一塊兒表示機器的結構,若是選擇「-march=native」,則表示選擇本地(native)CPU,若是本地CPU比較高級,就能夠支持SSE4.二、AVX等選項。這裏建議選擇默認值。
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]:
這個選項是問是否進入Android的工做空間配置,若是不用手機版的TensorFlow開發,則選擇默認值「N」。
以後,當顯示「Configuration finished」(配置完成)字樣,則表示配置順利完成。
2、在同一個源代碼樹中的不一樣配置之間進行切換時運行 bazel clean。
3、實際配置全過程(tensorflow1.9+python3)
➜ tensorflow git:(master) ./configure
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.15.2-homebrew installed.
Please specify the location of python. [Default is /usr/bin/python]: /usr/local/bin/python3
Found possible Python library paths:
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
Please input the desired Python library path to use. Default is [/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages]
Do you wish to build TensorFlow with Google Cloud Platform support? [Y/n]: n
No Google Cloud Platform support will be enabled for TensorFlow.
Do you wish to build TensorFlow with Hadoop File System support? [Y/n]: n
No Hadoop File System support will be enabled for TensorFlow.
Do you wish to build TensorFlow with Amazon AWS Platform support? [Y/n]: n
No Amazon AWS Platform support will be enabled for TensorFlow.
Do you wish to build TensorFlow with Apache Kafka Platform support? [Y/n]: n
No Apache Kafka Platform support will be enabled for TensorFlow.
Do you wish to build TensorFlow with XLA JIT support? [y/N]: n
No XLA JIT support will be enabled for TensorFlow.
Do you wish to build TensorFlow with GDR support? [y/N]: n
No GDR support will be enabled for TensorFlow.
Do you wish to build TensorFlow with VERBS support? [y/N]: n
No VERBS support will be enabled for TensorFlow.
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: n
No OpenCL SYCL support will be enabled for TensorFlow.
Do you wish to build TensorFlow with CUDA support? [y/N]: n
No CUDA support will be enabled for TensorFlow.
Do you wish to download a fresh release of clang? (Experimental) [y/N]: n
Clang will not be downloaded.
Do you wish to build TensorFlow with MPI support? [y/N]: n
No MPI support will be enabled for TensorFlow.
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: n
Not configuring the WORKSPACE for Android builds.
Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See tools/bazel.rc for more details.
--config=mkl # Build with MKL support.
--config=monolithic # Config for mostly static monolithic build.
Configuration finished