Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a version of TensorFlow not compiled for AVX instructions?

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) 

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. 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. I looked at How to compile Tensorflow with SSE4.2 and AVX instructions? and got scared

like image 786
bobe Avatar asked Dec 11 '18 11:12

bobe


People also ask

Does TensorFlow require AVX?

– Does TensorFlow Require AVX2? The default installable TensorFlow does not come with AVX2 enabled.

How can I determine if my CPU supports AVX instructions?

To know if your CPU supports AVX, hit the Windows key, search for windows system information and look for your CPU model from this pop-up window. Then, go to the manufacturer's website, and with the help of the model number, find out whether your CPU model supports AVX or not.

What is AVX instruction set used for?

Intel AVX-512 can accelerate performance for workloads and use cases such as scientific simulations, financial analytics, artificial intelligence (AI)/deep learning, 3D modeling and analysis, image and audio/video processing, cryptography, and data compression.


2 Answers

Try Anaconda. It should have TensorFlow distribution for old CPUs. Compilation of TensorFlow is difficult.

like image 44
FooBar167 Avatar answered Sep 21 '22 15:09

FooBar167


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 

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.

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.

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) 

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 

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.

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

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

produces

-march=                             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 

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' 

which looks like success.

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

like image 118
Chris Avatar answered Sep 19 '22 15:09

Chris