码迷,mamicode.com
首页 > 其他好文 > 详细

编译TensorFlow源码

时间:2017-09-26 00:56:34      阅读:766      评论:0      收藏:0      [点我收藏+]

标签:opencl   source   swig   ubuntu   htm   tor   源码   release   strong   

                      编译TensorFlow源码

 

参考:

https://www.tensorflow.org/install/install_sources

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/go/README.md

一 环境

ubuntu 16.04.2   (virtualbox 虚拟机)

        

二  安装 bazel

参考:https://docs.bazel.build/versions/master/install-ubuntu.html

Using Bazel custom APT repository (recommended)

1. Install JDK 8

Install JDK 8 by using:

sudo apt-get install openjdk-8-jdk

 

On Ubuntu 14.04 LTS you‘ll have to use a PPA:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update && sudo apt-get install oracle-java8-installer

  

2. Add Bazel distribution URI as a package source (one time setup)

echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -

 

If you want to install the testing version of Bazel, replace stable with testing.

 

3. Install and update Bazel

sudo apt-get update && sudo apt-get install bazel


Once installed, you can upgrade to a newer version of Bazel with:

sudo apt-get upgrade bazel

 

三 Python和Swig

sudo apt-get install python3-numpy python3-dev python3-pip python3-wheel  swig

 

四 下载源码及编译TensorFlow

github直接下载最新代码  https://github.com/tensorflow/tensorflow

终端切换到源码主目录,

./configure

涉及一些交互项

dell@dell-VirtualBox:~/tensorflow-master$ ./configure 
WARNING: ignoring http_proxy in environment.
You have bazel 0.5.4 installed.
Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3.5


Found possible Python library paths:
  /usr/local/lib/python3.5/dist-packages
  /usr/lib/python3/dist-packages
Please input the desired Python library path to use.  Default is [/usr/local/lib/python3.5/dist-packages]

Do you wish to build TensorFlow with jemalloc as malloc support? [Y/n]: y
jemalloc as malloc support will be enabled for TensorFlow.

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 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 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.

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]: 


Add "--config=mkl" to your bazel command to build with MKL support.
Please note that MKL on MacOS or windows is still not supported.
If you would like to use a local MKL instead of downloading, please set the environment variable "TF_MKL_ROOT" every time before build.
Configuration finished

开始编译

 

bazel build --config opt //tensorflow:libtensorflow.so

 

耗时比较长,用了90多分钟。

./tensorflow/core/framework/function.h:526:3: note: in expansion of macro REGISTER_OP_GRADIENT_UNIQ
   REGISTER_OP_GRADIENT_UNIQ(ctr, name, fn)
   ^
./tensorflow/core/framework/function.h:520:3: note: in expansion of macro REGISTER_OP_GRADIENT_UNIQ_HELPER
   REGISTER_OP_GRADIENT_UNIQ_HELPER(__COUNTER__, name, fn)
   ^
tensorflow/core/ops/nn_grad.cc:182:1: note: in expansion of macro REGISTER_OP_GRADIENT
 REGISTER_OP_GRADIENT("MaxPool", MaxPoolGrad);
 ^
./tensorflow/core/framework/function.h:529:15: warning: tensorflow::unused_grad_6 defined but not used [-Wunused-variable]
   static bool unused_grad_##ctr = SHOULD_REGISTER_OP_GRADIENT &&                ^
./tensorflow/core/framework/function.h:526:3: note: in expansion of macro REGISTER_OP_GRADIENT_UNIQ
   REGISTER_OP_GRADIENT_UNIQ(ctr, name, fn)
   ^
./tensorflow/core/framework/function.h:520:3: note: in expansion of macro REGISTER_OP_GRADIENT_UNIQ_HELPER
   REGISTER_OP_GRADIENT_UNIQ_HELPER(__COUNTER__, name, fn)
   ^
tensorflow/core/ops/nn_grad.cc:208:1: note: in expansion of macro REGISTER_OP_GRADIENT
 REGISTER_OP_GRADIENT("AvgPool", AvgPoolGrad);
 ^
./tensorflow/core/framework/function.h:529:15: warning: tensorflow::unused_grad_7 defined but not used [-Wunused-variable]
   static bool unused_grad_##ctr = SHOULD_REGISTER_OP_GRADIENT &&                ^
./tensorflow/core/framework/function.h:526:3: note: in expansion of macro REGISTER_OP_GRADIENT_UNIQ
   REGISTER_OP_GRADIENT_UNIQ(ctr, name, fn)
   ^
./tensorflow/core/framework/function.h:520:3: note: in expansion of macro REGISTER_OP_GRADIENT_UNIQ_HELPER
   REGISTER_OP_GRADIENT_UNIQ_HELPER(__COUNTER__, name, fn)
   ^
tensorflow/core/ops/nn_grad.cc:239:1: note: in expansion of macro REGISTER_OP_GRADIENT
 REGISTER_OP_GRADIENT("MaxPoolGrad", MaxPoolGradGrad);
 ^
./tensorflow/core/framework/function.h:529:15: warning: tensorflow::unused_grad_8 defined but not used [-Wunused-variable]
   static bool unused_grad_##ctr = SHOULD_REGISTER_OP_GRADIENT &&                ^
./tensorflow/core/framework/function.h:526:3: note: in expansion of macro REGISTER_OP_GRADIENT_UNIQ
   REGISTER_OP_GRADIENT_UNIQ(ctr, name, fn)
   ^
./tensorflow/core/framework/function.h:520:3: note: in expansion of macro REGISTER_OP_GRADIENT_UNIQ_HELPER
   REGISTER_OP_GRADIENT_UNIQ_HELPER(__COUNTER__, name, fn)
   ^
tensorflow/core/ops/nn_grad.cc:260:1: note: in expansion of macro REGISTER_OP_GRADIENT
 REGISTER_OP_GRADIENT("BiasAdd", BiasAddGrad);
 ^
Target //tensorflow:libtensorflow.so up-to-date:
  bazel-bin/tensorflow/libtensorflow.so
INFO: Elapsed time: 5544.039s, Critical Path: 63.77s
INFO: Build completed successfully, 2293 total actions

 

 

编译TensorFlow源码

标签:opencl   source   swig   ubuntu   htm   tor   源码   release   strong   

原文地址:http://www.cnblogs.com/majianguo/p/7594505.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!