How to compile tensorflow on CentOS
Tensorflow is a very effective machine learning library implemented by C++, we can use tensorflow with Python, but, there is a problem if we don't compile the tensorflow, it would cost a lot of time to compute. when we install the tensorflow with pip, we can see a warning message:"The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations." when import tensorflow. so, we need to compile the tensorflow library to speed up computation.
What to prepare:
- Java 8
- Bazel
- Tensorflow
- Python 3+
- CuDNN and CUDA toolkit(if you want to build tensorflow-gpu version)
Install Bazel:
- check you JAVA_HOME or test java: $ java -version
- get Bazel package: $ git clone https://github.com/bazelbuild/bazel.git (bazel can't install with yum.)
- switch to a proper version: $ git checkout tags/0.3.0
- $ cd bazel
- $ ./compile.sh
- add bazel to PATH for convenient: $ PATH = $PATH:(PATH_TO_BAZEL)/output/
Tensorflow:
- get Tensorflow package: $ git clone https://github.com/tensorflow/tensorflow
- $ cd tensorflow
configure
./configurePlease specify the location of python. [Default is /usr/bin/python]: /home/xxxx/.pyenv/version/python36/bin/pythonPlease specify optimization flags to use during compilation when bazel option"--config=opt"is specified [Default is -march=native]:Do you wish to use jemalloc as the malloc implementation? [Y/n] Yjemalloc enabledDo you wish to build TensorFlow with Google Cloud Platform support? [y/N] NNo Google Cloud Platform support will be enabledforTensorFlowDo you wish to build TensorFlow with Hadoop File System support? [y/N] NNo Hadoop File System support will be enabledforTensorFlowDo you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] NNo XLA JIT support will be enabledforTensorFlowFound possible Python library paths:/usr/local/lib/python2.7/dist-packages/usr/lib/python2.7/dist-packagesPlease input the desired Python library path to use. Default is [/usr/local/lib/python2.7/dist-packages]Using python library path: /home/xxxx/.pyenv/version/python36/lib/python3.6/site-packagesDo you wish to build TensorFlow with OpenCL support? [y/N] NNo OpenCL support will be enabledforTensorFlowDo you wish to build TensorFlow with CUDA support? [y/N] NConfiguration finished- build tensorflow with bazel: $ bazel build -c opt --copt=-msse4.1 --copt=-msse4.2 -k //tensorflow/tools/pip_package:build_pip_package
- build whl file: $ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
- install tensorflow with whl file: $ pip install --upgrade /tmp/tensorflow_pkg/<your whl file>.whl
#Troubleshotting
After installing tensorflow with whl file, if you get an error with message "illegal instruction", that may caused by you use unsupported sse to build tensorflow, AVX, SSE4.1, SSE4.2, MFA are different kinds of extended instruction sets on X86 CPUs. Many contain optimized instructions for processing matrix or vector operations. before installing, check which instructions your CPU support, and put those optimizing flags in for all.
$ bazel build -c opt --copt=-mavx --copt=-msse4.1 --copt=-msse4.2 -k //tensorflow/tools/pip_package:build_pip_package
This solution refer to: https://github.com/tensorflow/tensorflow/issues/8976
How to compile tensorflow on CentOS的更多相关文章
- 【转】Compile FFmpeg on CentOS 6.x
This guide is based on a minimal CentOS installation and will install FFmpeg with several external e ...
- CentOS 6 编译 TensorFlow for Java 以及 Maven Pom
我们的系统环境 CentOS 6.5, JDK 1.8 更新yum源 $ yum update 安装 Python 2.7 $ yum install python27 python27-numpy ...
- centos上tensorflow一键安装脚本
鉴于tensorflow在centos上安装相当麻烦,特地制作了一个脚本方便以后移植到其它机器上,脚本含有其它python常用包: #! /bin/bash sudo yum install -y ...
- Ubuntu TensorFlow 源码 Android Demo的编译运行
Ubuntu TensorFlow 源码 Android Demo的编译运行 一. 安装 Android 的SDK和NDK SDK 配置 A:下载 国内下载地址选最新的: SDK: https://d ...
- TensorFlow Android Camera Demo 使用android studio编译安装和解决Execution failed for task ':buildNativeBazel'报错
可以参考官网:https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android#android-stud ...
- Tensorflow[目录结构]
1 - Tensorflow源码目录结构 基于2018年5月28日github的tensorflow源码,即1.8版本 第一层: tensorflow: 核心代码目录. third_party:第三方 ...
- centos7 源码编译安装TensorFlow CPU 版本
一.前言 我们都知道,普通使用pip安装的TensorFlow是万金油版本,当你运行的时候,会提示你不是当前电脑中最优的版本,特别是CPU版本,没有使用指令集优化会让TensorFlow用起来更慢. ...
- How to install tensorflow from source on ubuntu 18.04 64bit
1,install dependencies sudo apt-get install openjdk-8-jdk git python-dev python3-dev python-numpy py ...
- TensorFlow编译androiddemo
首先是把tensorflow克隆到本地一份. git clone --recurse-submodules https://github.com/tensorflow/tensorflow.git 既 ...
随机推荐
- 在IE浏览器中url传参长度问题
1.在这之前我一直以为,应该说是并没有去思考过,url地址传参的长度限制问题:知道在项目材料价格系统中遇到之后,才对这个问题进行了具体的探索.IE中最大的长度限制为2084个,用于get传递数据的长度 ...
- EEG 睡眠 节律 代码
a1=load('EEG01.txt');[c,r]=size(a1);z=10;%等于几,绘图起点从几开始s=256*z;%绘图起点;还有,这里的256是采样率d=floor(c/256);cn=d ...
- TrustManagerService.java
/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Versi ...
- 在c#中 RemoveAt、 Remove、delete用法区别
有三种方法可以删除 DataTable 中的 DataRow: Delete 方法和 Remove 方法和 RemoveAt 方法 其区别是: Delete 方法实际上不是从 DataTable 中删 ...
- 你想知道吗?come
从大二接触Java开始,到现在也差不多三个年头了.从最基础的HTML.CSS到最后的SSH自己都是一步一个脚印走出来的,其中开心过.失落过.寂寞过.虽然是半道出家但是经过自己的努力也算是完成了“学业” ...
- socks5代理转http代理
Convert-Shadowsocks-into-an-HTTP-proxy apt-get install polipo service polipo stop polipo socksParent ...
- cf549B Looksery Party 贪心
题目大意:有n个员工,每个员工通讯录里有自己的号码和其他一些员工的号码.现在有若干员工参加一个聚会,他们会给自己通讯录里所有的人发一条短信,包括自己.现在有个人预测了每个员工会收到多少条短信,而你要寻 ...
- 关于JS的一些案例,setInterval,动态图片
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta ...
- 芯灵思Sinlinx A64开发板 Linux内核等待队列poll ---阻塞与非阻塞
开发平台 芯灵思Sinlinx A64 内存: 1GB 存储: 4GB 开发板详细参数 https://m.tb.cn/h.3wMaSKm 开发板交流群 641395230 阻塞:阻塞调用是指调用结果 ...
- Yii2 设计模式——工厂方法模式
工厂方法模式 模式定义 工厂方法模式(Factory Method Pattern)定义了一个创建对象的接口,但由子类决定要实例化的类是哪一个.工厂方法让类吧实例化推迟到子类. 什么意思?说起来有这么 ...