编译TensorFlow源码
编译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--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. installed.
Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3. Found possible Python library paths:
/usr/local/lib/python3./dist-packages
/usr/lib/python3/dist-packages
Please input the desired Python library path to use. Default is [/usr/local/lib/python3./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::: note: in expansion of macro 'REGISTER_OP_GRADIENT_UNIQ'
REGISTER_OP_GRADIENT_UNIQ(ctr, name, fn)
^
./tensorflow/core/framework/function.h::: note: in expansion of macro 'REGISTER_OP_GRADIENT_UNIQ_HELPER'
REGISTER_OP_GRADIENT_UNIQ_HELPER(__COUNTER__, name, fn)
^
tensorflow/core/ops/nn_grad.cc::: note: in expansion of macro 'REGISTER_OP_GRADIENT'
REGISTER_OP_GRADIENT("MaxPool", MaxPoolGrad);
^
./tensorflow/core/framework/function.h::: 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::: note: in expansion of macro 'REGISTER_OP_GRADIENT_UNIQ'
REGISTER_OP_GRADIENT_UNIQ(ctr, name, fn)
^
./tensorflow/core/framework/function.h::: note: in expansion of macro 'REGISTER_OP_GRADIENT_UNIQ_HELPER'
REGISTER_OP_GRADIENT_UNIQ_HELPER(__COUNTER__, name, fn)
^
tensorflow/core/ops/nn_grad.cc::: note: in expansion of macro 'REGISTER_OP_GRADIENT'
REGISTER_OP_GRADIENT("AvgPool", AvgPoolGrad);
^
./tensorflow/core/framework/function.h::: 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::: note: in expansion of macro 'REGISTER_OP_GRADIENT_UNIQ'
REGISTER_OP_GRADIENT_UNIQ(ctr, name, fn)
^
./tensorflow/core/framework/function.h::: note: in expansion of macro 'REGISTER_OP_GRADIENT_UNIQ_HELPER'
REGISTER_OP_GRADIENT_UNIQ_HELPER(__COUNTER__, name, fn)
^
tensorflow/core/ops/nn_grad.cc::: note: in expansion of macro 'REGISTER_OP_GRADIENT'
REGISTER_OP_GRADIENT("MaxPoolGrad", MaxPoolGradGrad);
^
./tensorflow/core/framework/function.h::: 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::: note: in expansion of macro 'REGISTER_OP_GRADIENT_UNIQ'
REGISTER_OP_GRADIENT_UNIQ(ctr, name, fn)
^
./tensorflow/core/framework/function.h::: note: in expansion of macro 'REGISTER_OP_GRADIENT_UNIQ_HELPER'
REGISTER_OP_GRADIENT_UNIQ_HELPER(__COUNTER__, name, fn)
^
tensorflow/core/ops/nn_grad.cc::: 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: .039s, Critical Path: .77s
INFO: Build completed successfully, total actions
编译TensorFlow源码的更多相关文章
- Ubuntu TensorFlow 源码 Android Demo的编译运行
Ubuntu TensorFlow 源码 Android Demo的编译运行 一. 安装 Android 的SDK和NDK SDK 配置 A:下载 国内下载地址选最新的: SDK: https://d ...
- tensorflow 源码编译tensorflow 1.1.0到 tensorflow 2.0,ver:1.1.0rc1、1.4.0rc1、1.14.0-rc1、2.0.0b1
目录 tensorflow-build table 更多详细过程信息及下载: tensorflow-build tensorflow 源码编译,提升硬件加速,支持cpu加速指令,suport SSE4 ...
- TensorFlow源码安装
前言 TensorFlow如果能二进制包安装,我真的不想选择自己编译,但是情况不由人,好不容易找到一台服务器,CPU不支持AVX指令集,安装的release版本运行到import tensorflow ...
- Tensorflow源码解析1 -- 内核架构和源码结构
1 主流深度学习框架对比 当今的软件开发基本都是分层化和模块化的,应用层开发会基于框架层.比如开发Linux Driver会基于Linux kernel,开发Android app会基于Android ...
- Tensorflow[源码安装时bazel行为解析]
0. 引言 通过源码方式安装,并进行一定程度的解读,有助于理解tensorflow源码,本文主要基于tensorflow v1.8源码,并借鉴于如何阅读TensorFlow源码. 首先,自然是需要去b ...
- [图解tensorflow源码] 入门准备工作附常用的矩阵计算工具[转]
[图解tensorflow源码] 入门准备工作 附常用的矩阵计算工具[转] Link: https://www.cnblogs.com/yao62995/p/5773142.html tensorf ...
- Ubuntu16.04系统Tensorflow源码安装
最近学习Tensorflow,记录一下安装过程.目前安装的是CPU版的 1.下载tensorflow源码 tensorflow是个开源库,在github上有源码,直接在上面下载.下载地址:https: ...
- tensorflow源码分析
前言: 一般来说,如果安装tensorflow主要目的是为了调试些小程序的话,只要下载相应的包,然后,直接使用pip install tensorflow即可. 但有时我们需要将Tensorflow的 ...
- Windows编译Nginx源码
Windows下的Nginx战役,人不作就不会死!就像是拿着麦当劳的优惠券去买肯德基一样,别扭啊 Nginx是一款轻量级的Web 服务器.反向代理服务器.邮件服务器等等集一大串荣誉于一身的大牌人物!他 ...
随机推荐
- 实验:企业级分布式存储应用与实战-mogilefs实现
实验:企业级分布式存储应用与实战-mogilefs实现 (1)安装mogilefs 1.创建一个存放安装mogilefs所需的软件包的目录 cd /app/ mkdir mogilefs cd mog ...
- 爬起点小说 day01
先介绍下我自己爬起点小说的思路: 1.爬取所有的类型列表 a.链接存redis中 类型表:novel_list 具体每一种类型:bnovel_all_list(把novel_list和bnovel_l ...
- 案例学习总结:原生JS实现表格排序
最近在学习js的表格排序,没想到看不起眼的表格排序实际上却暗含了众多JS知识点.在这里记录一下此次学习过程.希望对大家也有所帮助. 完整的表格排序涉及了下列这些知识点: call方法使用 sort方法 ...
- 实战-Mysql5.6.36脚本编译安装及初始化
概述 本文为centos7.3自动化编译安装mysql5.3.6的脚本及后续初始化操作,话不多少,直接上脚本. 安装脚本install.py如下: #coding=utf-8 #!/usr/bin/p ...
- linux系统下安装配置解压版的MySQL数据库
一.解压文件到当前目录 命令:tar -zxvf mysql....tar.gz 二.移动解压完成的文件夹到目标目录并更名mysql 命令:mv mysql-版本号 /usr/local/mysql ...
- wkhtmltopdf
最近要做一个html转pdf的功能,在网上找了很多内容,itext什么的,都不太满意,最后找到一个wkhtmltopdf,用起来真的很不错,还找到了一篇好文章,我就直接抄过来了,等有时间我再自己理一遍 ...
- RxAndroid中observable的基本使用和表单校验操作
RxAndroid 响应式编程 类似于监听-观察者模式 在观察者模式中,你的对象需要实现 RxJava 中的两个关键接口:Observable 和 Observer.当 Observable 的状态改 ...
- maven的安装配置以及在IDEA中配置
一.下载maven: 1.maven官网:http://maven.apache.org/download.cgi 二.安装配置 1.下载后解压到本地目录,如图 2.配置环境变量:我的电脑右键-> ...
- 数学之美?编程之美?数学 + 编程= unbelievable 美!
欢迎大家前往腾讯云社区,获取更多腾讯海量技术实践干货哦~ 作者:Rusu 导语 相信大家跟我一样,偶尔会疑惑:曾经年少的时候学习过的那么多的复杂的数学函数,牛逼的化学方程式,各种物理原理.公式,到底有 ...
- css实现垂直水平居中的5种方法
css实现垂直水平居中的5种方法 给父元素设置table-cell,text-align,vertical-align #big{ width: 200px; height: 200px; borde ...