首页 文章

bazel从源代码构建Tensorflow

提问于
浏览
2

我在python 3.6中有许多重要的深度学习任务,并希望从源代码构建tensorflow(仅限CPU),因为我的带有Touchbar 13的MacBook Pro“注意到如果使用SSE4.1 SSE4.2 AVX AVX2构建,则tensorflow会运行得更快有关该主题的StackOverflow和GitHub上存在很多问题,而且我都读了很多 . 其中没有一个是为什么它不适合我 .

我严格遵循https://www.tensorflow.org/install/install_sources提供的说明

我的配置看起来像这样

./configure
Please specify the location of python. [Default is /anaconda/bin/python]: /anaconda/python.app/Contents/MacOS/python
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] n
No XLA JIT 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
Found possible Python library paths:
  /anaconda/python.app/Contents/lib/python3.6/site-packages
Please input the desired Python library path to use.  Default is [/anaconda/python.app/Contents/lib/python3.6/site-packages]

Using python library path: /anaconda/python.app/Contents/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

与bazel 0.4.5然后我尝试按照说明进行构建

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

执行时没有错误,但它提供了数百个警告 . 我可以提供一个例子,但几乎没有任何片段在没有警告的情况下继续 .

我非常感谢你们,非常感谢你们 .

1 回答

  • 3

    不幸的是编译器警告是生活中的事实 . 但是,其中许多来自外部库,这些库被引入构建中 . 这些可以使用Bazel的“output_filter”参数过滤掉:

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

    这会将输出限制为TensorFlow代码生成的警告(您也可以通过这种方式完全关闭警告,但这会带来编译的所有乐趣) . 由于用于构建的工具与TensorFlow的开发匹配更紧密,所以警告更少(我得到一些关于多行注释延续,一堆有符号/无符号整数比较,以及一些关于“可能”未初始化的变量) .

    这些都没有表明明确的错误,只是有时容易出错的代码模式 . 如果编译器知道出错了,则会发出错误 . 这是一个很长的说法,没有什么可担心的 .

相关问题