是否有未针对AVX指令编译的TensorFlow版本? [英] Is there a version of TensorFlow not compiled for AVX instructions?

查看:61
本文介绍了是否有未针对AVX指令编译的TensorFlow版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的Chromebook上安装TensorFlow,这不是最好的地方,但我只是想对此有所了解.我在Python开发环境中或在任何开发环境中都没有做太多工作,所以请多多包涵. 弄清楚pip之后,我安装了TensorFlow并尝试将其导入,收到此错误:

I'm trying to get TensorFlow up on my Chromebook, not the best place, I know, but I just want to get a feel for it. I haven't done much work in the Python dev environment, or in any dev environment for that matter, so bear with me. After figuring out pip, I installed TensorFlow and tried to import it, receiving this error:

Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2018-12-11 06:09:54.960546: F tensorflow/core/platform/cpu_feature_guard.cc:37] The TensorFlow library was compiled to use AVX instructions, but these aren't available on your machine.
Aborted (core dumped)

经过一番研究,我发现我的处理器(Intel Celeron N2840(Bay Trail-M架构))不支持AVX指令,所以我想知道是否有办法使用针对其他指令编译的版本放. Cog告诉我可以使用MMX和各种SSE(无论什么意思).

After some research, I have discovered that my processor (an Intel Celeron N2840 (Bay Trail-M Architecture)) does not support AVX instructions, so I was wondering if there was a way to use a version compiled for some other instruction set. Cog tells me I can use MMX and various SSEs (whatever the hell that means).

P.S.这是在同一台计算机的Windows上工作时,在Linux上使用AVX指令使用TensorFlow错误,但并非完全如此.另外,我没有评论,因为我没有50个声誉.

P.S. This is sort of a duplicate of TensorFlow error using AVX instructions on Linux while working on Windows on the same machine but not entirely. Plus I can't comment because I don't have 50 reputation.

P.P.S.我看了如何使用SSE4.2和AVX指令?而感到害怕

P.P.S. I looked at How to compile Tensorflow with SSE4.2 and AVX instructions? and got scared

推荐答案

peter-cordes 建议的最佳做法a>是通过发出以下命令来查看gcc将如何使您的"cpu具有什么功能":

A best practices approach suggested by peter-cordes is to see what gcc is going to make of your 'what capabilities your cpu has' by issuing the following:

gcc -O3 -fverbose-asm -march=native -xc /dev/null -S -o- | less

此命令将从gcc的视图(将由谁来进行构建)中提供有关您cpu功能的信息(全部),因此gcc的视图很重要.

This command will provide information (all) about your cpu capabilities from the view of gcc, whom is going to do the build, so gcc's view matters.

什么时候出现?当某个程序根据您的cpu量身定制时. ang我对我的CPU有什么了解.好吧,以上一行会告诉您所有您需要了解的内容.

When does this come up? When a program offers to tailor itself to your cpu. Dang. What do I know about my cpu. Well, the above line will tell you all you need to know.

也就是说,一般而言,正在推广基于cpu的功能的人员/开发人员将陈述或建议一系列列表,如果您的cpu具有*,则这些列表会更快/更好/更强.以上将为您提供*.仔细阅读您所看到的内容.如果您没有它,就不要它,即

That said, generally, people/developers that are promoting cpu based capabilities will state or suggest a list of things that go faster/better/stronger if your cpu has *. And the above will give you *. Read carefully what you see. If you don't have it, you don't want it, i.e.

-mno-avx(whatever you don't want;in my case it was avx)

由以下提供了有关在较老的cpu上支持CPU的安装的良好概述:

A good overview of install of CPU capable on older cpu(s) is provided by Mikael Fernandez Simalango for Ubuntu 16.04 LTS. It assumes a python2.7 environ but easily translates to python3. The heart of the matter is extracting which cpu instruction extensions are available on your particular cpu that will be used in addition to -march=native via /proc/cpuinfo, (but note, it appears limited to what flags it accepts, so may be better to actually read through the instruction above and reflect)

grep flags -m1 /proc/cpuinfo | cut -d ":" -f 2 | tr '[:upper:]' 
'[:lower:]' | { read FLAGS; OPT="-march=native"; for flag in $FLAGS; 
do case "$flag" in "sse4_1" | "sse4_2" | "ssse3" | "fma" | "cx16" | 
"popcnt" | "avx" | "avx2") OPT+=" -m$flag";; esac; done; 
MODOPT=${OPT//_/\.}; echo "$MODOPT"; }

在我的旧盒子输出中运行它:

Running this on my old box output:

-march=native -mssse3 -mcx16 -msse4.1 -msse4.2 -mpopcnt

它在那里出现了.目前尚不清楚如何说不是这个"和不是那个",对于老CPU,这很可能是-mno-avx.

It gets part way there. What is not clear is how to say, 'not this' and 'not that', which for old CPUs would be, most likely, -mno-avx.

对于一个旧的CPU,这很重要-march和

For an old cpu, which -march matters and Nephanth very usefully addresses this:

gcc -march=native -Q --help=target|grep march

产生

-march=                             westmere

这意味着我对./compile问题的回答应该是或可能是,并注意gcc文档中的引号"westmere",因此"必须出于某种原因而存在

which means my response to the ./compile question should be or might be, and note the quotes 'westmere' which is also in the gcc docs so the ' ' must be there for a reason

-march='westmere' -mssse3 -mcx16 -msse4.1 -msse4.2 -mpopcnt -mno-avx

但这可能更好(请参见下面的讨论):

but this is probably much better (see discussion below):

-march=native -mssse3 -mcx16 -msse4.1 -msse4.2 -mpopcnt -mno-avx

-mno-avx是gcc的一个选项,经过几个小时,结果是

The -mno-avx is an option for gcc, and results, after many hours, in

Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more 
information.
>>> import tensorflow as tf
>>> 
>>> tf.__version__
'2.0.0-alpha0'

看起来很成功.

已重定: 以任一顺序,找出您的CPU支持(或不支持)哪些指令,并明确说明这些指令.

Restated: In either order, find out what instructions are (or not) supported by your cpu, and state those explicitly.

这篇关于是否有未针对AVX指令编译的TensorFlow版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆