How to compile Tensorflow with SSE4.2 and AVX instructions?

本文解释了在使用TensorFlow时遇到的关于SSE4.2和AVX指令集未被利用的警告信息,并提供了如何通过从源代码安装来充分利用这些指令集的方法。

This is the message received from running a script to check if Tensorflow is working:

Warning: The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.

Warning: The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.

what is SSE4.2 and AVX?

You may think about them as a set of some additional instructions for a computer to use multiple data points against a single instruction to perform operations which may be naturally parallelized (for example adding two arrays). That means, they are some instructions to speed up your compution.

Why you get the warning?

Most probably you have not installed TF from source and instead of it used something like pip install tensorflow. That means that you installed pre-built (by someone else) binaries which were not optimized for your architecture. And these warnings tell you exactly this: something is available on your CPU architecture, but it will not be used because the binary was not compiled with it. Here is the part from documentation.

Good thing is that most probably you just want to learn/experiment with TF so everything will work properly and you should not worry about it.

what if you want to get SSE4.2 and AVX compiled?

if you want to get full use of your CPU architecture, you can compile these SSE4.2 and AVX by install TF from source. Just follow the tensorflow offical website document to install. you do not need to uninstall the existing pip-installed tensorflow.

in the configure step , you will be ask:

Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:

keep Default configure you will get the optimization with your CPU archiitecture.

Learning TensorFlow: A Guide to Building Deep Learning Systems By 作者: Tom Hope – Yehezkel S. Resheff – Itay Lieder ISBN-10 书号: 1491978511 ISBN-13 书号: 9781491978511 Edition 版本: 1 Release 出版日期: 2017-08-28 pages 页数: (242) List Price: $49.99 Book Description Roughly inspired by the human brain, deep neural networks trained with large amounts of data can solve complex tasks with unprecedented accuracy. This practical book provides an end-to-end guide to TensorFlow, the leading open source software library that helps you build and train neural networks for computer vision, natural language processing (NLP), speech recognition, and general predictive analytics. Authors Tom Hope, Yehezkel Resheff, and Itay Lieder provide a hands-on approach to TensorFlow fundamentals for a broad technical audience—from data scientists and engineers to students and researchers. You’ll begin by working through some basic examples in TensorFlow before diving deeper into topics such as neural network architectures, TensorBoard visualization, TensorFlow abstraction libraries, and multithreaded input pipelines. Once you finish this book, you’ll know how to build and deploy production-ready deep learning systems in TensorFlow. Get up and running with TensorFlow, rapidly and painlessly Learn how to use TensorFlow to build deep learning models from the ground up Train popular deep learning models for computer vision and NLP Use extensive abstraction libraries to make development easier and faster Learn how to scale TensorFlow, and use clusters to distribute model training Deploy TensorFlow in a production setting Contents Chapter 1 Introduction Chapter 2 Go with the Flow: Up and running with TensorFlow Chapter 3 Understanding TensorFlow Basics Chapter 4 Convolutional Neural Networks Chapter 5 Working with Text and Sequences + TensorBoard visualization Chapter 6 TF Abstractions and Simplification Chapter 7 Queues, Threads, and Reading Data Chapter 8 Distributed TensorFlow Chapter 9 Serving Models Chapter 10 Miscellaneous
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值