簡體   English   中英

在編譯Tensorflow時如何執行Bazel Build Command?

[英]How should I execute the Bazel Build Command in compiling Tensorflow?

我一直在嘗試安裝Tensorflow幾周,我在簡單安裝時遇到了很多錯誤,所以我認為最好從源代碼安裝Tensorflow。 我正在按照Tensorflow網站上的說明完成,我的./configure大部分都是默認的,所以我可以在修改之前看看它是否有效:

./configure Please specify the location of python. [Default is /usr/bin/python]: /Library/Frameworks/Python.framework/Versions/3.6/bin/python3 Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]: 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 the XLA just-in-time compiler (experimental)? [y/N] No XLA support will be enabled for TensorFlow Found possible Python library paths: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages Please input the desired Python library path to use. Default is [/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages] /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages Do you wish to build TensorFlow with OpenCL support? [y/N] n No OpenCL 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 INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes. Configuration finished

(這不是我第一次編輯配置)

在此之后,我直接從Tensorflow.org網站上執行以下bazel構建命令,從源代碼安裝:

bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

(將來,我將添加一些額外的標志來解釋我一直在獲取有關SSE,AVX等的CPU指令錯誤這一事實)

當我執行那個bazel命令時,我得到一個非常長的等待時間和一堆錯誤:

r08ErCk:tensorflow kendrick$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package WARNING: /Users/kendrick/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': Use SavedModel Builder instead. WARNING: /Users/kendrick/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': Use SavedModel instead. INFO: Found 1 target... INFO: From Compiling external/protobuf/src/google/protobuf/compiler/js/embed.cc [for host]: external/protobuf/src/google/protobuf/compiler/js/embed.cc:37:12: warning: unused variable 'output_file' [-Wunused-const-variable] const char output_file[] = "well_known_types_embed.cc"; ^ 1 warning generated. INFO: From Compiling external/protobuf/python/google/protobuf/pyext/message_factory.cc: external/protobuf/python/google/protobuf/pyext/message_factory.cc:78:28: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings] static char* kwlist[] = {"pool", 0}; ^ external/protobuf/python/google/protobuf/pyext/message_factory.cc:222:6: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings] {"pool", (getter)GetPool, NULL, "DescriptorPool"}, ^ external/protobuf/python/google/protobuf/pyext/message_factory.cc:222:37: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings] {"pool", (getter)GetPool, NULL, "DescriptorPool"}, ^ 3 warnings generated.

這只是所有錯誤的一小部分,看起來類似於堆積的錯誤。 即使在所有錯誤消息之后,命令也永遠不會返回,我只是在空行上獲得閃爍的光標。

有人可以請我提供一些關於我應該進入終端的確切說明以避免這些錯誤嗎? 幾周以來我一直在關注堆棧建議,但仍然會出現錯誤。

MAC OS Sierra(MacBook Air)

我該怎么進入終端? (特別)

到目前為止,我所做的一切幾乎都與Tensorflow.org網站上的說明完全相同。

我是第一次使用http://queirozf.com/entries/installing-cuda-tk-and-tensorflow-on-a-clean-ubuntu-16-04-install安裝,這不僅是一個非常簡單的過程,但是使用tf非常簡單..只需要source <name_of_virtual_environment>/bin/activate ,然后通過它運行python / python3。
請記住,鏈接中的演練是針對gpu tensorflow的,但是使用cpu tensorflow下載為mac,而使用此虛擬環境進程應該可以正常工作。

由於你沒有GPU,你有SSE和AVX,並且在mac sierra上 - 谷歌上的說明不適用於1.3。 我很困惑為什么他們沒有提供一個確切的腳本來做到這一點。 無論如何,這是您的問題的答案http://www.josephmiguel.com/building-tensorflow-1-3-from-source-on-mac-osx-sierra-macbook-pro-i7-with-sse-and -avx /

/*
do each of these steps independently
will take around 1hr to complete all the steps regardless of machine type

*/


one time install

install anaconda3 pkg # manually download this and install the package
conda update conda
conda create -n dl python=3.6 anaconda
source activate dl

cd /
brew install bazel
pip install six numpy wheel
pip install –upgrade https://storage.googleapis.com/tensorflow/mac/cpu/protobuf-3.1.0-cp35-none-macosx_10_11_x86_64.whl

sudo -i
cd /
rm -rf tensorflow # if rerunning the script
cd /
git clone https://github.com/tensorflow/tensorflow


Step 1

cd /tensorflow
git checkout r1.3 -f
cd /
chmod -R 777 tensorflow
cd /tensorflow
./configure # accept all default settings


Step 2

// https://stackoverflow.com/questions/41293077/how-to-compile-tensorflow-with-sse4-2-and-avx-instructions
bazel build –config=opt –copt=-mavx –copt=-mavx2 –copt=-mfma //tensorflow/tools/pip_package:build_pip_package


Step 3

bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
pip install /tmp/tensorflow_pkg/tensorflow-1.0.1-cp36-cp36m-macosx_10_7_x86_64.whl


Step 4

cd ~
ipython


Step 5

import tensorflow as tf
hello = tf.constant(‘Hello, TensorFlow!’)
sess = tf.Session()
print(sess.run(hello))


Step 6

pip uninstall /tmp/tensorflow_pkg/tensorflow-1.0.1-cp36-cp36m-macosx_10_7_x86_64.whl

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM