Tensorflow for mac AVX - python

I'm using TensorFlow but I'm getting the following warning
The TensorFlow library wasn't compiled to use AVX instructions, but
these are available on your machine and could speed up CPU
computations
I installed it using pip.
How can I fix it?

It's because you installed using pip it's a precompiled package that wasn't precompiled to the architecture you use, you need to build it from the source.
You can refer to he official tensorflow documentation on how to compile it from the source
https://www.tensorflow.org/install/install_sources

Related

how to find suitable version of tensorflow for my machine

inux version 5.15.0-58-generic (buildd#lcy02-amd64-101) (gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38)
conda version == 22.9.0
pip version == 22.2.2
python version 3.5 and 3.9
I have a machine with intel pentium g2020 cpu and it seems like it does not support AVX instructions. I am currently working on a project and need tensorflow (keras to be more precise) on my machine but any version that I install throws an error. I would need you help to find the suitable version for my machine and the a way to install it.
I tried different python version and tensorflow version but all of them throw errors like kernel died or your machine does not support AVX instructions.

Tensorflow install on Mac

I am having a difficult time getting tensorflow to install on a MacBook Pro.
Initially, I tried pip3.8 install tensorflow in my virtual environment. It installed but gives the following error when I try to use it:
This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
I get that this is a warning, but I think it's a serious warning that I am going to have performance issues with any non-trivial work.
Based on this post (Tensorflow on MacOS: Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA), I uninstalled tensorflow and followed the steps. After I installed Bazel, using homebrew, I got an error when I ran ./configure:
Please downgrade your Bazel installation to version 0.26.1.
According to this: (https://github.com/bazelbuild/bazel/releases) the oldest version is 3.2. I had 3.7 installed. So I uninstalled Bazel using homebrew. This felt like a dead end even though compiling from the source seems like the correct way to go. That version it's asking for is not even remotely close to a current version. I think the message is not telling me what I need to know.
Next I tried using pip to install the version recommended by Tensorflow.org. (https://www.tensorflow.org/install/pip.html)
pip3.8 install https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.4.0-cp38-cp38-macosx_10_14_x86_64.whl
This successfully installed as well, but gives me similar errors as my original install and fails the test recommended under the list of installations on the tensorflow.org page.
I think I'm making a novice mistake. Can anyone assist here?
It's not serious warning, you can either wait for macOS 12.0+ to have built-in Apple Metal Acceleration or run Intel optimized wheels for macOS, but it support only TensorFlow 2.0

Issue with tensorflow-mkl on CPU

I am new to tensorflow. In fact using it because the server code I am writing calls that.
I am using conda to setup the various packages. I did conda install -c anaconda tensorflow-mkl. (Note: I dont have a GPU - using a CPU)
I always get this error:
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX
The specific line of code where this happens:
tensorflow.contrib.predictor.from_saved_model(path)
On further research, I figured out that this is because the tensorflow package I have does not support this above instruction and needs to have support for the same.
Some questions:
1. How do we ensure the tensorflow package I have does support the above function? Any source from which I can download?
If it is not important, is there a way to suppress this instruction or any errors from it?
Thanks in advance!
You can use conda or pip installations to download the tensorflow that supports cpu. You can use the following commands from your terminal
conda install tensorflow -c anaconda
or
pip install tensorflow==1.13.1
You can use this link if you havent installed pip yet
How to install pip3 on Windows?
Hope this helps..
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX
This is just a warning.Not an error.
To suppress this warning please add the following lines before your actual code:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import tensorflow as tf
As per the tensorflow official documentation,starting with TensorFlow 1.6, binaries use AVX instructions which may not run on older CPUs.
You can refer the below url for more details on Intel Optimized tensorflow installation:
https://software.intel.com/en-us/articles/intel-optimization-for-tensorflow-installation-guide
Hope this answer your query.Thank you.

What's the problem of 'error code 3221225501' during running tensorflow codes

I try to run the keras codes with tensorflow backend. But it caused "ImportError: DLL load failed with error code 3221225501". It seems not sloved by others..
I just install python 3.7.4 in CPU enviroment and install the tensorflow with edition:tensorflow-1.13.1-cp37-cp37m-win_amd64.whl. And it is sucessfully installed. When I run my code, errors occours: ImportError: DLL load failed with error code 3221225501. I search the problem on internet, and lower down the tensorflow edition with 1.12.0 and download the files from github. It seems useless. So I come here for help.
Hope someone can provide a good suggestion, thanks in advance!
Please check if your CPU supports AVX Instructions.
If it does not support AVX instructions, then you should use TF version 1.5 or earlier versions.
From TF 1.6 and above, TF binaries uses AVX instructions.
Please refer to below link for more information.
Issue installing Tensorflow -- not a CUDA/CuDNN issue

How can I install the latest version of tensorflow?

I want to install the latest version of tensorflow (1.12.0) in my machine and installed it using pip install tensorflow. The 1.12.0 version of the tensorflow installed in my linux machine without any error but when I tried to import tensorflow in my python shell its giving this error and aborting the tensorflow import.
>>> import tensorflow as tf
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
In this answer it is said that its a simple warning but mine is not a warning its aborting the import of tensorflow completely. I tried uninstalling and reinstalling tensorflow multiple times but the same problem persists. I then tried to install the lowest version of tensorflow pip install tensorflow==1.0.0 this works and able to to install an older version of tensorflow.
How can I install the latest version of tensorflow?
Seem your CPU doesn't not support AVX instructions.
Since version 1.6 use AVX instructions, thus TF cannot be used on "old" CPUs.
However there is some unofficial built. But you will probably not find built on latest version of tensorflow.
Here is a thread about it : https://github.com/tensorflow/tensorflow/issues/18689

Categories